+// Copyright (C) 2017-2019 CEA/DEN, EDF R&D
+//
+// 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)
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;
-
+
if ( prevSolution )
{
_dist = _projector.NextProject( prevSolution[0], _curve, P, _tol, proj, param );
else
{
_dist = _projector.Project( _curve, P, _tol, proj, param, false );
- proj = _curve.Value( param );
}
+#ifdef _DEBUG_
+ std::cout << ".. _dist : " << _dist << std::endl;
+#endif
+ proj = _curve.Value( param );
newSolution[0] = param;
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 );
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();
{
_realProjector = 0;
setBoundaryShape( shape );
+ _tryWOPrevSolution = false;
}
//================================================================================
_realProjector = 0;
_shape = other._shape;
_bndBox = other._bndBox;
+ _tryWOPrevSolution = false;
}
//================================================================================
}
break;
}
+
+ if ( !_realProjector )
+ delete classifier;
}
}
_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;
}
//================================================================================
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;
}
//================================================================================