本文整理汇总了C++中RegionBelow函数的典型用法代码示例。如果您正苦于以下问题:C++ RegionBelow函数的具体用法?C++ RegionBelow怎么用?C++ RegionBelow使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RegionBelow函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckForRightSplice
static int CheckForRightSplice( GLUtesselator *tess, ActiveRegion *regUp )
/*
* Check the upper and lower edge of "regUp", to make sure that the
* eUp->Org is above eLo, or eLo->Org is below eUp (depending on which
* origin is leftmost).
*
* The main purpose is to splice right-going edges with the same
* dest vertex and nearly identical slopes (ie. we can't distinguish
* the slopes numerically). However the splicing can also help us
* to recover from numerical errors. For example, suppose at one
* point we checked eUp and eLo, and decided that eUp->Org is barely
* above eLo. Then later, we split eLo into two edges (eg. from
* a splice operation like this one). This can change the result of
* our test so that now eUp->Org is incident to eLo, or barely below it.
* We must correct this condition to maintain the dictionary invariants.
*
* One possibility is to check these edges for intersection again
* (ie. CheckForIntersect). This is what we do if possible. However
* CheckForIntersect requires that tess->event lies between eUp and eLo,
* so that it has something to fall back on when the intersection
* calculation gives us an unusable answer. So, for those cases where
* we can't check for intersection, this routine fixes the problem
* by just splicing the offending vertex into the other edge.
* This is a guaranteed solution, no matter how degenerate things get.
* Basically this is a combinatorial solution to a numerical problem.
*/
{
ActiveRegion *regLo = RegionBelow(regUp);
GLUhalfEdge *eUp = regUp->eUp;
GLUhalfEdge *eLo = regLo->eUp;
if( VertLeq( eUp->Org, eLo->Org )) {
if( EdgeSign( eLo->Dst, eUp->Org, eLo->Org ) > 0 ) return FALSE;
/* eUp->Org appears to be below eLo */
if( ! VertEq( eUp->Org, eLo->Org )) {
/* Splice eUp->Org into eLo */
if ( __gl_meshSplitEdge( eLo->Sym ) == NULL) longjmp(tess->env,1);
if ( !__gl_meshSplice( eUp, eLo->Oprev ) ) longjmp(tess->env,1);
regUp->dirty = regLo->dirty = TRUE;
} else if( eUp->Org != eLo->Org ) {
/* merge the two vertices, discarding eUp->Org */
pqDelete( tess->pq, eUp->Org->pqHandle ); /* __gl_pqSortDelete */
SpliceMergeVertices( tess, eLo->Oprev, eUp );
}
} else {
if( EdgeSign( eUp->Dst, eLo->Org, eUp->Org ) < 0 ) return FALSE;
/* eLo->Org appears to be above eUp, so splice eLo->Org into eUp */
regUp->dirty = TRUE;
void* valid_ptr_check = RegionAbove(regUp);//->dirty
if ( valid_ptr_check ) {
RegionAbove(regUp)->dirty = TRUE;
}
if (__gl_meshSplitEdge( eUp->Sym ) == NULL) longjmp(tess->env,1);
if ( !__gl_meshSplice( eLo->Oprev, eUp ) ) longjmp(tess->env,1);
}
return TRUE;
}
示例2: ConnectLeftDegenerate
static void ConnectLeftDegenerate( TESStesselator *tess,
ActiveRegion *regUp, TESSvertex *vEvent )
/*
* The event vertex lies exacty on an already-processed edge or vertex.
* Adding the new vertex involves splicing it into the already-processed
* part of the mesh.
*/
{
TESShalfEdge *e, *eTopLeft, *eTopRight, *eLast;
ActiveRegion *reg;
e = regUp->eUp;
if( VertEq( e->Org, vEvent )) {
/* e->Org is an unprocessed vertex - just combine them, and wait
* for e->Org to be pulled from the queue
*/
assert( TOLERANCE_NONZERO );
SpliceMergeVertices( tess, e, vEvent->anEdge );
return;
}
if( ! VertEq( e->Dst, vEvent )) {
/* General case -- splice vEvent into edge e which passes through it */
if (tessMeshSplitEdge( tess->mesh, e->Sym ) == NULL) longjmp(tess->env,1);
if( regUp->fixUpperEdge ) {
/* This edge was fixable -- delete unused portion of original edge */
if ( !tessMeshDelete( tess->mesh, e->Onext ) ) longjmp(tess->env,1);
regUp->fixUpperEdge = FALSE;
}
if ( !tessMeshSplice( tess->mesh, vEvent->anEdge, e ) ) longjmp(tess->env,1);
SweepEvent( tess, vEvent ); /* recurse */
return;
}
/* vEvent coincides with e->Dst, which has already been processed.
* Splice in the additional right-going edges.
*/
assert( TOLERANCE_NONZERO );
regUp = TopRightRegion( regUp );
reg = RegionBelow( regUp );
eTopRight = reg->eUp->Sym;
eTopLeft = eLast = eTopRight->Onext;
if( reg->fixUpperEdge ) {
/* Here e->Dst has only a single fixable edge going right.
* We can delete it since now we have some real right-going edges.
*/
assert( eTopLeft != eTopRight ); /* there are some left edges too */
DeleteRegion( tess, reg );
if ( !tessMeshDelete( tess->mesh, eTopRight ) ) longjmp(tess->env,1);
eTopRight = eTopLeft->Oprev;
}
if ( !tessMeshSplice( tess->mesh, vEvent->anEdge, eTopRight ) ) longjmp(tess->env,1);
if( ! EdgeGoesLeft( eTopLeft )) {
/* e->Dst had no left-going edges -- indicate this to AddRightEdges() */
eTopLeft = NULL;
}
AddRightEdges( tess, regUp, eTopRight->Onext, eLast, eTopLeft, TRUE );
}
示例3: while
static TESShalfEdge *FinishLeftRegions( TESStesselator *tess,
ActiveRegion *regFirst, ActiveRegion *regLast )
/*
* We are given a vertex with one or more left-going edges. All affected
* edges should be in the edge dictionary. Starting at regFirst->eUp,
* we walk down deleting all regions where both edges have the same
* origin vOrg. At the same time we copy the "inside" flag from the
* active region to the face, since at this point each face will belong
* to at most one region (this was not necessarily true until this point
* in the sweep). The walk stops at the region above regLast; if regLast
* is NULL we walk as far as possible. At the same time we relink the
* mesh if necessary, so that the ordering of edges around vOrg is the
* same as in the dictionary.
*/
{
ActiveRegion *reg, *regPrev;
TESShalfEdge *e, *ePrev;
regPrev = regFirst;
ePrev = regFirst->eUp;
while( regPrev != regLast ) {
regPrev->fixUpperEdge = FALSE; /* placement was OK */
reg = RegionBelow( regPrev );
e = reg->eUp;
if( e->Org != ePrev->Org ) {
if( ! reg->fixUpperEdge ) {
/* Remove the last left-going edge. Even though there are no further
* edges in the dictionary with this origin, there may be further
* such edges in the mesh (if we are adding left edges to a vertex
* that has already been processed). Thus it is important to call
* FinishRegion rather than just DeleteRegion.
*/
FinishRegion( tess, regPrev );
break;
}
/* If the edge below was a temporary edge introduced by
* ConnectRightVertex, now is the time to fix it.
*/
e = tessMeshConnect( tess->mesh, ePrev->Lprev, e->Sym );
if (e == NULL) longjmp(tess->env,1);
if ( !FixUpperEdge( tess, reg, e ) ) longjmp(tess->env,1);
}
/* Relink edges so that ePrev->Onext == e */
if( ePrev->Onext != e ) {
if ( !tessMeshSplice( tess->mesh, e->Oprev, e ) ) longjmp(tess->env,1);
if ( !tessMeshSplice( tess->mesh, ePrev, e ) ) longjmp(tess->env,1);
}
FinishRegion( tess, regPrev ); /* may change reg->eUp */
ePrev = reg->eUp;
regPrev = reg;
}
return ePrev;
}
示例4: SweepEvent
static void SweepEvent( TESStesselator *tess, TESSvertex *vEvent )
/*
* Does everything necessary when the sweep line crosses a vertex.
* Updates the mesh and the edge dictionary.
*/
{
ActiveRegion *regUp, *reg;
TESShalfEdge *e, *eTopLeft, *eBottomLeft;
tess->event = vEvent; /* for access in EdgeLeq() */
DebugEvent( tess );
/* Check if this vertex is the right endpoint of an edge that is
* already in the dictionary. In this case we don't need to waste
* time searching for the location to insert new edges.
*/
e = vEvent->anEdge;
while( e->activeRegion == NULL ) {
e = e->Onext;
if( e == vEvent->anEdge ) {
/* All edges go right -- not incident to any processed edges */
ConnectLeftVertex( tess, vEvent );
return;
}
}
/* Processing consists of two phases: first we "finish" all the
* active regions where both the upper and lower edges terminate
* at vEvent (ie. vEvent is closing off these regions).
* We mark these faces "inside" or "outside" the polygon according
* to their winding number, and delete the edges from the dictionary.
* This takes care of all the left-going edges from vEvent.
*/
regUp = TopLeftRegion( tess, e->activeRegion );
if (regUp == NULL) longjmp(tess->env,1);
reg = RegionBelow( regUp );
eTopLeft = reg->eUp;
eBottomLeft = FinishLeftRegions( tess, reg, NULL );
/* Next we process all the right-going edges from vEvent. This
* involves adding the edges to the dictionary, and creating the
* associated "active regions" which record information about the
* regions between adjacent dictionary edges.
*/
if( eBottomLeft->Onext == eTopLeft ) {
/* No right-going edges -- add a temporary "fixable" edge */
ConnectRightVertex( tess, regUp, eBottomLeft );
} else {
AddRightEdges( tess, regUp, eBottomLeft->Onext, eTopLeft, eTopLeft, TRUE );
}
}
示例5: CheckForLeftSplice
static int CheckForLeftSplice( GLUtesselator *tess, ActiveRegion *regUp )
/*
* Check the upper and lower edge of "regUp", to make sure that the
* eUp->Dst is above eLo, or eLo->Dst is below eUp (depending on which
* destination is rightmost).
*
* Theoretically, this should always be true. However, splitting an edge
* into two pieces can change the results of previous tests. For example,
* suppose at one point we checked eUp and eLo, and decided that eUp->Dst
* is barely above eLo. Then later, we split eLo into two edges (eg. from
* a splice operation like this one). This can change the result of
* the test so that now eUp->Dst is incident to eLo, or barely below it.
* We must correct this condition to maintain the dictionary invariants
* (otherwise new edges might get inserted in the wrong place in the
* dictionary, and bad stuff will happen).
*
* We fix the problem by just splicing the offending vertex into the
* other edge.
*/
{
ActiveRegion *regLo = RegionBelow(regUp);
GLUhalfEdge *eUp = regUp->eUp;
GLUhalfEdge *eLo = regLo->eUp;
GLUhalfEdge *e;
assert( ! VertEq( eUp->Dst, eLo->Dst ));
if( VertLeq( eUp->Dst, eLo->Dst )) {
if( EdgeSign( eUp->Dst, eLo->Dst, eUp->Org ) < 0 ) return FALSE;
/* eLo->Dst is above eUp, so splice eLo->Dst into eUp */
if ( RegionAbove(regUp) ) {
RegionAbove(regUp)->dirty = TRUE;
}
regUp->dirty = TRUE;
e = __gl_meshSplitEdge( eUp );
if (e == NULL) longjmp(tess->env,1);
if ( !__gl_meshSplice( eLo->Sym, e ) ) longjmp(tess->env,1);
e->Lface->inside = regUp->inside;
} else {
if( EdgeSign( eLo->Dst, eUp->Dst, eLo->Org ) > 0 ) return FALSE;
/* eUp->Dst is below eLo, so splice eUp->Dst into eLo */
regUp->dirty = regLo->dirty = TRUE;
e = __gl_meshSplitEdge( eLo );
if (e == NULL) longjmp(tess->env,1);
if ( !__gl_meshSplice( eUp->Lnext, eLo->Sym ) ) longjmp(tess->env,1);
e->Rface->inside = regUp->inside;
}
return TRUE;
}
示例6: RegionAbove
static ActiveRegion *TopLeftRegion( TESStesselator *tess, ActiveRegion *reg )
{
TESSvertex *org = reg->eUp->Org;
TESShalfEdge *e;
/* Find the region above the uppermost edge with the same origin */
do {
reg = RegionAbove( reg );
} while( reg->eUp->Org == org );
/* If the edge above was a temporary edge introduced by ConnectRightVertex,
* now is the time to fix it.
*/
if( reg->fixUpperEdge ) {
e = tessMeshConnect( tess->mesh, RegionBelow(reg)->eUp->Sym, reg->eUp->Lnext );
if (e == NULL) return NULL;
if ( !FixUpperEdge( tess, reg, e ) ) return NULL;
reg = RegionAbove( reg );
}
return reg;
}
示例7: ConnectLeftVertex
static void ConnectLeftVertex( TESStesselator *tess, TESSvertex *vEvent )
/*
* Purpose: connect a "left" vertex (one where both edges go right)
* to the processed portion of the mesh. Let R be the active region
* containing vEvent, and let U and L be the upper and lower edge
* chains of R. There are two possibilities:
*
* - the normal case: split R into two regions, by connecting vEvent to
* the rightmost vertex of U or L lying to the left of the sweep line
*
* - the degenerate case: if vEvent is close enough to U or L, we
* merge vEvent into that edge chain. The subcases are:
* - merging with the rightmost vertex of U or L
* - merging with the active edge of U or L
* - merging with an already-processed portion of U or L
*/
{
ActiveRegion *regUp, *regLo, *reg;
TESShalfEdge *eUp, *eLo, *eNew;
ActiveRegion tmp;
/* assert( vEvent->anEdge->Onext->Onext == vEvent->anEdge ); */
/* Get a pointer to the active region containing vEvent */
tmp.eUp = vEvent->anEdge->Sym;
/* __GL_DICTLISTKEY */ /* tessDictListSearch */
regUp = (ActiveRegion *)dictKey( dictSearch( tess->dict, &tmp ));
regLo = RegionBelow( regUp );
if( !regLo ) {
// This may happen if the input polygon is coplanar.
return;
}
eUp = regUp->eUp;
eLo = regLo->eUp;
/* Try merging with U or L first */
if( EdgeSign( eUp->Dst, vEvent, eUp->Org ) == 0 ) {
ConnectLeftDegenerate( tess, regUp, vEvent );
return;
}
/* Connect vEvent to rightmost processed vertex of either chain.
* e->Dst is the vertex that we will connect to vEvent.
*/
reg = VertLeq( eLo->Dst, eUp->Dst ) ? regUp : regLo;
if( regUp->inside || reg->fixUpperEdge) {
if( reg == regUp ) {
eNew = tessMeshConnect( tess->mesh, vEvent->anEdge->Sym, eUp->Lnext );
if (eNew == NULL) longjmp(tess->env,1);
} else {
TESShalfEdge *tempHalfEdge= tessMeshConnect( tess->mesh, eLo->Dnext, vEvent->anEdge);
if (tempHalfEdge == NULL) longjmp(tess->env,1);
eNew = tempHalfEdge->Sym;
}
if( reg->fixUpperEdge ) {
if ( !FixUpperEdge( tess, reg, eNew ) ) longjmp(tess->env,1);
} else {
ComputeWinding( tess, AddRegionBelow( tess, regUp, eNew ));
}
SweepEvent( tess, vEvent );
} else {
/* The new vertex is in a region which does not belong to the polygon.
* We don''t need to connect this vertex to the rest of the mesh.
*/
AddRightEdges( tess, regUp, vEvent->anEdge, vEvent->anEdge, NULL, TRUE );
}
}
示例8: ConnectRightVertex
static void ConnectRightVertex( TESStesselator *tess, ActiveRegion *regUp,
TESShalfEdge *eBottomLeft )
/*
* Purpose: connect a "right" vertex vEvent (one where all edges go left)
* to the unprocessed portion of the mesh. Since there are no right-going
* edges, two regions (one above vEvent and one below) are being merged
* into one. "regUp" is the upper of these two regions.
*
* There are two reasons for doing this (adding a right-going edge):
* - if the two regions being merged are "inside", we must add an edge
* to keep them separated (the combined region would not be monotone).
* - in any case, we must leave some record of vEvent in the dictionary,
* so that we can merge vEvent with features that we have not seen yet.
* For example, maybe there is a vertical edge which passes just to
* the right of vEvent; we would like to splice vEvent into this edge.
*
* However, we don't want to connect vEvent to just any vertex. We don''t
* want the new edge to cross any other edges; otherwise we will create
* intersection vertices even when the input data had no self-intersections.
* (This is a bad thing; if the user's input data has no intersections,
* we don't want to generate any false intersections ourselves.)
*
* Our eventual goal is to connect vEvent to the leftmost unprocessed
* vertex of the combined region (the union of regUp and regLo).
* But because of unseen vertices with all right-going edges, and also
* new vertices which may be created by edge intersections, we don''t
* know where that leftmost unprocessed vertex is. In the meantime, we
* connect vEvent to the closest vertex of either chain, and mark the region
* as "fixUpperEdge". This flag says to delete and reconnect this edge
* to the next processed vertex on the boundary of the combined region.
* Quite possibly the vertex we connected to will turn out to be the
* closest one, in which case we won''t need to make any changes.
*/
{
TESShalfEdge *eNew;
TESShalfEdge *eTopLeft = eBottomLeft->Onext;
ActiveRegion *regLo = RegionBelow(regUp);
TESShalfEdge *eUp = regUp->eUp;
TESShalfEdge *eLo = regLo->eUp;
int degenerate = FALSE;
if( eUp->Dst != eLo->Dst ) {
(void) CheckForIntersect( tess, regUp );
}
/* Possible new degeneracies: upper or lower edge of regUp may pass
* through vEvent, or may coincide with new intersection vertex
*/
if( VertEq( eUp->Org, tess->event )) {
if ( !tessMeshSplice( tess->mesh, eTopLeft->Oprev, eUp ) ) longjmp(tess->env,1);
regUp = TopLeftRegion( tess, regUp );
if (regUp == NULL) longjmp(tess->env,1);
eTopLeft = RegionBelow( regUp )->eUp;
FinishLeftRegions( tess, RegionBelow(regUp), regLo );
degenerate = TRUE;
}
if( VertEq( eLo->Org, tess->event )) {
if ( !tessMeshSplice( tess->mesh, eBottomLeft, eLo->Oprev ) ) longjmp(tess->env,1);
eBottomLeft = FinishLeftRegions( tess, regLo, NULL );
degenerate = TRUE;
}
if( degenerate ) {
AddRightEdges( tess, regUp, eBottomLeft->Onext, eTopLeft, eTopLeft, TRUE );
return;
}
/* Non-degenerate situation -- need to add a temporary, fixable edge.
* Connect to the closer of eLo->Org, eUp->Org.
*/
if( VertLeq( eLo->Org, eUp->Org )) {
eNew = eLo->Oprev;
} else {
eNew = eUp;
}
eNew = tessMeshConnect( tess->mesh, eBottomLeft->Lprev, eNew );
if (eNew == NULL) longjmp(tess->env,1);
/* Prevent cleanup, otherwise eNew might disappear before we've even
* had a chance to mark it as a temporary edge.
*/
AddRightEdges( tess, regUp, eNew, eNew->Onext, eNew->Onext, FALSE );
eNew->Sym->activeRegion->fixUpperEdge = TRUE;
WalkDirtyRegions( tess, regUp );
}
示例9: WalkDirtyRegions
static void WalkDirtyRegions( TESStesselator *tess, ActiveRegion *regUp )
/*
* When the upper or lower edge of any region changes, the region is
* marked "dirty". This routine walks through all the dirty regions
* and makes sure that the dictionary invariants are satisfied
* (see the comments at the beginning of this file). Of course
* new dirty regions can be created as we make changes to restore
* the invariants.
*/
{
ActiveRegion *regLo = RegionBelow(regUp);
TESShalfEdge *eUp, *eLo;
for( ;; ) {
/* Find the lowest dirty region (we walk from the bottom up). */
while( regLo->dirty ) {
regUp = regLo;
regLo = RegionBelow(regLo);
}
if( ! regUp->dirty ) {
regLo = regUp;
regUp = RegionAbove( regUp );
if( regUp == NULL || ! regUp->dirty ) {
/* We've walked all the dirty regions */
return;
}
}
regUp->dirty = FALSE;
eUp = regUp->eUp;
eLo = regLo->eUp;
if( eUp->Dst != eLo->Dst ) {
/* Check that the edge ordering is obeyed at the Dst vertices. */
if( CheckForLeftSplice( tess, regUp )) {
/* If the upper or lower edge was marked fixUpperEdge, then
* we no longer need it (since these edges are needed only for
* vertices which otherwise have no right-going edges).
*/
if( regLo->fixUpperEdge ) {
DeleteRegion( tess, regLo );
if ( !tessMeshDelete( tess->mesh, eLo ) ) longjmp(tess->env,1);
regLo = RegionBelow( regUp );
eLo = regLo->eUp;
} else if( regUp->fixUpperEdge ) {
DeleteRegion( tess, regUp );
if ( !tessMeshDelete( tess->mesh, eUp ) ) longjmp(tess->env,1);
regUp = RegionAbove( regLo );
eUp = regUp->eUp;
}
}
}
if( eUp->Org != eLo->Org ) {
if( eUp->Dst != eLo->Dst
&& ! regUp->fixUpperEdge && ! regLo->fixUpperEdge
&& (eUp->Dst == tess->event || eLo->Dst == tess->event) )
{
/* When all else fails in CheckForIntersect(), it uses tess->event
* as the intersection location. To make this possible, it requires
* that tess->event lie between the upper and lower edges, and also
* that neither of these is marked fixUpperEdge (since in the worst
* case it might splice one of these edges into tess->event, and
* violate the invariant that fixable edges are the only right-going
* edge from their associated vertex).
*/
if( CheckForIntersect( tess, regUp )) {
/* WalkDirtyRegions() was called recursively; we're done */
return;
}
} else {
/* Even though we can't use CheckForIntersect(), the Org vertices
* may violate the dictionary edge ordering. Check and correct this.
*/
(void) CheckForRightSplice( tess, regUp );
}
}
if( eUp->Org == eLo->Org && eUp->Dst == eLo->Dst ) {
/* A degenerate loop consisting of only two edges -- delete it. */
AddWinding( eLo, eUp );
DeleteRegion( tess, regUp );
if ( !tessMeshDelete( tess->mesh, eUp ) ) longjmp(tess->env,1);
regUp = RegionAbove( regLo );
}
}
}
示例10: CheckForIntersect
static int CheckForIntersect( TESStesselator *tess, ActiveRegion *regUp )
/*
* Check the upper and lower edges of the given region to see if
* they intersect. If so, create the intersection and add it
* to the data structures.
*
* Returns TRUE if adding the new intersection resulted in a recursive
* call to AddRightEdges(); in this case all "dirty" regions have been
* checked for intersections, and possibly regUp has been deleted.
*/
{
ActiveRegion *regLo = RegionBelow(regUp);
TESShalfEdge *eUp = regUp->eUp;
TESShalfEdge *eLo = regLo->eUp;
TESSvertex *orgUp = eUp->Org;
TESSvertex *orgLo = eLo->Org;
TESSvertex *dstUp = eUp->Dst;
TESSvertex *dstLo = eLo->Dst;
TESSreal tMinUp, tMaxLo;
TESSvertex isect, *orgMin;
TESShalfEdge *e;
assert( ! VertEq( dstLo, dstUp ));
assert( EdgeSign( dstUp, tess->event, orgUp ) <= 0 );
assert( EdgeSign( dstLo, tess->event, orgLo ) >= 0 );
assert( orgUp != tess->event && orgLo != tess->event );
assert( ! regUp->fixUpperEdge && ! regLo->fixUpperEdge );
if( orgUp == orgLo ) return FALSE; /* right endpoints are the same */
tMinUp = MIN( orgUp->t, dstUp->t );
tMaxLo = MAX( orgLo->t, dstLo->t );
if( tMinUp > tMaxLo ) return FALSE; /* t ranges do not overlap */
if( VertLeq( orgUp, orgLo )) {
if( EdgeSign( dstLo, orgUp, orgLo ) > 0 ) return FALSE;
} else {
if( EdgeSign( dstUp, orgLo, orgUp ) < 0 ) return FALSE;
}
/* At this point the edges intersect, at least marginally */
DebugEvent( tess );
tesedgeIntersect( dstUp, orgUp, dstLo, orgLo, &isect );
/* The following properties are guaranteed: */
assert( MIN( orgUp->t, dstUp->t ) <= isect.t );
assert( isect.t <= MAX( orgLo->t, dstLo->t ));
assert( MIN( dstLo->s, dstUp->s ) <= isect.s );
assert( isect.s <= MAX( orgLo->s, orgUp->s ));
if( VertLeq( &isect, tess->event )) {
/* The intersection point lies slightly to the left of the sweep line,
* so move it until it''s slightly to the right of the sweep line.
* (If we had perfect numerical precision, this would never happen
* in the first place). The easiest and safest thing to do is
* replace the intersection by tess->event.
*/
isect.s = tess->event->s;
isect.t = tess->event->t;
}
/* Similarly, if the computed intersection lies to the right of the
* rightmost origin (which should rarely happen), it can cause
* unbelievable inefficiency on sufficiently degenerate inputs.
* (If you have the test program, try running test54.d with the
* "X zoom" option turned on).
*/
orgMin = VertLeq( orgUp, orgLo ) ? orgUp : orgLo;
if( VertLeq( orgMin, &isect )) {
isect.s = orgMin->s;
isect.t = orgMin->t;
}
if( VertEq( &isect, orgUp ) || VertEq( &isect, orgLo )) {
/* Easy case -- intersection at one of the right endpoints */
(void) CheckForRightSplice( tess, regUp );
return FALSE;
}
if( (! VertEq( dstUp, tess->event )
&& EdgeSign( dstUp, tess->event, &isect ) >= 0)
|| (! VertEq( dstLo, tess->event )
&& EdgeSign( dstLo, tess->event, &isect ) <= 0 ))
{
/* Very unusual -- the new upper or lower edge would pass on the
* wrong side of the sweep event, or through it. This can happen
* due to very small numerical errors in the intersection calculation.
*/
if( dstLo == tess->event ) {
/* Splice dstLo into eUp, and process the new region(s) */
if (tessMeshSplitEdge( tess->mesh, eUp->Sym ) == NULL) longjmp(tess->env,1);
if ( !tessMeshSplice( tess->mesh, eLo->Sym, eUp ) ) longjmp(tess->env,1);
regUp = TopLeftRegion( tess, regUp );
if (regUp == NULL) longjmp(tess->env,1);
eUp = RegionBelow(regUp)->eUp;
FinishLeftRegions( tess, RegionBelow(regUp), regLo );
AddRightEdges( tess, regUp, eUp->Oprev, eUp, eUp, TRUE );
return TRUE;
}
if( dstUp == tess->event ) {
/* Splice dstUp into eLo, and process the new region(s) */
//.........这里部分代码省略.........
示例11: AddRightEdges
static void AddRightEdges( TESStesselator *tess, ActiveRegion *regUp,
TESShalfEdge *eFirst, TESShalfEdge *eLast, TESShalfEdge *eTopLeft,
int cleanUp )
/*
* Purpose: insert right-going edges into the edge dictionary, and update
* winding numbers and mesh connectivity appropriately. All right-going
* edges share a common origin vOrg. Edges are inserted CCW starting at
* eFirst; the last edge inserted is eLast->Oprev. If vOrg has any
* left-going edges already processed, then eTopLeft must be the edge
* such that an imaginary upward vertical segment from vOrg would be
* contained between eTopLeft->Oprev and eTopLeft; otherwise eTopLeft
* should be NULL.
*/
{
ActiveRegion *reg, *regPrev;
TESShalfEdge *e, *ePrev;
int firstTime = TRUE;
/* Insert the new right-going edges in the dictionary */
e = eFirst;
do {
assert( VertLeq( e->Org, e->Dst ));
AddRegionBelow( tess, regUp, e->Sym );
e = e->Onext;
} while ( e != eLast );
/* Walk *all* right-going edges from e->Org, in the dictionary order,
* updating the winding numbers of each region, and re-linking the mesh
* edges to match the dictionary ordering (if necessary).
*/
if( eTopLeft == NULL ) {
eTopLeft = RegionBelow( regUp )->eUp->Rprev;
}
regPrev = regUp;
ePrev = eTopLeft;
for( ;; ) {
reg = RegionBelow( regPrev );
e = reg->eUp->Sym;
if( e->Org != ePrev->Org ) break;
if( e->Onext != ePrev ) {
/* Unlink e from its current position, and relink below ePrev */
if ( !tessMeshSplice( tess->mesh, e->Oprev, e ) ) longjmp(tess->env,1);
if ( !tessMeshSplice( tess->mesh, ePrev->Oprev, e ) ) longjmp(tess->env,1);
}
/* Compute the winding number and "inside" flag for the new regions */
reg->windingNumber = regPrev->windingNumber - e->winding;
reg->inside = IsWindingInside( tess, reg->windingNumber );
/* Check for two outgoing edges with same slope -- process these
* before any intersection tests (see example in tessComputeInterior).
*/
regPrev->dirty = TRUE;
if( ! firstTime && CheckForRightSplice( tess, regPrev )) {
AddWinding( e, ePrev );
DeleteRegion( tess, regPrev );
if ( !tessMeshDelete( tess->mesh, ePrev ) ) longjmp(tess->env,1);
}
firstTime = FALSE;
regPrev = reg;
ePrev = e;
}
regPrev->dirty = TRUE;
assert( regPrev->windingNumber - e->winding == reg->windingNumber );
if( cleanUp ) {
/* Check for intersections between newly adjacent edges. */
WalkDirtyRegions( tess, regPrev );
}
}