Skip to content

Commit d31b595

Browse files
thomasmhugent
thomas
authored andcommitted
5239_v1
1 parent 4e3738a commit d31b595

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

src/analysis/interpolation/DualEdgeTriangulation.cc

+22-22
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
295295
{
296296
toswap = index;
297297
index = mHalfEdge[mHalfEdge[mHalfEdge[index]->getNext()]->getDual()]->getNext();
298-
checkSwap( toswap );
298+
checkSwap( toswap , 0 );
299299
if ( toswap == cwedge )
300300
{
301301
break;
@@ -329,9 +329,9 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
329329
mHalfEdge.at( nextnextnumber )->setNext(( int )edge6 );
330330

331331
//check, if there are swaps necessary
332-
checkSwap( number );
333-
checkSwap( nextnumber );
334-
checkSwap( nextnextnumber );
332+
checkSwap( number , 0 );
333+
checkSwap( nextnumber , 0 );
334+
checkSwap( nextnextnumber , 0 );
335335
}
336336

337337
//the point is exactly on an existing edge (the number of the edge is stored in the variable 'mEdgeWithPoint'---------------
@@ -364,10 +364,10 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
364364
mHalfEdge[edgef]->setNext( nedge2 );
365365

366366
//swap edges if necessary
367-
checkSwap( edgec );
368-
checkSwap( edged );
369-
checkSwap( edgee );
370-
checkSwap( edgef );
367+
checkSwap( edgec , 0 );
368+
checkSwap( edged , 0 );
369+
checkSwap( edgee , 0 );
370+
checkSwap( edgef , 0 );
371371
}
372372

373373
else if ( number == -100 || number == -5 )//this means unknown problems or a numerical error occured in 'baseEdgeOfTriangle'
@@ -679,18 +679,17 @@ bool DualEdgeTriangulation::calcPoint( double x, double y, Point3D* result )
679679
}
680680
}
681681

682-
bool DualEdgeTriangulation::checkSwap( unsigned int edge )
682+
bool DualEdgeTriangulation::checkSwap( unsigned int edge, unsigned int recursivDeep )
683683
{
684684
if ( swapPossible( edge ) )
685685
{
686686
Point3D* pta = mPointVector[mHalfEdge[edge]->getPoint()];
687687
Point3D* ptb = mPointVector[mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint()];
688688
Point3D* ptc = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getNext()]->getNext()]->getPoint()];
689689
Point3D* ptd = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint()];
690-
691-
if ( MathUtils::inCircle( ptd, pta, ptb, ptc ) )//empty circle criterion violated
690+
if ( MathUtils::inCircle( ptd, pta, ptb, ptc ) && recursivDeep < 100 )//empty circle criterion violated
692691
{
693-
doSwap( edge );//swap the edge (recursiv)
692+
doSwap( edge , recursivDeep );//swap the edge (recursiv)
694693
return true;
695694
}
696695
}
@@ -715,7 +714,7 @@ void DualEdgeTriangulation::doOnlySwap( unsigned int edge )
715714
mHalfEdge[edge2]->setPoint( mHalfEdge[edge5]->getPoint() );
716715
}
717716

718-
void DualEdgeTriangulation::doSwap( unsigned int edge )
717+
void DualEdgeTriangulation::doSwap( unsigned int edge, unsigned int recursivDeep )
719718
{
720719
unsigned int edge1 = edge;
721720
unsigned int edge2 = mHalfEdge[edge]->getDual();
@@ -731,10 +730,11 @@ void DualEdgeTriangulation::doSwap( unsigned int edge )
731730
mHalfEdge[edge6]->setNext( edge3 );
732731
mHalfEdge[edge1]->setPoint( mHalfEdge[edge3]->getPoint() );//change the points to which edge1 and edge2 point
733732
mHalfEdge[edge2]->setPoint( mHalfEdge[edge5]->getPoint() );
734-
checkSwap( edge3 );
735-
checkSwap( edge6 );
736-
checkSwap( edge4 );
737-
checkSwap( edge5 );
733+
recursivDeep++;
734+
checkSwap( edge3 , recursivDeep );
735+
checkSwap( edge6 , recursivDeep );
736+
checkSwap( edge4 , recursivDeep );
737+
checkSwap( edge5 , recursivDeep );
738738
}
739739

740740
#if 0
@@ -1556,7 +1556,7 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )
15561556
//optimisation of the new edges
15571557
for ( iter = crossedEdges.begin(); iter != crossedEdges.end(); ++iter )
15581558
{
1559-
checkSwap(( *( iter ) ) );
1559+
checkSwap(( *( iter ) ) , 0 );
15601560
}
15611561

15621562
return leftPolygon.first();
@@ -3245,10 +3245,10 @@ int DualEdgeTriangulation::splitHalfEdge( int edge, float position )
32453245
mHalfEdge[mHalfEdge[edge3]->getNext()]->setNext( edge6 );
32463246

32473247
//test four times recursively for swaping
3248-
checkSwap( mHalfEdge[edge5]->getNext() );
3249-
checkSwap( mHalfEdge[edge2]->getNext() );
3250-
checkSwap( mHalfEdge[dualedge]->getNext() );
3251-
checkSwap( mHalfEdge[edge3]->getNext() );
3248+
checkSwap( mHalfEdge[edge5]->getNext() , 0 );
3249+
checkSwap( mHalfEdge[edge2]->getNext() , 0 );
3250+
checkSwap( mHalfEdge[dualedge]->getNext() , 0 );
3251+
checkSwap( mHalfEdge[edge3]->getNext() , 0 );
32523252

32533253
mDecorator->addPoint( new Point3D( p->getX(), p->getY(), 0 ) );//dirty hack to enforce update of decorators
32543254

src/analysis/interpolation/DualEdgeTriangulation.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
149149
/**returns the number of a HalfEdge from a triangle in which 'point' is in. If the number -10 is returned, this means, that 'point' is outside the convex hull. If -5 is returned, then numerical problems with the leftOfTest occured (and the value of the possible edge is stored in the variable 'mUnstableEdge'. -20 means, that the inserted point is exactly on an edge (the number is stored in the variable 'mEdgeWithPoint'). -25 means, that the point is already in the triangulation (the number of the point is stored in the member 'mTwiceInsPoint'. If -100 is returned, this means that something else went wrong*/
150150
int baseEdgeOfTriangle( Point3D* point );
151151
/**Checks, if 'edge' has to be swapped because of the empty circle criterion. If so, doSwap(...) is called.*/
152-
bool checkSwap( unsigned int edge );
152+
bool checkSwap( unsigned int edge, unsigned int recursivDeep );
153153
/**Swaps 'edge' and test recursively for other swaps (delaunay criterion)*/
154-
void doSwap( unsigned int edge );
154+
void doSwap( unsigned int edge, unsigned int recursivDeep );
155155
/**Swaps 'edge' and does no recursiv testing*/
156156
void doOnlySwap( unsigned int edge );
157157
/**Number of an edge which does not point to the virtual point. It continuously updated for a fast search*/

0 commit comments

Comments
 (0)