Salome HOME
23179: EDF 11603 - Problem with extrusion when path is not well oriented
[modules/smesh.git] / src / StdMeshers / StdMeshers_CompositeHexa_3D.cxx
index f3b76232c4bf961d46ea3e5bba3aa0d2aeb836c2..7c9dca548a82d1b0f12bd63bec0590e07ca3ecf1 100644 (file)
@@ -379,11 +379,12 @@ namespace
     TopExp::MapShapes( shape, TopAbs_FACE, subFF );
 
     TopoDS_Vertex VV[2];
-    TopTools_MapOfShape subChecked;
+    TopTools_MapOfShape subChecked/*, ridgeEE*/;
     TopTools_MapIteratorOfMapOfShape vIt( cornerVV );
     for ( ; vIt.More(); vIt.Next() )
     {
       TopoDS_Shape V0 = vIt.Key();
+      // walk from one corner VERTEX to another along ridge EDGEs
       PShapeIteratorPtr riIt = SMESH_MesherHelper::GetAncestors( V0, mesh, TopAbs_EDGE );
       while ( const TopoDS_Shape* riE = riIt->next() )
       {
@@ -405,7 +406,7 @@ namespace
           {
             if ( E->IsSame( ridgeE ) || !subEE.Contains( *E ) || !subChecked.Add( *E ))
               continue;
-            // look for FACEs sharing E and ridgeE
+            // look for FACEs sharing both E and ridgeE
             PShapeIteratorPtr fIt = SMESH_MesherHelper::GetAncestors( *E, mesh, TopAbs_FACE );
             while ( const TopoDS_Shape* F = fIt->next() )
             {
@@ -422,12 +423,12 @@ namespace
               break;
             }
           }
-          // look for the next ridge EDGE
+          // look for the next ridge EDGE ending at V1
           if ( nextRidgeE.IsNull() )
           {
             eIt = SMESH_MesherHelper::GetAncestors( V1, mesh, TopAbs_EDGE );
             while ( const TopoDS_Shape* E = eIt->next() )
-              if ( !ridgeE.IsSame( *E ) && !internEE.Contains( *E ) )
+              if ( !ridgeE.IsSame( *E ) && !internEE.Contains( *E ) && subEE.Contains( *E ))
               {
                 nextRidgeE = *E;
                 break;
@@ -465,7 +466,7 @@ bool StdMeshers_CompositeHexa_3D::findBoxFaces( const TopoDS_Shape&    shape,
   TopTools_MapOfShape cornerVertices;
   getBlockCorners( mesh, shape, cornerVertices );
   if ( cornerVertices.Extent() != 8 )
-    return error( COMPERR_BAD_INPUT_MESH, "Can't find 8 corners of a block" );
+    return error( COMPERR_BAD_INPUT_MESH, "Can't find 8 corners of a block by 2D mesh" );
   TopTools_MapOfShape internalEdges;
   if ( !getInternalEdges( mesh, shape, cornerVertices, internalEdges ))
     return error( COMPERR_BAD_INPUT_MESH, "2D mesh is not suitable for i,j,k hexa meshing" );
@@ -1114,9 +1115,9 @@ bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh )
 
   // store the rest nodes row by row
 
-  const SMDS_MeshNode* dummy = mesh.GetMeshDS()->AddNode(0,0,0);
-  const SMDS_MeshElement* firstQuad = dummy; // most left face above the last row of found nodes
-  
+  TIDSortedElemSet emptySet, avoidSet;
+  const SMDS_MeshElement* firstQuad = 0; // most left face above the last row of found nodes
+
   int nbFoundNodes = myIndexer._xSize;
   while ( nbFoundNodes != myGrid.size() )
   {
@@ -1133,8 +1134,6 @@ bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh )
     //     o---o  o  o  o  o
     //n1down    n2down
     //
-    TIDSortedElemSet emptySet, avoidSet;
-    avoidSet.insert( firstQuad );
     firstQuad = SMESH_MeshAlgos::FindFaceInSet( n1down, n2down, emptySet, avoidSet);
     while ( firstQuad && !faceSubMesh->Contains( firstQuad )) {
       avoidSet.insert( firstQuad );
@@ -1181,8 +1180,8 @@ bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh )
       n1down = myGrid[ nbFoundNodes - myIndexer._xSize - 1 ];
       n1up   = n2up;
     }
+    avoidSet.clear(); avoidSet.insert( firstQuad );
   }
-  mesh.GetMeshDS()->RemoveNode(dummy);
   DumpGrid(); // debug
 
   return true;