X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_Import_1D.cxx;h=1aec701b4570ecd58a029b0fd36f99f1c46e884d;hb=0ad3621c84291620f4533e056354bcdc83f1407c;hp=e3d59a79c8e1fc3195d5319fe7b3da575481db24;hpb=6bc94c22113c7133067ebd33f85ccb437b3c3fe0;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_Import_1D.cxx b/src/StdMeshers/StdMeshers_Import_1D.cxx index e3d59a79c..1aec701b4 100644 --- a/src/StdMeshers/StdMeshers_Import_1D.cxx +++ b/src/StdMeshers/StdMeshers_Import_1D.cxx @@ -200,22 +200,37 @@ namespace // INTERNAL STUFF if ( getBox()->IsOut( point )) return false; + bool ok = false; + double dist2, param; + distance2 = Precision::Infinite(); + if ( isLeaf() ) { for ( size_t i = 0; i < _segments.size(); ++i ) if ( !_segments[i].IsOut( point ) && - _segments[i].IsOn( point, distance2, u )) - return true; + _segments[i].IsOn( point, dist2, param ) && + dist2 < distance2 ) + { + distance2 = dist2; + u = param; + ok = true; + } + return ok; } else { for (int i = 0; i < 8; i++) - if (((CurveProjector*) myChildren[i])->IsOnCurve( point, distance2, u )) - return true; + if (((CurveProjector*) myChildren[i])->IsOnCurve( point, dist2, param ) && + dist2 < distance2 ) + { + distance2 = dist2; + u = param; + ok = true; + } } - return false; + return ok; } - + //================================================================================ /*! * \brief Initialize @@ -233,13 +248,14 @@ namespace // INTERNAL STUFF _pLast = pl; _curve = curve; _length2 = pf.SquareDistance( pl ); + _line.SetLocation( pf ); + _line.SetDirection( gp_Vec( pf, pl )); _chord2 = Max( _line. SquareDistance( curve->Value( uf + 0.25 * ( ul - uf ))), Max( _line.SquareDistance( curve->Value( uf + 0.5 * ( ul - uf ))), _line.SquareDistance( curve->Value( uf + 0.75 * ( ul - uf ))))); + _chord2 *= ( 1.05 * 1.05 ); // +5% _chord2 = Max( tol, _chord2 ); _chord = Sqrt( _chord2 ); - _line.SetLocation( pf ); - _line.SetDirection( gp_Vec( pf, pl )); Bnd_Box bb; BndLib_Add3dCurve::Add( GeomAdaptor_Curve( curve, uf, ul ), tol, bb ); @@ -268,12 +284,12 @@ namespace // INTERNAL STUFF gp_Vec edge( _pFirst, _pLast ); gp_Vec n1p ( _pFirst, point ); u = ( edge * n1p ) / _length2; // param [0,1] on the edge - if ( u < 0 ) + if ( u < 0. ) { if ( _pFirst.SquareDistance( point ) > _chord2 ) return false; } - else if ( u > _chord ) + else if ( u > 1. ) { if ( _pLast.SquareDistance( point ) > _chord2 ) return false; @@ -419,6 +435,7 @@ namespace // INTERNAL STUFF case TopAbs_EDGE: if ( SMESH_Algo::isDegenerated( TopoDS::Edge( sm->GetSubShape() ))) continue; + // fall through case TopAbs_FACE: _subM.insert( sm ); if ( !sm->IsEmpty() ) @@ -677,14 +694,14 @@ namespace // INTERNAL STUFF if ( removeImport ) { - // treate removal of Import algo from subMesh + // treat removal of Import algo from subMesh removeSubmesh( subMesh, (_ListenerData*) data ); } else if ( modifHyp || ( SMESH_subMesh::CLEAN == event && SMESH_subMesh::COMPUTE_EVENT == eventType)) { - // treate modification of ImportSource hypothesis + // treat modification of ImportSource hypothesis clearSubmesh( subMesh, (_ListenerData*) data, /*all=*/false ); } else if ( SMESH_subMesh::CHECK_COMPUTE_STATE == event && @@ -704,7 +721,7 @@ namespace // INTERNAL STUFF d->_computedSubM.insert( *smIt); } } - // Clear _ImportData::_n2n if it's no more useful, i.e. when + // Clear _ImportData::_n2n if it isn't useful anymore, i.e. when // the event is not within mesh.Compute() if ( SMESH_subMesh::ALGO_EVENT == eventType ) clearN2N( subMesh->GetFather() );