]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
try to cope with invalid node params on edges
authoreap <eap@opencascade.com>
Thu, 17 Apr 2008 07:42:14 +0000 (07:42 +0000)
committereap <eap@opencascade.com>
Thu, 17 Apr 2008 07:42:14 +0000 (07:42 +0000)
src/SMESH/SMESH_Pattern.cxx

index 1ab83c71e927aa94cf2a3864683deeacdaeffa2d..45a2831d97ce9b1bcbe0c6d080c933600f8e0d7b 100644 (file)
@@ -32,13 +32,13 @@ using namespace std;
 #include <Bnd_Box.hxx>
 #include <Bnd_Box2d.hxx>
 #include <ElSLib.hxx>
+#include <Extrema_ExtPC.hxx>
 #include <Extrema_GenExtPS.hxx>
 #include <Extrema_POnSurf.hxx>
 #include <Geom2d_Curve.hxx>
 #include <GeomAdaptor_Surface.hxx>
 #include <Geom_Curve.hxx>
 #include <Geom_Surface.hxx>
-//#include <IntAna2d_AnaIntersection.hxx>
 #include <TopAbs_ShapeEnum.hxx>
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
@@ -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<const SMDS_EdgePosition*>(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;