Salome HOME
23507: Nodes can't be projected to a CAD
authoreap <eap@opencascade.com>
Mon, 20 Nov 2017 14:40:35 +0000 (17:40 +0300)
committereap <eap@opencascade.com>
Mon, 20 Nov 2017 14:40:35 +0000 (17:40 +0300)
do not use a previous solution as a last resort

src/FrontTrack/FrontTrack_NodesOnGeom.cxx
src/FrontTrack/FrontTrack_Projector.cxx
src/FrontTrack/FrontTrack_Projector.hxx

index ed385fd908828fcbae3577dfe456166654fa4a7a..911358d5519401aa16178d1ae7570ced04dd95fa 100755 (executable)
@@ -293,7 +293,7 @@ void FT_NodesOnGeom::projectAndMove()
       gp_Pnt       xyz1 = getPoint( nn._neighborNodes[0] );
       gp_Pnt       xyz2 = getPoint( nn._neighborNodes[1] );
 
-// maxDist2 : le quart du carré de la distance entre les deux voisins du noued à bouger
+      // maxDist2 : le quart du carré de la distance entre les deux voisins du noued à bouger
       double   maxDist2 = xyz1.SquareDistance( xyz2 ) / 4.;
       if ( _projectors[ 0 ].project( xyz, maxDist2, newXyz,
                                      nn._params, nn._nearParams ))
@@ -326,6 +326,7 @@ void FT_NodesOnGeom::projectAndMove()
       for ( iP = 0; iP < projectors.size(); ++iP )
       {
         projectors[ iProjector ].prepareForProjection();
+        projectors[ iProjector ].tryWithoutPrevSolution( true );
 
         if (( ok = projectors[ iProjector ].isOnShape( xyz1, tol2, nn._params, nn._nearParams )) &&
             ( ok = projectors[ iProjector ].isOnShape( xyz2, tol2, nn._params, nn._params )))
index 5a76d6cf8d182b3ba6ad893bc6fcd3a9ff3a11eb..b8e3667a130551824f34cffa69800585a5e8f99a 100755 (executable)
@@ -786,6 +786,9 @@ void FT_Projector::prepareForProjection()
       }
       break;
     }
+
+    if ( !_realProjector )
+      delete classifier;
   }
 }
 
@@ -859,7 +862,13 @@ bool FT_Projector::project( const gp_Pnt& point,
   _realProjector->_dist = 1e100;
   projection = _realProjector->project( point, newSolution, prevSolution );
 
-  return ( _realProjector->_dist * _realProjector->_dist < maxDist2 );
+  bool ok = ( _realProjector->_dist * _realProjector->_dist < maxDist2 );
+  if ( !ok && _tryWOPrevSolution && prevSolution )
+  {
+    projection = _realProjector->project( point, newSolution );
+    ok = ( _realProjector->_dist * _realProjector->_dist < maxDist2 );
+  }
+  return ok;
 }
 
 //================================================================================
@@ -889,8 +898,12 @@ bool FT_Projector::projectAndClassify( const gp_Pnt& point,
   if ( _bndBox.IsOut( point ) || !_realProjector )
     return false;
 
-  return _realProjector->projectAndClassify( point, maxDist2, projection,
-                                             newSolution, prevSolution );
+  bool ok = _realProjector->projectAndClassify( point, maxDist2, projection,
+                                                newSolution, prevSolution );
+  if ( !ok && _tryWOPrevSolution && prevSolution )
+    ok = _realProjector->projectAndClassify( point, maxDist2, projection, newSolution );
+
+  return ok;
 }
 
 //================================================================================
index f7b0aa766a04663e97e6f499dbde841b6119a6d2..7420eaa3870f21e2e89f028e7326e99d8f4ef973 100755 (executable)
@@ -40,6 +40,12 @@ public:
   // return true if projection is not needed
   bool isPlanarBoundary() const;
 
+
+  // switch a mode of usage of prevSolution.
+  // If projection fails, to try to project without usage of prevSolution.
+  // By default this mode is off
+  void tryWithoutPrevSolution( bool toTry ) { _tryWOPrevSolution = toTry; }
+
   // project a point to the boundary shape
   bool project( const gp_Pnt& point,
                 const double  maxDist2,
@@ -65,6 +71,7 @@ private:
   FT_RealProjector* _realProjector;
   Bnd_Box           _bndBox;
   TopoDS_Shape      _shape;
+  bool              _tryWOPrevSolution;
 };
 
 #endif