1 |
– |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* sm_del.c |
6 |
|
*/ |
62 |
|
error(CONSISTENCY,"Too many edges in vertex loop\n"); |
63 |
|
#endif |
64 |
|
Max_edges += 100; |
65 |
< |
if(!(Edges = (EDGE *)realloc(Edges,(Max_edges+1)*sizeof(EDGE)))) |
65 |
> |
if(!(Edges = (EDGE *)realloc((void *)Edges,(Max_edges+1)*sizeof(EDGE)))) |
66 |
|
goto memerr; |
67 |
|
} |
68 |
|
#ifdef DEBUG |
81 |
|
LIST |
82 |
|
*smVertexStar(sm,id) |
83 |
|
SM *sm; |
84 |
< |
int id; |
84 |
> |
S_ID id; |
85 |
|
{ |
86 |
|
TRI *tri,*t_next; |
87 |
|
LIST *elist,*end; |
88 |
< |
int e,t_id,v_next,t_next_id,b_id,v_id,t_last_id; |
88 |
> |
int e,t_id,t_next_id,b_id,v_id,t_last_id; |
89 |
> |
S_ID v_next; |
90 |
|
|
91 |
|
elist = end = NULL; |
92 |
|
|
139 |
|
int |
140 |
|
smTriangulate_add_tri(sm,id0,id1,id2,e0,e1,e2ptr) |
141 |
|
SM *sm; |
142 |
< |
int id0,id1,id2,e0,e1,*e2ptr; |
142 |
> |
S_ID id0,id1,id2; |
143 |
> |
int e0,e1,*e2ptr; |
144 |
|
{ |
145 |
|
int t_id,e2; |
146 |
|
TRI *t; |
176 |
|
SM *sm; |
177 |
|
LIST *l; |
178 |
|
{ |
179 |
< |
int e1,e2,e3,e4,e,t_id,id0,id1,id2,id3; |
179 |
> |
int e1,e2,e3,e4,e,t_id; |
180 |
> |
S_ID id0,id1,id2,id3; |
181 |
|
FVECT v0,v1,v2,v3,n; |
182 |
|
double dp; |
183 |
|
TRI *tri; |
248 |
|
return(TRUE); |
249 |
|
} |
250 |
|
|
251 |
+ |
eIn_tri(e,t) |
252 |
+ |
int e; |
253 |
+ |
TRI *t; |
254 |
+ |
{ |
255 |
+ |
|
256 |
+ |
if(T_NTH_V(t,0)==E_NTH_VERT(e,0)) |
257 |
+ |
return(T_NTH_V(t,1)==E_NTH_VERT(e,1)||T_NTH_V(t,2)==E_NTH_VERT(e,1)); |
258 |
+ |
else |
259 |
+ |
if(T_NTH_V(t,1)==E_NTH_VERT(e,0)) |
260 |
+ |
return(T_NTH_V(t,0)==E_NTH_VERT(e,1)||T_NTH_V(t,2)==E_NTH_VERT(e,1)); |
261 |
+ |
else if(T_NTH_V(t,2)==E_NTH_VERT(e,0)) |
262 |
+ |
return(T_NTH_V(t,0)==E_NTH_VERT(e,1)||T_NTH_V(t,1)==E_NTH_VERT(e,1)); |
263 |
+ |
|
264 |
+ |
return(FALSE); |
265 |
+ |
} |
266 |
+ |
|
267 |
+ |
|
268 |
|
/* Triangulate the polygon defined by plist, and generating vertex p_id. |
269 |
|
Return list of added triangles in list add_ptr. Returns TRUE if |
270 |
|
successful, FALSE otherwise. This is NOT a general triangulation routine, |
274 |
|
int |
275 |
|
smTriangulate(sm,id,plist) |
276 |
|
SM *sm; |
277 |
< |
int id; |
277 |
> |
S_ID id; |
278 |
|
LIST *plist; |
279 |
|
{ |
280 |
|
LIST *l,*prev,*t; |
281 |
|
FVECT v0,v1,v2,n,p; |
282 |
< |
int is_tri,cut,t_id,id0,id1,id2,e2,e1,enew; |
282 |
> |
int is_tri,cut,t_id,e2,e1,enew; |
283 |
> |
S_ID id0,id1,id2; |
284 |
|
double dp1,dp2; |
285 |
|
|
286 |
|
VSUB(p,SM_NTH_WV(sm,id),SM_VIEW_CENTER(sm)); |
346 |
|
id1 = id2; |
347 |
|
continue; |
348 |
|
} |
349 |
< |
} |
349 |
> |
} |
350 |
|
VCOPY(v0,v1); |
351 |
|
VCOPY(v1,v2); |
352 |
|
id0 = id1; |
364 |
|
if(!cut) |
365 |
|
break; |
366 |
|
cut = FALSE; |
349 |
– |
} |
350 |
– |
prev = l; |
367 |
|
} |
368 |
< |
if(is_tri) |
369 |
< |
{ |
368 |
> |
prev = l; |
369 |
> |
} |
370 |
> |
if(is_tri) |
371 |
> |
{ |
372 |
|
l = LIST_NEXT(l); |
373 |
|
enew = (int)LIST_DATA(l); |
374 |
|
t_id = smTriangulate_add_tri(sm,id0,id1,id2,e1,e2,&enew); |
375 |
|
free_list(l); |
376 |
< |
} |
377 |
< |
else |
378 |
< |
if(!smTriangulate_quad(sm,l)) |
376 |
> |
} |
377 |
> |
else |
378 |
> |
if(!smTriangulate_quad(sm,l)) |
379 |
|
goto Terror; |
362 |
– |
#if 0 |
363 |
– |
{int i; |
364 |
– |
eputs("\n\n"); |
365 |
– |
for(i=1;i<=Ecnt;i++) |
366 |
– |
fprintf(stderr,"%d verts %d %d tris %d %d\n", |
367 |
– |
i,Edges[i].verts[0],Edges[i].verts[1], |
368 |
– |
Edges[i].tris[0],Edges[i].tris[1]); |
369 |
– |
} |
370 |
– |
#endif |
371 |
– |
|
380 |
|
/* Set triangle adjacencies based on edge adjacencies */ |
381 |
|
FOR_ALL_EDGES(enew) |
382 |
|
{ |
388 |
|
|
389 |
|
e2 = (T_WHICH_V(SM_NTH_TRI(sm,id1),E_NTH_VERT(enew,1))+2)%3; |
390 |
|
T_NTH_NBR(SM_NTH_TRI(sm,id1),e2) = id0; |
391 |
< |
} |
384 |
< |
#if 0 |
385 |
< |
{int i; |
386 |
< |
eputs("\n\n"); |
387 |
< |
for(i=1;i<=Ecnt;i++) |
388 |
< |
fprintf(stderr,"%d verts %d %d tris %d %d\n", |
389 |
< |
i,Edges[i].verts[0],Edges[i].verts[1], |
390 |
< |
Edges[i].tris[0],Edges[i].tris[1]); |
391 |
< |
} |
392 |
< |
#endif |
391 |
> |
} |
392 |
|
|
393 |
|
#ifdef DEBUG |
394 |
|
#if DEBUG > 1 |
472 |
|
!T_IS_VALID(SM_NTH_TRI(sm,T_NTH_NBR(n,1))) || |
473 |
|
!T_IS_VALID(SM_NTH_TRI(sm,T_NTH_NBR(n,2)))) |
474 |
|
error(CONSISTENCY,"Invalid topology\n"); |
475 |
< |
} |
476 |
< |
} |
475 |
> |
} |
476 |
> |
|
477 |
> |
} |
478 |
|
#endif |
479 |
< |
#endif |
479 |
> |
#endif |
480 |
> |
|
481 |
|
return(TRUE); |
482 |
|
|
483 |
|
Terror: |
484 |
< |
#ifdef DEBUG |
484 |
> |
|
485 |
|
error(CONSISTENCY,"smTriangulate():Unable to triangulate\n"); |
485 |
– |
#endif |
486 |
– |
} |
486 |
|
|
488 |
– |
eIn_tri(e,t) |
489 |
– |
int e; |
490 |
– |
TRI *t; |
491 |
– |
{ |
492 |
– |
|
493 |
– |
if(T_NTH_V(t,0)==E_NTH_VERT(e,0)) |
494 |
– |
return(T_NTH_V(t,1)==E_NTH_VERT(e,1)||T_NTH_V(t,2)==E_NTH_VERT(e,1)); |
495 |
– |
else |
496 |
– |
if(T_NTH_V(t,1)==E_NTH_VERT(e,0)) |
497 |
– |
return(T_NTH_V(t,0)==E_NTH_VERT(e,1)||T_NTH_V(t,2)==E_NTH_VERT(e,1)); |
498 |
– |
else if(T_NTH_V(t,2)==E_NTH_VERT(e,0)) |
499 |
– |
return(T_NTH_V(t,0)==E_NTH_VERT(e,1)||T_NTH_V(t,1)==E_NTH_VERT(e,1)); |
500 |
– |
|
501 |
– |
return(FALSE); |
487 |
|
} |
488 |
|
|
489 |
|
|
494 |
|
int e,e1; |
495 |
|
int *tn_id,*tn1_id; |
496 |
|
{ |
497 |
< |
int verts[3],enext,eprev,e1next,e1prev; |
497 |
> |
S_ID verts[3]; |
498 |
> |
int enext,eprev,e1next,e1prev; |
499 |
|
TRI *n,*ta,*tb,*t,*t1; |
500 |
|
FVECT p1,p2,p3; |
501 |
|
int ta_id,tb_id; |
636 |
|
SM *sm; |
637 |
|
{ |
638 |
|
int e,t0_id,t1_id,e_new,e0,e1,e0_next,e1_next; |
639 |
< |
int i,v0_id,v1_id,v2_id,p_id,t0_nid,t1_nid; |
639 |
> |
S_ID v0_id,v1_id,v2_id,p_id; |
640 |
> |
int i,t0_nid,t1_nid; |
641 |
|
FVECT v0,v1,v2,p,np,v; |
642 |
|
TRI *t0,*t1; |
643 |
|
|
711 |
|
|
712 |
|
smDelete_samp(sm,s_id) |
713 |
|
SM *sm; |
714 |
< |
int s_id; |
714 |
> |
S_ID s_id; |
715 |
|
{ |
716 |
|
QUADTREE qt; |
717 |
< |
OBJECT *os; |
717 |
> |
S_ID *os; |
718 |
|
|
719 |
|
/* Mark as free */ |
720 |
|
smUnalloc_samp(sm,s_id); |
734 |
|
int |
735 |
|
smRemoveVertex(sm,id) |
736 |
|
SM *sm; |
737 |
< |
int id; |
737 |
> |
S_ID id; |
738 |
|
{ |
739 |
|
LIST *b_list; |
740 |
|
/* generate list of edges that form the boundary of the |