71 if (pair == NULL)
return NULL;
77 if( eNext->Sym < eNext ) { eNext = eNext->Sym; }
82 ePrev = eNext->Sym->next;
86 eNext->Sym->next = eSym;
94 e->activeRegion = NULL;
102 eSym->activeRegion = NULL;
118 aOnext->Sym->Lnext = b;
119 bOnext->Sym->Lnext = a;
130 static void MakeVertex(
GLUvertex *newVertex,
137 assert(vNew != NULL);
146 vNew->anEdge = eOrig;
155 }
while( e != eOrig );
170 assert(fNew != NULL);
179 fNew->anEdge = eOrig;
182 fNew->marked = FALSE;
187 fNew->inside = fNext->inside;
194 }
while( e != eOrig );
205 if( eDel->Sym < eDel ) { eDel = eDel->Sym; }
209 ePrev = eDel->Sym->next;
210 eNext->Sym->next = ePrev;
211 ePrev->Sym->next = eNext;
230 }
while( e != eStart );
254 }
while( e != eStart );
279 if (newVertex1 == NULL || newVertex2 == NULL || newFace == NULL) {
280 if (newVertex1 != NULL) memFree(newVertex1);
281 if (newVertex2 != NULL) memFree(newVertex2);
282 if (newFace != NULL) memFree(newFace);
286 e = MakeEdge( &mesh->eHead );
287 if (e == NULL)
return NULL;
289 MakeVertex( newVertex1, e, &mesh->vHead );
290 MakeVertex( newVertex2, e->Sym, &mesh->vHead );
291 MakeFace( newFace, e, &mesh->fHead );
321 int joiningLoops = FALSE;
322 int joiningVertices = FALSE;
324 if( eOrg == eDst )
return 1;
326 if( eDst->Org != eOrg->Org ) {
328 joiningVertices = TRUE;
329 KillVertex( eDst->Org, eOrg->Org );
331 if( eDst->Lface != eOrg->Lface ) {
334 KillFace( eDst->Lface, eOrg->Lface );
338 Splice( eDst, eOrg );
340 if( ! joiningVertices ) {
342 if (newVertex == NULL)
return 0;
347 MakeVertex( newVertex, eDst, eOrg->Org );
348 eOrg->Org->anEdge = eOrg;
350 if( ! joiningLoops ) {
352 if (newFace == NULL)
return 0;
357 MakeFace( newFace, eDst, eOrg->Lface );
358 eOrg->Lface->anEdge = eOrg;
378 int joiningLoops = FALSE;
383 if( eDel->Lface != eDel->Rface ) {
386 KillFace( eDel->Lface, eDel->Rface );
389 if( eDel->Onext == eDel ) {
390 KillVertex( eDel->Org, NULL );
393 eDel->Rface->anEdge = eDel->Oprev;
394 eDel->Org->anEdge = eDel->Onext;
396 Splice( eDel, eDel->Oprev );
397 if( ! joiningLoops ) {
399 if (newFace == NULL)
return 0;
402 MakeFace( newFace, eDel, eDel->Lface );
409 if( eDelSym->Onext == eDelSym ) {
410 KillVertex( eDelSym->Org, NULL );
411 KillFace( eDelSym->Lface, NULL );
414 eDel->Lface->anEdge = eDelSym->Oprev;
415 eDelSym->Org->anEdge = eDelSym->Onext;
416 Splice( eDelSym, eDelSym->Oprev );
441 if (eNew == NULL)
return NULL;
446 Splice( eNew, eOrg->Lnext );
449 eNew->Org = eOrg->Dst;
452 if (newVertex == NULL)
return NULL;
454 MakeVertex( newVertex, eNewSym, eNew->Org );
456 eNew->Lface = eNewSym->Lface = eOrg->Lface;
469 GLUhalfEdge *tempHalfEdge= __gl_meshAddEdgeVertex( eOrg );
470 if (tempHalfEdge == NULL)
return NULL;
472 eNew = tempHalfEdge->Sym;
475 Splice( eOrg->Sym, eOrg->Sym->Oprev );
476 Splice( eOrg->Sym, eNew );
479 eOrg->Dst = eNew->Org;
480 eNew->Dst->anEdge = eNew->Sym;
481 eNew->Rface = eOrg->Rface;
482 eNew->winding = eOrg->winding;
483 eNew->Sym->winding = eOrg->Sym->winding;
502 int joiningLoops = FALSE;
504 if (eNew == NULL)
return NULL;
508 if( eDst->Lface != eOrg->Lface ) {
511 KillFace( eDst->Lface, eOrg->Lface );
515 Splice( eNew, eOrg->Lnext );
516 Splice( eNewSym, eDst );
519 eNew->Org = eOrg->Dst;
520 eNewSym->Org = eDst->Org;
521 eNew->Lface = eNewSym->Lface = eOrg->Lface;
524 eOrg->Lface->anEdge = eNewSym;
526 if( ! joiningLoops ) {
528 if (newFace == NULL)
return NULL;
531 MakeFace( newFace, eNew, eOrg->Lface );
546 void __gl_meshZapFace(
GLUface *fZap )
553 eNext = eStart->Lnext;
559 if( e->Rface == NULL ) {
562 if( e->Onext == e ) {
563 KillVertex( e->Org, NULL );
566 e->Org->anEdge = e->Onext;
567 Splice( e, e->Oprev );
570 if( eSym->Onext == eSym ) {
571 KillVertex( eSym->Org, NULL );
574 eSym->Org->anEdge = eSym->Onext;
575 Splice( eSym, eSym->Oprev );
579 }
while( e != eStart );
594 GLUmesh *__gl_meshNewMesh(
void )
608 eSym = &mesh->eHeadSym;
610 v->next = v->prev = v;
614 f->next = f->prev = f;
628 e->activeRegion = NULL;
637 eSym->activeRegion = NULL;
656 if( f2->next != f2 ) {
657 f1->prev->next = f2->next;
658 f2->next->prev = f1->prev;
663 if( v2->next != v2 ) {
664 v1->prev->next = v2->next;
665 v2->next->prev = v1->prev;
670 if( e2->next != e2 ) {
671 e1->Sym->next->Sym->next = e2->next;
672 e2->next->Sym->next = e1->Sym->next;
673 e2->Sym->next->Sym->next = e1;
674 e1->Sym->next = e2->Sym->next;
682 #ifdef DELETE_BY_ZAPPING
686 void __gl_meshDeleteMesh(
GLUmesh *mesh )
690 while( fHead->next != fHead ) {
691 __gl_meshZapFace( fHead->next );
693 assert( mesh->vHead.next == &mesh->vHead );
702 void __gl_meshDeleteMesh(
GLUmesh *mesh )
708 for( f = mesh->fHead.next; f != &mesh->fHead; f = fNext ) {
713 for( v = mesh->vHead.next; v != &mesh->vHead; v = vNext ) {
718 for( e = mesh->eHead.next; e != &mesh->eHead; e = eNext ) {
733 void __gl_meshCheckMesh(
GLUmesh *mesh )
743 for( fPrev = fHead ; (f = fPrev->next) != fHead; fPrev = f) {
744 assert( f->prev == fPrev );
747 assert( e->Sym != e );
748 assert( e->Sym->Sym == e );
749 assert( e->Lnext->Onext->Sym == e );
750 assert( e->Onext->Sym->Lnext == e );
751 assert( e->Lface == f );
753 }
while( e != f->anEdge );
755 assert( f->prev == fPrev && f->anEdge == NULL && f->data == NULL );
758 for( vPrev = vHead ; (v = vPrev->next) != vHead; vPrev = v) {
759 assert( v->prev == vPrev );
762 assert( e->Sym != e );
763 assert( e->Sym->Sym == e );
764 assert( e->Lnext->Onext->Sym == e );
765 assert( e->Onext->Sym->Lnext == e );
766 assert( e->Org == v );
768 }
while( e != v->anEdge );
770 assert( v->prev == vPrev && v->anEdge == NULL && v->data == NULL );
773 for( ePrev = eHead ; (e = ePrev->next) != eHead; ePrev = e) {
774 assert( e->Sym->next == ePrev->Sym );
775 assert( e->Sym != e );
776 assert( e->Sym->Sym == e );
777 assert( e->Org != NULL );
778 assert( e->Dst != NULL );
779 assert( e->Lnext->Onext->Sym == e );
780 assert( e->Onext->Sym->Lnext == e );
782 assert( e->Sym->next == ePrev->Sym
783 && e->Sym == &mesh->eHeadSym
785 && e->Org == NULL && e->Dst == NULL
786 && e->Lface == NULL && e->Rface == NULL );