Salome HOME
22364: EDF SMESH: Create Mesh dialog box improvement: hide inapplicable algorithms...
[modules/smesh.git] / src / StdMeshers / StdMeshers_Hexa_3D.cxx
index a0d205bd1f8036d74df69815c35514606a10671e..d63ed2641651eb041a5019aa9992d957b28d85f3 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  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
@@ -6,7 +6,7 @@
 // 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
 // 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.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -287,9 +287,9 @@ namespace
 //=============================================================================
 /*!
  * Generates hexahedron mesh on hexaedron like form using algorithm from
 //=============================================================================
 /*!
  * Generates hexahedron mesh on hexaedron like form using algorithm from
- * "Application de l'interpolation transfinie à la création de maillages
+ * "Application de l'interpolation transfinie � la cr�ation de maillages
  *  C0 ou G1 continus sur des triangles, quadrangles, tetraedres, pentaedres
  *  C0 ou G1 continus sur des triangles, quadrangles, tetraedres, pentaedres
- *  et hexaedres déformés."
+ *  et hexaedres d�form�s."
  * Alain PERONNET - 8 janvier 1999
  */
 //=============================================================================
  * Alain PERONNET - 8 janvier 1999
  */
 //=============================================================================
@@ -741,6 +741,43 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper
   return error( algo->GetComputeError());
 }
 
   return error( algo->GetComputeError());
 }
 
+//================================================================================
+/*!
+ * \brief Return true if the algorithm can mesh this shape
+ *  \param [in] aShape - shape to check
+ *  \param [in] toCheckAll - if true, this check returns OK if all shapes are OK,
+ *              else, returns OK if at least one shape is OK
+ */
+//================================================================================
+
+bool StdMeshers_Hexa_3D::IsApplicable( const TopoDS_Shape & aShape, bool toCheckAll )
+{
+  TopoDS_Vertex theVertex0, theVertex1;
+  TopTools_IndexedMapOfOrientedShape theShapeIDMap;
+  bool isCurShellApp;
+  int nbFoundShells = 0;
+  TopExp_Explorer exp0( aShape, TopAbs_SOLID );
+  if ( !exp0.More() ) return false;
+  for ( ; exp0.More(); exp0.Next() )
+  {
+    nbFoundShells = 0;
+    isCurShellApp = false;
+    TopExp_Explorer exp1( exp0.Current(), TopAbs_SHELL );
+    for ( ; exp1.More(); exp1.Next(), ++nbFoundShells)
+      if ( nbFoundShells == 2 ) break;
+    if ( nbFoundShells != 1 ) {
+      if ( toCheckAll ) return false;
+      continue;
+    }   
+    exp1.Init( exp0.Current(), TopAbs_SHELL );
+    const TopoDS_Shell& shell = TopoDS::Shell(exp1.Current());
+    isCurShellApp = SMESH_Block::FindBlockShapes(shell, theVertex0, theVertex1, theShapeIDMap );
+    if ( toCheckAll && !isCurShellApp ) return false;
+    if ( !toCheckAll && isCurShellApp ) return true;
+  }
+  return toCheckAll;
+};
+
 //=======================================================================
 //function : ComputePentahedralMesh
 //purpose  : 
 //=======================================================================
 //function : ComputePentahedralMesh
 //purpose  :