0001-5239_v1.patch

Thomas Arnold, 2012-06-01 12:15 AM

Download (6.54 KB)

View differences:

src/analysis/interpolation/DualEdgeTriangulation.cc
295 295
        {
296 296
          toswap = index;
297 297
          index = mHalfEdge[mHalfEdge[mHalfEdge[index]->getNext()]->getDual()]->getNext();
298
          checkSwap( toswap );
298
          checkSwap( toswap , 0 );
299 299
          if ( toswap == cwedge )
300 300
          {
301 301
            break;
......
329 329
        mHalfEdge.at( nextnextnumber )->setNext(( int )edge6 );
330 330

  
331 331
        //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 );
335 335
      }
336 336

  
337 337
      //the point is exactly on an existing edge (the number of the edge is stored in the variable 'mEdgeWithPoint'---------------
......
364 364
        mHalfEdge[edgef]->setNext( nedge2 );
365 365

  
366 366
        //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 );
371 371
      }
372 372

  
373 373
      else if ( number == -100 || number == -5 )//this means unknown problems or a numerical error occured in 'baseEdgeOfTriangle'
......
680 680
  }
681 681
}
682 682

  
683
bool DualEdgeTriangulation::checkSwap( unsigned int edge )
683
bool DualEdgeTriangulation::checkSwap( unsigned int edge, unsigned int recursivDeep )
684 684
{
685 685
  if ( swapPossible( edge ) )
686 686
  {
......
688 688
    Point3D* ptb = mPointVector[mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint()];
689 689
    Point3D* ptc = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getNext()]->getNext()]->getPoint()];
690 690
    Point3D* ptd = mPointVector[mHalfEdge[mHalfEdge[mHalfEdge[edge]->getDual()]->getNext()]->getPoint()];
691

  
692
    if ( MathUtils::inCircle( ptd, pta, ptb, ptc ) )//empty circle criterion violated
691
    if ( MathUtils::inCircle( ptd, pta, ptb, ptc ) && recursivDeep < 100 )//empty circle criterion violated
693 692
    {
694
      doSwap( edge );//swap the edge (recursiv)
693
      doSwap( edge , recursivDeep );//swap the edge (recursiv)
695 694
      return true;
696 695
    }
697 696
  }
......
716 715
  mHalfEdge[edge2]->setPoint( mHalfEdge[edge5]->getPoint() );
717 716
}
718 717

  
719
void DualEdgeTriangulation::doSwap( unsigned int edge )
718
void DualEdgeTriangulation::doSwap( unsigned int edge, unsigned int recursivDeep )
720 719
{
721 720
  unsigned int edge1 = edge;
722 721
  unsigned int edge2 = mHalfEdge[edge]->getDual();
......
732 731
  mHalfEdge[edge6]->setNext( edge3 );
733 732
  mHalfEdge[edge1]->setPoint( mHalfEdge[edge3]->getPoint() );//change the points to which edge1 and edge2 point
734 733
  mHalfEdge[edge2]->setPoint( mHalfEdge[edge5]->getPoint() );
735
  checkSwap( edge3 );
736
  checkSwap( edge6 );
737
  checkSwap( edge4 );
738
  checkSwap( edge5 );
734
  recursivDeep++;
735
  checkSwap( edge3 , recursivDeep );
736
  checkSwap( edge6 , recursivDeep );
737
  checkSwap( edge4 , recursivDeep );
738
  checkSwap( edge5 , recursivDeep );
739 739
}
740 740

  
741 741
#if 0
......
1557 1557
  //optimisation of the new edges
1558 1558
  for ( iter = crossedEdges.begin(); iter != crossedEdges.end(); ++iter )
1559 1559
  {
1560
    checkSwap(( *( iter ) ) );
1560
    checkSwap(( *( iter ) ) , 0 );
1561 1561
  }
1562 1562

  
1563 1563
  return leftPolygon.first();
......
3245 3245
  mHalfEdge[mHalfEdge[edge3]->getNext()]->setNext( edge6 );
3246 3246

  
3247 3247
  //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 );
3252 3252

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

  
src/analysis/interpolation/DualEdgeTriangulation.h
148 148
    /**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*/
149 149
    int baseEdgeOfTriangle( Point3D* point );
150 150
    /**Checks, if 'edge' has to be swapped because of the empty circle criterion. If so, doSwap(...) is called.*/
151
    bool checkSwap( unsigned int edge );
151
    bool checkSwap( unsigned int edge, unsigned int recursivDeep );
152 152
    /**Swaps 'edge' and test recursively for other swaps (delaunay criterion)*/
153
    void doSwap( unsigned int edge );
153
    void doSwap( unsigned int edge, unsigned int recursivDeep );
154 154
    /**Swaps 'edge' and does no recursiv testing*/
155 155
    void doOnlySwap( unsigned int edge );
156 156
    /**Number of an edge which does not point to the virtual point. It continuously updated for a fast search*/
157
-