X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFrontTrack%2FFrontTrack_Projector.cxx;h=450bab6a75cb1dbc1bb125d87b34d7f9dab1892c;hb=refs%2Ftags%2FV9_13_0b1;hp=5a76d6cf8d182b3ba6ad893bc6fcd3a9ff3a11eb;hpb=b5a5605be48d3c73f12421d9003e296c5759a8b8;p=modules%2Fhomard.git diff --git a/src/FrontTrack/FrontTrack_Projector.cxx b/src/FrontTrack/FrontTrack_Projector.cxx old mode 100755 new mode 100644 index 5a76d6cf..450bab6a --- a/src/FrontTrack/FrontTrack_Projector.cxx +++ b/src/FrontTrack/FrontTrack_Projector.cxx @@ -1,3 +1,21 @@ +// Copyright (C) 2017-2024 CEA, EDF +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// // File : FrontTrack_Projector.cxx // Created : Wed Apr 26 20:33:55 2017 // Author : Edward AGAPOV (eap) @@ -104,6 +122,9 @@ namespace // actual projection algorithms double* newSolution, const double* prevSolution = 0) { +#ifdef _DEBUG_ + std::cout << ".. project a point to the curve prevSolution = " << prevSolution << std::endl; +#endif gp_Pnt proj; Standard_Real param; @@ -115,6 +136,9 @@ namespace // actual projection algorithms { _dist = _projector.Project( _curve, P, _tol, proj, param, false ); } +#ifdef _DEBUG_ + std::cout << ".. _dist : " << _dist << std::endl; +#endif proj = _curve.Value( param ); newSolution[0] = param; @@ -130,6 +154,9 @@ namespace // actual projection algorithms double* newSolution, const double* prevSolution = 0) { +#ifdef _DEBUG_ + std::cout << ".. project a point to a curve and check " << std::endl; +#endif projection = project( point, newSolution, prevSolution ); return ( _uRange[0] < newSolution[0] && newSolution[0] < _uRange[1] && _dist * _dist < maxDist2 ); @@ -436,6 +463,7 @@ namespace // actual projection algorithms newSolution[0], newSolution[1]); projection = ElSLib::CylinderValue( newSolution[0], newSolution[1], _cylinder.Position(), _cylinder.Radius() ); + _dist = point.Distance( projection ); return ( _dist * _dist < maxDist2 ) && SurfaceProjector::classify( newSolution ); } @@ -611,7 +639,7 @@ namespace // actual projection algorithms bool isStraight( const GeomAdaptor_Curve& curve, const double tol ) { // rough check: evaluate how far from a straight line connecting the curve ends - // stand several internal points of the curve + // stand several internal points of the curve const double f = curve.FirstParameter(); const double l = curve.LastParameter(); @@ -649,6 +677,7 @@ FT_Projector::FT_Projector(const TopoDS_Shape& shape) { _realProjector = 0; setBoundaryShape( shape ); + _tryWOPrevSolution = false; } //================================================================================ @@ -662,6 +691,7 @@ FT_Projector::FT_Projector(const FT_Projector& other) _realProjector = 0; _shape = other._shape; _bndBox = other._bndBox; + _tryWOPrevSolution = false; } //================================================================================ @@ -786,6 +816,9 @@ void FT_Projector::prepareForProjection() } break; } + + if ( !_realProjector ) + delete classifier; } } @@ -859,7 +892,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 +928,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; } //================================================================================