Salome HOME
0020511: EDF 1101 SMESH : Add CGNS to Mesh Format Supported
[modules/smesh.git] / src / StdMeshers / StdMeshers_Hexa_3D.cxx
index 926dee1cc963eb5043b1e8071fe0179359389fa4..50306796ee89f258f122aa4882dd3afb81a04854 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  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
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 //  SMESH SMESH : implementaion of SMESH idl descriptions
@@ -388,7 +388,8 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh &         aMesh,
       const TopoDS_Edge& baseE = baseQuadSide->Edge( iE );
       eOri[ iE ] = baseE.Orientation();
 
-      // assure correctness of node positions on baseE
+      // assure correctness of node positions on baseE:
+      // helper.GetNodeU() will fix positions if they are wrong
       if ( SMESHDS_SubMesh* smDS = meshDS->MeshElements( baseE ))
       {
         bool ok;
@@ -422,6 +423,17 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh &         aMesh,
           append( aCubeSide[i]._u2nodesMap, u2nodesMap.rbegin(), u2nodesMap.rend());
       }
     }
+    // check if the loaded grid corresponds to nb of quadrangles
+    const SMESHDS_SubMesh* faceSubMesh =
+      proxymesh ? proxymesh->GetSubMesh( F ) : meshDS->MeshElements( F );
+    const int nbQuads = faceSubMesh->NbElements();
+    const int nbHor = aCubeSide[i]._u2nodesMap.size() - 1;
+    const int nbVer = aCubeSide[i]._u2nodesMap.begin()->second.size() - 1;
+    if ( nbQuads != nbHor * nbVer )
+    {
+      SMESH_ComputeErrorPtr err = ComputePentahedralMesh(aMesh, aShape, proxymesh.get());
+      return error( err );
+    }
   }
 
   // Orient loaded grids of cube sides along axis of the unitary cube coord system