ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/sm.c
(Generate patch)

Comparing ray/src/hd/sm.c (file contents):
Revision 3.2 by gwlarson, Thu Aug 20 16:47:21 1998 UTC vs.
Revision 3.3 by gwlarson, Mon Aug 24 12:38:57 1998 UTC

# Line 343 | Line 343 | TRI **tptr;
343      SM_NTH_VERT(sm,v1_id) = t_id;
344      SM_NTH_VERT(sm,v2_id) = t_id;
345  
346    /* Add triangle to the locator */
347    smLocator_add_tri(sm,t_id,v0_id,v1_id,v2_id);
346      if(t)
347         *tptr = t;
348      /* return initialized triangle */
# Line 442 | Line 440 | FVECT p;
440   }
441  
442   void
443 < smTris_swap_edge(sm,t_id,t1_id,e,e1,tn_id,tn1_id)
443 > smTris_swap_edge(sm,t_id,t1_id,e,e1,tn_id,tn1_id,add,del)
444     SM *sm;
445     int t_id,t1_id;
446     int e,e1;
447     int **tn_id,**tn1_id;
448 +   LIST **add,**del;
449  
450   {
451      TRI *t,*t1;
# Line 469 | Line 468 | smTris_swap_edge(sm,t_id,t1_id,e,e1,tn_id,tn1_id)
468      verts[enext] = T_NTH_V(t1,e1prev);
469      verts[eprev] = T_NTH_V(t,eprev);
470      ta_id = smAdd_tri(sm,verts[0],verts[1],verts[2],&ta);
471 +    *add = push_data(*add,ta_id);
472  
473      verts[e1] = T_NTH_V(t1,e1);
474      verts[e1next] = T_NTH_V(t,eprev);
475      verts[e1prev] = T_NTH_V(t1,e1prev);
476      tb_id = smAdd_tri(sm,verts[0],verts[1],verts[2],&tb);
477 <    
477 >    *add = push_data(*add,tb_id);
478 >
479      /* set the neighbors */
480      T_NTH_NBR(ta,e) = T_NTH_NBR(t1,e1next);
481      T_NTH_NBR(tb,e1) = T_NTH_NBR(t,enext);
# Line 495 | Line 496 | smTris_swap_edge(sm,t_id,t1_id,e,e1,tn_id,tn1_id)
496      T_NTH_NBR(n,T_NTH_NBR_PTR(t1_id,n)) = tb_id;
497  
498      /* Delete two parent triangles */
499 <    smDelete_tri(sm,t_id);
500 <    smDelete_tri(sm,t1_id);
499 >    *del = push_data(*del,t_id);
500 >    if(SM_IS_NTH_T_NEW(sm,t_id))
501 >      SM_CLEAR_NTH_T_NEW(sm,t_id);
502 >    else
503 >      SM_CLEAR_NTH_T_BASE(sm,t_id);
504 >    *del = push_data(*del,t1_id);
505 >    if(SM_IS_NTH_T_NEW(sm,t1_id))
506 >      SM_CLEAR_NTH_T_NEW(sm,t1_id);
507 >    else
508 >      SM_CLEAR_NTH_T_BASE(sm,t1_id);
509      *tn_id = ta_id;
510      *tn1_id = tb_id;
511   }
512  
513 + smUpdate_locator(sm,add_list,del_list)
514 + SM *sm;
515 + LIST *add_list,*del_list;
516 + {
517 +  int t_id;
518 +  TRI *t;
519 +  while(add_list)
520 +  {
521 +    t_id = pop_list(&add_list);
522 +    if(!SM_IS_NTH_T_NEW(sm,t_id) && !SM_IS_NTH_T_BASE(sm,t_id))
523 +    {
524 +      SM_SET_NTH_T_NEW(sm,t_id);
525 +      continue;
526 +    }
527 +    t = SM_NTH_TRI(sm,t_id);
528 +    smLocator_add_tri(sm,t_id,T_NTH_V(t,0),T_NTH_V(t,1),T_NTH_V(t,2));
529 +  }
530 +  
531 +  while(del_list)
532 +  {
533 +    t_id = pop_list(&del_list);
534 +    if(SM_IS_NTH_T_NEW(sm,t_id))
535 +    {
536 +      smDelete_tri(sm,t_id);
537 +      continue;
538 +    }
539 +    smLocator_remove_tri(sm,t_id);
540 +    smDelete_tri(sm,t_id);
541 +  }
542 + }
543   /* MUST add check for constrained edges */
544 < char
544 > int
545   smFix_tris(sm,id,tlist)
546   SM *sm;
547   int id;
548   LIST *tlist;
549   {
550      TRI *t,*t_opp;
551 <    FVECT p,p1,np,p2,p3;
552 <    int swapped = 0;
514 <    int e,e1,e_id;
515 <    char debug = 0;
551 >    FVECT p,p1,p2,p3;
552 >    int e,e1,swapped = 0;
553      int t_id,t_opp_id;
554 <    
555 <    VCOPY(p,SM_NTH_WV(sm,id));    
556 <    VSUB(p,p,SM_VIEW_CENTER(sm));
554 >    LIST *add_list,*del_list;
555 >
556 >
557 >    add_list = del_list = NULL;
558 >    VSUB(p,SM_NTH_WV(sm,id),SM_VIEW_CENTER(sm));
559      while(tlist)
560      {
561 <        t_id = (int)pop_list(&tlist);
561 >        t_id = pop_list(&tlist);
562          t = SM_NTH_TRI(sm,t_id);
563          e = (T_WHICH_V(t,id)+1)%3;
564          t_opp_id = T_NTH_NBR(t,e);
# Line 534 | Line 573 | LIST *tlist;
573              e1 = T_NTH_NBR_PTR(t_id,t_opp);
574              /* check list for t_opp and Remove if there */
575              remove_from_list(t_opp_id,&tlist);
576 <
577 <            smTris_swap_edge(sm,t_id,t_opp_id,e,e1,&t_id,&t_opp_id);
576 >            smTris_swap_edge(sm,t_id,t_opp_id,e,e1,&t_id,&t_opp_id,
577 >                             &add_list,&del_list);
578              tlist = push_data(tlist,t_id);
579              tlist = push_data(tlist,t_opp_id);
580          }
581      }
582 +    smUpdate_locator(sm,add_list,del_list);
583 +
584      return(swapped);
585   }
586  
# Line 670 | Line 711 | smInsert_point_in_tri(sm,c,dir,p,s_id,tri_id)
711        n_id = smClosest_vertex_in_tri(sm,t0_id,t1_id,t2_id,npt,P_REPLACE_EPS);
712      }
713      t0_id = smAdd_tri(sm,s_id,v0_id,v1_id,&t0);
714 +    /* Add triangle to the locator */
715 +    smLocator_add_tri(sm,t0_id,s_id,v0_id,v1_id);
716 +
717      t1_id = smAdd_tri(sm,s_id,v1_id,v2_id,&t1);
718 +    smLocator_add_tri(sm,t1_id,s_id,v1_id,v2_id);
719      t2_id = smAdd_tri(sm,s_id,v2_id,v0_id,&t2);
720 <        
720 >    smLocator_add_tri(sm,t2_id,s_id,v2_id,v0_id);      
721 >
722      /* Set the neighbor pointers for the new tris */
723      T_NTH_NBR(t0,0) = t2_id;
724      T_NTH_NBR(t0,1) = T_NTH_NBR(tri,0);
# Line 692 | Line 738 | smInsert_point_in_tri(sm,c,dir,p,s_id,tri_id)
738      nbr = SM_NTH_TRI(sm,T_NTH_NBR(tri,2));
739      T_NTH_NBR(nbr,T_NTH_NBR_PTR(tri_id,nbr)) = t2_id;
740          
741 +    smLocator_remove_tri(sm,tri_id);
742      smDelete_tri(sm,tri_id);
743          
744      /* Fix up the new triangles*/
# Line 957 | Line 1004 | int type;
1004      v2_id = p[stTri_verts[i][2]];
1005      if((ids[i] = smAdd_tri(sm, v0_id,v1_id,v2_id,&(tris[i])))== -1)
1006       return(0);
1007 +    smLocator_add_tri(sm,ids[i],v0_id,v1_id,v2_id);
1008    }
1009    /* Set neighbors */
1010  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines