Salome HOME
In MergeNodes():
[modules/smesh.git] / src / StdMeshers / StdMeshers_Hexa_3D.cxx
index 4ed44a20fe4dc23953d8e855d82620df8082e899..cc33934e1f1be4ac8f04a99dae5c14069a19d76c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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
 #include "SMESH_MesherHelper.hxx"
 #include "SMESH_subMesh.hxx"
 
-#include "SMDS_MeshElement.hxx"
 #include "SMDS_MeshNode.hxx"
-#include "SMDS_FacePosition.hxx"
-#include "SMDS_VolumeTool.hxx"
-#include "SMDS_VolumeOfNodes.hxx"
 
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
-#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopTools_ListOfShape.hxx>
 #include <TopTools_SequenceOfShape.hxx>
 #include <TopTools_MapOfShape.hxx>
 #include <TopoDS.hxx>
-#include <gp_Pnt2d.hxx>
 
 #include "utilities.h"
 #include "Utils_ExceptHandlers.hxx"
@@ -269,13 +261,26 @@ namespace
    */
   //================================================================================
 
-  bool beginsAtSide( const _FaceGrid& sideGrid1, const _FaceGrid& sideGrid2 )
+  bool beginsAtSide( const _FaceGrid&     sideGrid1,
+                     const _FaceGrid&     sideGrid2,
+                     SMESH_ProxyMesh::Ptr proxymesh )
   {
-    const SMDS_MeshNode* n00 = (sideGrid1._u2nodesMap.begin()->second)[0];
     const TNodeColumn& col0  = sideGrid2._u2nodesMap.begin()->second;
     const TNodeColumn& col1  = sideGrid2._u2nodesMap.rbegin()->second;
-    return ( n00 == col0.front() || n00 == col0.back() ||
-             n00 == col1.front() || n00 == col1.back() );
+    const SMDS_MeshNode* n00 = col0.front();
+    const SMDS_MeshNode* n01 = col0.back();
+    const SMDS_MeshNode* n10 = col1.front();
+    const SMDS_MeshNode* n11 = col1.back();
+    const SMDS_MeshNode* n = (sideGrid1._u2nodesMap.begin()->second)[0];
+    if ( proxymesh )
+    {
+      n00 = proxymesh->GetProxyNode( n00 );
+      n10 = proxymesh->GetProxyNode( n10 );
+      n01 = proxymesh->GetProxyNode( n01 );
+      n11 = proxymesh->GetProxyNode( n11 );
+      n   = proxymesh->GetProxyNode( n );
+    }
+    return ( n == n00 || n == n01 || n == n10 || n == n11 );
   }
 }
 
@@ -290,7 +295,7 @@ namespace
 //=============================================================================
 
 bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh &         aMesh,
-                                 const TopoDS_Shape & aShape)// throw(SALOME_Exception)
+                                 const TopoDS_Shape & aShape)
 {
   // PAL14921. Enable catching std::bad_alloc and Standard_OutOfMemory outside
   //Unexpect aCatch(SalomeException);
@@ -366,20 +371,12 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh &         aMesh,
     for ( int i = 0; i < 6; ++i )
     {
       const TopoDS_Face& sideF = aCubeSide[i]._quad->face;
-      if ( SMESHDS_SubMesh* smDS = meshDS->MeshElements( sideF ))
+      if ( !SMESH_MesherHelper::IsSameElemGeometry( meshDS->MeshElements( sideF ),
+                                                    SMDSGeom_QUADRANGLE,
+                                                    /*nullSubMeshRes=*/false ))
       {
-        bool isAllQuad = true;
-        SMDS_ElemIteratorPtr fIt = smDS->GetElements();
-        while ( fIt->more() && isAllQuad )
-        {
-          const SMDS_MeshElement* f = fIt->next();
-          isAllQuad = ( f->NbCornerNodes() == 4 );
-        }
-        if ( !isAllQuad )
-        {
-          SMESH_ComputeErrorPtr err = ComputePentahedralMesh(aMesh, aShape, proxymesh.get());
-          return error( err );
-        }
+        SMESH_ComputeErrorPtr err = ComputePentahedralMesh(aMesh, aShape, proxymesh.get());
+        return error( err );
       }
     }
   }
@@ -399,6 +396,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh &         aMesh,
 
     // assure correctness of node positions on baseE:
     // helper.GetNodeU() will fix positions if they are wrong
+    helper.ToFixNodeParameters( true );
     for ( int iE = 0; iE < baseQuadSide->NbEdges(); ++iE )
     {
       const TopoDS_Edge& baseE = baseQuadSide->Edge( iE );
@@ -441,12 +439,12 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh &         aMesh,
 
   // Orient loaded grids of cube sides along axis of the unitary cube coord system
   bool isReverse[6];
-  isReverse[B_BOTTOM] = beginsAtSide( aCubeSide[B_BOTTOM], aCubeSide[B_RIGHT ] );
-  isReverse[B_TOP   ] = beginsAtSide( aCubeSide[B_TOP   ], aCubeSide[B_RIGHT ] );
-  isReverse[B_FRONT ] = beginsAtSide( aCubeSide[B_FRONT ], aCubeSide[B_RIGHT ] );
-  isReverse[B_BACK  ] = beginsAtSide( aCubeSide[B_BACK  ], aCubeSide[B_RIGHT ] );
-  isReverse[B_LEFT  ] = beginsAtSide( aCubeSide[B_LEFT  ], aCubeSide[B_BACK  ] );
-  isReverse[B_RIGHT ] = beginsAtSide( aCubeSide[B_RIGHT ], aCubeSide[B_BACK  ] );
+  isReverse[B_BOTTOM] = beginsAtSide( aCubeSide[B_BOTTOM], aCubeSide[B_RIGHT ], proxymesh );
+  isReverse[B_TOP   ] = beginsAtSide( aCubeSide[B_TOP   ], aCubeSide[B_RIGHT ], proxymesh );
+  isReverse[B_FRONT ] = beginsAtSide( aCubeSide[B_FRONT ], aCubeSide[B_RIGHT ], proxymesh );
+  isReverse[B_BACK  ] = beginsAtSide( aCubeSide[B_BACK  ], aCubeSide[B_RIGHT ], proxymesh );
+  isReverse[B_LEFT  ] = beginsAtSide( aCubeSide[B_LEFT  ], aCubeSide[B_BACK  ], proxymesh );
+  isReverse[B_RIGHT ] = beginsAtSide( aCubeSide[B_RIGHT ], aCubeSide[B_BACK  ], proxymesh );
   for ( int i = 0; i < 6; ++i )
   {
     aCubeSide[i]._columns.resize( aCubeSide[i]._u2nodesMap.size() );