From: eap Date: Mon, 20 Nov 2017 14:40:35 +0000 (+0300) Subject: 23507: Nodes can't be projected to a CAD X-Git-Tag: V9_0_0~2^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=665075d1a5c46bdc86a8f8fa0c635fecc8d944a6;p=modules%2Fhomard.git 23507: Nodes can't be projected to a CAD do not use a previous solution as a last resort --- diff --git a/src/FrontTrack/FrontTrack_NodesOnGeom.cxx b/src/FrontTrack/FrontTrack_NodesOnGeom.cxx index ed385fd9..911358d5 100755 --- a/src/FrontTrack/FrontTrack_NodesOnGeom.cxx +++ b/src/FrontTrack/FrontTrack_NodesOnGeom.cxx @@ -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 ))) diff --git a/src/FrontTrack/FrontTrack_Projector.cxx b/src/FrontTrack/FrontTrack_Projector.cxx index 5a76d6cf..b8e3667a 100755 --- a/src/FrontTrack/FrontTrack_Projector.cxx +++ b/src/FrontTrack/FrontTrack_Projector.cxx @@ -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; } //================================================================================ diff --git a/src/FrontTrack/FrontTrack_Projector.hxx b/src/FrontTrack/FrontTrack_Projector.hxx index f7b0aa76..7420eaa3 100755 --- a/src/FrontTrack/FrontTrack_Projector.hxx +++ b/src/FrontTrack/FrontTrack_Projector.hxx @@ -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