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.2 by gwlarson, Mon Aug 24 12:38:57 1998 UTC vs.
Revision 3.3 by gwlarson, Fri Sep 11 11:52:25 1998 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ SGI";
16   static EDGE Edges[MAX_EDGES];
17   static int Ecnt=0;
18  
19 + int
20 + remove_tri(qtptr,fptr,t_id)
21 +   QUADTREE *qtptr;
22 +   int *fptr;
23 +   int t_id;
24 + {
25 +    OBJECT tset[QT_MAXSET+1];  
26 +    int n;
27  
28 +   if(QT_IS_EMPTY(*qtptr))
29 +     return(FALSE);
30 +   /* remove id from set */
31 +      else
32 +      {
33 +         if(!qtinset(*qtptr,t_id))
34 +           return(FALSE);
35 +         n = QT_SET_CNT(qtqueryset(*qtptr))-1;
36 +         *qtptr = qtdelelem(*qtptr,t_id);
37 +          if(n  == 0)
38 +             (*fptr) |= QT_COMPRESS;
39 +        if(!QT_FLAG_FILL_TRI(*fptr))
40 +          (*fptr)++;
41 +      }
42 +    return(TRUE);
43 + }
44 +
45 + int
46 + remove_tri_compress(qtptr,q0,q1,q2,t0,t1,t2,n,arg,t_id)
47 + QUADTREE *qtptr;
48 + FVECT q0,q1,q2;
49 + FVECT t0,t1,t2;
50 + int n;
51 + int *arg;
52 + int t_id;
53 + {
54 +    int f = 0;
55 +    /* NOTE compress */
56 +    return(remove_tri(qtptr,&f,t_id));
57 + }
58 +
59 +
60 +
61 + int
62 + stDelete_tri(st,t_id,t0,t1,t2)
63 +   STREE *st;
64 +   int t_id;
65 +   FVECT t0,t1,t2;
66 + {
67 +    int f;
68 +    FVECT dir;
69 +    
70 +  /* First add all of the leaf cells lying on the triangle perimeter:
71 +     mark all cells seen on the way
72 +   */
73 +    ST_CLEAR_FLAGS(st);
74 +    f = 0;
75 +    VSUB(dir,t1,t0);
76 +    stTrace_edge(st,t0,dir,1.0,remove_tri,&f,t_id);
77 +    VSUB(dir,t2,t1);
78 +    stTrace_edge(st,t1,dir,1.0,remove_tri,&f,t_id);
79 +    VSUB(dir,t0,t2);
80 +    stTrace_edge(st,t2,dir,1.0,remove_tri,&f,t_id);
81 +    /* Now visit interior */
82 +    if(QT_FLAG_FILL_TRI(f) || QT_FLAG_UPDATE(f))
83 +       stVisit_tri_interior(st,t0,t1,t2,remove_tri_compress,&f,t_id);
84 + }
85 +
86 +
87   smLocator_remove_tri(sm,t_id)
88   SM *sm;
89   int t_id;
# Line 24 | Line 91 | int t_id;
91    STREE *st;
92    char found;
93    TRI *t;
94 <  FVECT p0,p1,p2;
94 >  FVECT v0,v1,v2;
95  
96    st = SM_LOCATOR(sm);
97  
98    t = SM_NTH_TRI(sm,t_id);
99  
100 <  smDir(sm,p0,T_NTH_V(t,0));
101 <  smDir(sm,p1,T_NTH_V(t,1));
102 <  smDir(sm,p2,T_NTH_V(t,2));
103 <
37 <  found = stRemove_tri(st,t_id,p0,p1,p2);
38 <
100 >  VSUB(v0,SM_T_NTH_WV(sm,t,0),SM_VIEW_CENTER(sm));
101 >  VSUB(v1,SM_T_NTH_WV(sm,t,1),SM_VIEW_CENTER(sm));
102 >  VSUB(v2,SM_T_NTH_WV(sm,t,2),SM_VIEW_CENTER(sm));
103 >  found = stUpdate_tri(st,t_id,v0,v1,v2,remove_tri,remove_tri_compress);
104    return(found);
105   }
106  
# Line 168 | Line 233 | LIST *l;
233        e = (int)LIST_DATA(el);
234        id_e0 = E_NTH_VERT(e,0);
235        id_e1 = E_NTH_VERT(e,1);
236 <
236 >      /* NOTE: DO these need to be normalized? Just subtract center? */
237        smDir(sm,e0,id_e0);
238        smDir(sm,e1,id_e1);
239 <      if(spherical_polygon_edge_intersect(v0,v1,e0,e1))
239 >      if(sedge_intersect(v0,v1,e0,e1))
240          return(TRUE);
241  
242        el = LIST_NEXT(el);
# Line 284 | Line 349 | LIST **l,**lnew;
349   }
350  
351  
352 <
353 < LIST
289 < *smTriangulate_convex(sm,plist)
352 > int
353 > smTriangulate_convex(sm,plist)
354   SM *sm;
355   LIST *plist;
356   {
# Line 328 | Line 392 | LIST *plist;
392  
393          e_id0 = -e_id2;
394      }
395 +    
396      free_list(plist);
397 +    return(TRUE);
398   }
399 <
399 > int
400   smTriangulate_elist(sm,plist)
401   SM *sm;
402   LIST *plist;
# Line 339 | Line 405 | LIST *plist;
405      FVECT v0,v1,v2;
406      int id0,id1,id2,e,id_next;
407      char flipped;
408 <    int debug = TRUE;
408 >    int done;
409  
410      l = plist;
411      
# Line 371 | Line 437 | LIST *plist;
437   #ifdef DEBUG
438            eputs("smTriangulate_elist():Unable to find convex vertex\n");
439   #endif
440 <          return;
440 >          return(FALSE);
441        }
442        /* add edge */
443        el1 = NULL;
444        /* Split edge list l into two lists: one from id1-id_next-id1,
445           and the next from id2-id_next-id2
446        */
447 <      debug = split_edge_list(id1,id_next,&l,&el1);
447 >      split_edge_list(id1,id_next,&l,&el1);
448        /* Recurse and triangulate the two edge lists */
449 <      if(debug)
450 <        debug = smTriangulate_elist(sm,l);
451 <      if(debug)
452 <        debug = smTriangulate_elist(sm,el1);
387 <
388 <      return(debug);
449 >      done = smTriangulate_elist(sm,l);
450 >      if(done)
451 >        done = smTriangulate_elist(sm,el1);
452 >      return(done);
453      }
454 <    smTriangulate_convex(sm,plist);
455 <    return(TRUE);
454 >    done = smTriangulate_convex(sm,plist);
455 >    return(done);
456   }
457  
458   int
459 < smTriangulate_polygon(sm,plist)
459 > smTriangulate(sm,plist)
460   SM *sm;
461   LIST *plist;
462   {
# Line 400 | Line 464 | LIST *plist;
464      TRI *t0,*t1;
465      int test;
466      
467 <    test = smTriangulate_elist(sm,plist,NULL);
467 >    test = smTriangulate_elist(sm,plist);
468  
469      if(!test)
470         return(test);
# Line 411 | Line 475 | LIST *plist;
475          if((id_t0==SM_INVALID) || (id_t1==SM_INVALID))
476          {
477   #ifdef DEBUG
478 <           eputs("smTriangulate_polygon(): Unassigned edge neighbor\n");
478 >           eputs("smTriangulate(): Unassigned edge neighbor\n");
479   #endif
480              continue;
481          }
# Line 534 | Line 598 | smMesh_remove_vertex(sm,id)
598         return(FALSE);
599  
600      /* Triangulate spherical polygon */
601 <    debug = smTriangulate_polygon(sm,elist);
601 >    smTriangulate(sm,elist);
602  
603  
604      /* Fix up new triangles to be Delaunay */
605 <    if(debug)
542 <       smFix_edges(sm);
605 >    smFix_edges(sm);
606  
607      return(TRUE);
608   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines