From ce4982ab11409dc58b00c7c89bac426ab11e2a64 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 17 Apr 2008 07:42:14 +0000 Subject: [PATCH] try to cope with invalid node params on edges --- src/SMESH/SMESH_Pattern.cxx | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/SMESH/SMESH_Pattern.cxx b/src/SMESH/SMESH_Pattern.cxx index 1ab83c71e..45a2831d9 100644 --- a/src/SMESH/SMESH_Pattern.cxx +++ b/src/SMESH/SMESH_Pattern.cxx @@ -32,13 +32,13 @@ using namespace std; #include #include #include +#include #include #include #include #include #include #include -//#include #include #include #include @@ -655,9 +655,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, TopoDS_Edge & edge = *elIt; list< TPoint* > & ePoints = getShapePoints( edge ); double f, l; - Handle(Geom2d_Curve) C2d; - if ( !theProject ) - C2d = BRep_Tool::CurveOnSurface( edge, face, f, l ); + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface( edge, face, f, l ); bool isForward = ( edge.Orientation() == TopAbs_FORWARD ); TopoDS_Shape v1 = TopExp::FirstVertex( edge, true ); // always FORWARD @@ -733,7 +731,30 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, const SMDS_EdgePosition* epos = static_cast(node->GetPosition().get()); double u = epos->GetUParameter(); - paramNodeMap.insert( TParamNodeMap::value_type( u, node )); + paramNodeMap.insert( make_pair( u, node )); + } + if ( paramNodeMap.size() != eSubMesh->NbNodes() ) { + // wrong U on edge, project + Extrema_ExtPC proj; + BRepAdaptor_Curve aCurve( edge ); + proj.Initialize( aCurve, f, l ); + paramNodeMap.clear(); + nIt = eSubMesh->GetNodes(); + for ( int iNode = 0; nIt->more(); ++iNode ) { + const SMDS_MeshNode* node = smdsNode( nIt->next() ); + proj.Perform( gp_Pnt( node->X(), node->Y(), node->Z())); + double u = 0; + if ( proj.IsDone() ) { + for ( int i = 1, nb = proj.NbExt(); i <= nb; ++i ) + if ( proj.IsMin( i )) { + u = proj.Point( i ).Parameter(); + break; + } + } else { + u = isForward ? iNode : eSubMesh->NbNodes() - iNode; + } + paramNodeMap.insert( make_pair( u, node )); + } } // put U in [0,1] so that the first key-point has U==0 double du = l - f; -- 2.30.2