Salome HOME
0022106: EDF 2464 SMESH : Split quadrangles in 4 triangles
[modules/smesh.git] / src / StdMeshers / StdMeshers_Import_1D.cxx
index a856471205ed4d88875a67a60247e1ea1284c104..03b89eda3091c521bb96165c03850eb0128d821c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -521,7 +521,7 @@ namespace // INTERNAL STUFF
     TopExp::MapShapes( SMESH_Mesh::PseudoShape(), pseudoSubShapes );
 
     // index of pseudoSubShapes corresponding to srcMeshDS
-    int subIndex = srcMeshDS->GetPersistentId() % pseudoSubShapes.Extent();
+    int    subIndex = 1 + srcMeshDS->GetPersistentId() % pseudoSubShapes.Extent();
     int nbSubShapes = 1 + srcMeshDS->GetPersistentId() / pseudoSubShapes.Extent();
 
     // try to find already present shapeForSrcMesh
@@ -621,7 +621,7 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th
 {
   if ( !_sourceHyp ) return false;
 
-  const vector<SMESH_Group*>& srcGroups = _sourceHyp->GetGroups();
+  const vector<SMESH_Group*>& srcGroups = _sourceHyp->GetGroups(/*loaded=*/true);
   if ( srcGroups.empty() )
     return error("Invalid source groups");
 
@@ -693,9 +693,11 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th
         else
         {
           // find an existing vertex node
+          double checktol = max(1.E-10, 10*edgeTol*edgeTol);
           for ( vNIt = vertexNodes.begin(); vNIt != vertexNodes.end(); ++vNIt)
-            if ( vNIt->SquareDistance( *node ) < 10 * edgeTol * edgeTol)
+            if ( vNIt->SquareDistance( *node ) < checktol)
             {
+              //MESSAGE("SquareDistance " << vNIt->SquareDistance( *node ) << " checktol " << checktol);
               (*n2nIt).second = vNIt->_node;
               vertexNodes.erase( vNIt );
               break;
@@ -710,13 +712,17 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th
             SMDS_MeshNode* newNode = tgtMesh->AddNode( (*node)->X(), (*node)->Y(), (*node)->Z());
             n2nIt->second = newNode;
             tgtMesh->SetNodeOnEdge( newNode, shapeID, u );
+            //MESSAGE("u=" << u);
           }
         }
         if ( !(newNodes[i] = n2nIt->second ))
           break;
       }
       if ( !newNodes.back() )
+      {
+        //MESSAGE("not all nodes of edge lie on theShape");
         continue; // not all nodes of edge lie on theShape
+      }
 
       // make a new edge
       SMDS_MeshElement * newEdge;
@@ -724,6 +730,7 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th
         newEdge = tgtMesh->AddEdge( newNodes[0], newNodes[1], newNodes[2] );
       else
         newEdge = tgtMesh->AddEdge( newNodes[0], newNodes[1]);
+      //MESSAGE("add Edge");
       tgtMesh->SetMeshElementOnShape( newEdge, shapeID );
       e2e->insert( make_pair( edge, newEdge ));
     }
@@ -1037,7 +1044,7 @@ void StdMeshers_Import_1D::getMaps(const SMESH_Mesh* srcMesh,
   e2e = &iData->_e2e;
   if ( iData->_copyMeshSubM.empty() )
   {
-    n2n->clear();
+    // n2n->clear(); -- for sharing nodes on EDGEs
     e2e->clear();
   }
 }