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

Comparing ray/src/hd/sm_del.c (file contents):
Revision 3.7 by gwlarson, Wed Nov 11 12:05:38 1998 UTC vs.
Revision 3.9 by gwlarson, Tue Jan 5 16:52:37 1999 UTC

# Line 19 | Line 19 | static int Max_edges=200;
19   static EDGE *Edges=NULL;
20   static int Ecnt=0;
21  
22 #define remove_tri_compress remove_tri
23 remove_tri(qtptr,fptr,tptr)
24   QUADTREE *qtptr;
25   int *fptr;
26   int *tptr;
27 {
28    int n;
29
30    if(QT_IS_EMPTY(*qtptr))
31      return;
32    if(QT_LEAF_IS_FLAG(*qtptr))
33      return;
34
35    n = QT_SET_CNT(qtqueryset(*qtptr))-1;
36    *qtptr = qtdelelem(*qtptr,*tptr);
37    if(n  == 0)
38      (*fptr) |= QT_COMPRESS;
39    if(!QT_FLAG_FILL_TRI(*fptr))
40      (*fptr)++;
41 }
42
43
44 smLocator_remove_tri(sm,t_id,v0_id,v1_id,v2_id)
45 SM *sm;
46 int t_id;
47 int v0_id,v1_id,v2_id;
48 {
49  STREE *st;
50  FVECT v0,v1,v2;
51  
52  st = SM_LOCATOR(sm);
53
54  VSUB(v0,SM_NTH_WV(sm,v0_id),SM_VIEW_CENTER(sm));
55  VSUB(v1,SM_NTH_WV(sm,v1_id),SM_VIEW_CENTER(sm));
56  VSUB(v2,SM_NTH_WV(sm,v2_id),SM_VIEW_CENTER(sm));
57
58  qtClearAllFlags();
59  
60  stApply_to_tri(st,v0,v1,v2,remove_tri,remove_tri_compress,&t_id);
61
62 }
63
22   smFree_tri(sm,id)
23   SM *sm;
24   int id;
25   {
26 <  TRI *tri;
26 >  TRI *tri,*t;
27  
28    tri = SM_NTH_TRI(sm,id);
29    /* Add to the free_list */
30 +
31    T_NEXT_FREE(tri) = SM_FREE_TRIS(sm);
32    SM_FREE_TRIS(sm) = id;
33    T_VALID_FLAG(tri) = -1;
# Line 88 | Line 47 | int t_id;
47       to id because the vertices can no longer
48       point to tri id as being the first triangle pointer
49    */
50 +  SM_SAMPLE_TRIS(sm)--;
51    if(!SM_IS_NTH_T_BASE(sm,t_id))
52    {
53 <    SM_SAMPLE_TRIS(sm)--;
53 >
54 > #if 0
55      if(SM_IS_NTH_T_NEW(sm,t_id))
56        smNew_tri_cnt--;
57 + #endif
58    }
59    smClear_tri_flags(sm,t_id);
60  
# Line 125 | Line 87 | memerr:
87   adjacent to id. Return set of triangles adjacent to id to delete in delptr
88   */
89   LIST
90 < *smVertexPolygon(sm,id,delptr)
90 > *smVertexPolygon(sm,id,del_ptr)
91   SM *sm;
92   int id;
93 < QUADTREE *delptr;
93 > LIST **del_ptr;
94   {
95      TRI *tri,*t_next;
96      LIST *elist,*end;
97      int e,t_id,v_next,t_next_id,b_id,v_id;
136    OBJECT del_set[2];
98  
99      eClear_edges();
100      elist = end =  NULL;
# Line 156 | Line 117 | QUADTREE *delptr;
117      t_next_id = t_id;
118      t_next = tri;
119  
120 +    *del_ptr = push_data(*del_ptr,t_id);
121      /* Create a set to hold all of the triangles for deletion later */
160    del_set[0] = 1; del_set[1] = t_id;
161    *delptr = qtnewleaf(del_set);
122  
123      while((t_next_id = T_NTH_NBR(t_next,b_id)) != t_id)
124      {
# Line 172 | Line 132 | QUADTREE *delptr;
132        v_next = T_NTH_V(t_next,(b_id+1)%3);
133        SET_E_NTH_VERT(e,1,v_next);
134        elist = add_data_to_circular_list(elist,&end,e);
135 <      qtaddelem(*delptr,t_next_id);
135 >      *del_ptr = push_data(*del_ptr,t_next_id);
136      }
137      return(elist);
138   }
# Line 261 | Line 221 | LIST *plist,**add_ptr;
221      FVECT v0,v1,v2,n,p;
222      int is_tri,is_convex,cut,t_id,id0,id1,id2,e2,e1,enew;
223      double dp;
224 +    static int debug=0;
225  
226      VSUB(p,SM_NTH_WV(sm,id),SM_VIEW_CENTER(sm));
227      enew = 0;
# Line 354 | Line 315 | LIST *plist,**add_ptr;
315   #ifdef DEBUG
316            eputs("smTriangulate():Unable to triangulate\n");
317   #endif
318 <          free_list(l);
318 >         free_list(l);
319            while(*add_ptr)
320            {
321              t_id = pop_list(add_ptr);
322              smDelete_tri(sm,t_id);
323            }
324            return(FALSE);
325 <        }
325 >         }
326 >        
327          cut = FALSE;
328          is_convex = TRUE;
329        }
# Line 416 | Line 378 | TRI *t;
378     lies inside the circle defined by the CCW triangle- the edge is swapped
379     for the opposite diagonal
380   */
381 < smFixEdges(sm,add_list,delptr)
381 > smFixEdges(sm,add_list)
382     SM *sm;
383     LIST *add_list;
422   QUADTREE *delptr;
423
384   {
385      int e,t0_id,t1_id,e_new,e0,e1,e0_next,e1_next;
386      int i,v0_id,v1_id,v2_id,p_id,t0_nid,t1_nid;
# Line 455 | Line 415 | smFixEdges(sm,add_list,delptr)
415          VSUB(p,p,SM_VIEW_CENTER(sm));
416          if(point_in_cone(p,v0,v1,v2))
417          {
418 <           smTris_swap_edge(sm,t0_id,t1_id,e0,e1,&t0_nid,&t1_nid,&add_list,
459 <                            delptr);
418 >           smTris_swap_edge(sm,t0_id,t1_id,e0,e1,&t0_nid,&t1_nid,&add_list);
419              
420             /* Adjust the triangle pointers of the remaining edges to be
421                processed
# Line 489 | Line 448 | smFixEdges(sm,add_list,delptr)
448          }
449      }
450      /* Add/Delete the appropriate triangles from the stree */
451 <    smUpdate_locator(sm,add_list,qtqueryset(*delptr));
493 <
451 >    smUpdate_locator(sm,add_list);
452   }
453  
454   /* Remove vertex "id" from the mesh- and retriangulate the resulting
# Line 501 | Line 459 | smRemoveVertex(sm,id)
459     SM *sm;
460     int id;
461   {
462 <    LIST *b_list,*add_list;
463 <    QUADTREE delnode=-1;
464 <    int t_id;
465 <
462 >    LIST *b_list,*add_list,*del_list;
463 >    int t_id,i;
464 >    static int cnt=0;
465 >    OBJECT *optr,*os;
466      /* generate list of edges that form the boundary of the
467         polygon formed by the triangles adjacent to vertex 'id'
468       */
469 <    b_list = smVertexPolygon(sm,id,&delnode);
469 >    del_list = NULL;
470 >    b_list = smVertexPolygon(sm,id,&del_list);
471  
472      add_list = NULL;
473      /* Triangulate polygonal hole  */
474      if(!smTriangulate(sm,id,b_list,&add_list))
475      {
476 <      qtfreeleaf(delnode);
476 >      free_list(del_list);
477        return(FALSE);
478      }
479 +    else
480 +    {
481 + #ifdef DEBUG
482 +      b_list = del_list;
483 +      while(b_list)
484 +      {
485 +        t_id = LIST_DATA(b_list);
486 +        b_list = LIST_NEXT(b_list);
487 +        T_VALID_FLAG(SM_NTH_TRI(sm,t_id))=-1;
488 +      }
489 + #endif
490 +      while(del_list)
491 +      {
492 +        t_id = pop_list(&del_list);
493 +        smDelete_tri(sm,t_id);
494 +      }    
495 +    }      
496      /* Fix up new triangles to be Delaunay-delnode contains set of
497       triangles to delete,add_list is the set of new triangles to add
498       */
499 <    smFixEdges(sm,add_list,&delnode);
499 >    smFixEdges(sm,add_list);
500  
525
526    qtfreeleaf(delnode);
501      return(TRUE);
502   }
503    
504  
505  
506 <
506 >
507  
508  
509  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines