Salome HOME
23076: [CEA 1499] Get in python all sub-shapes in error after Compute
[modules/smesh.git] / src / StdMeshers / StdMeshers_Hexa_3D.cxx
index d63ed2641651eb041a5019aa9992d957b28d85f3..1ad459448f597df5017c01702262aefa2abc70ff 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015  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
@@ -124,23 +124,17 @@ bool StdMeshers_Hexa_3D::CheckHypothesis
     return true;
   }
 
+  // only StdMeshers_ViscousLayers can be used
   aStatus = HYP_OK;
   for ( ; h != hyps.end(); ++h )
   {
-    string hypName = (*h)->GetName();
-    if ( find( _compatibleHypothesis.begin(),_compatibleHypothesis.end(),hypName )
-         != _compatibleHypothesis.end() )
-    {
-      _viscousLayersHyp = dynamic_cast< const StdMeshers_ViscousLayers*> ( *h );
-    }
-    else
-    {
-      aStatus = HYP_INCOMPATIBLE;
-    }
+    if ( !(_viscousLayersHyp = dynamic_cast< const StdMeshers_ViscousLayers*> ( *h )))
+      break;
   }
-
   if ( !_viscousLayersHyp )
     aStatus = HYP_INCOMPATIBLE;
+  else
+    error( _viscousLayersHyp->CheckHypothesis( aMesh, aShape, aStatus ));
 
   return aStatus == HYP_OK;
 }
@@ -371,8 +365,9 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh &         aMesh,
     for ( int i = 0; i < 6; ++i )
     {
       const TopoDS_Face& sideF = aCubeSide[i]._quad->face;
-      if ( !SMESH_MesherHelper::IsSameElemGeometry( meshDS->MeshElements( sideF ),
-                                                    SMDSGeom_QUADRANGLE,
+      const SMESHDS_SubMesh* smDS =
+        proxymesh ? proxymesh->GetSubMesh( sideF ) : meshDS->MeshElements( sideF );
+      if ( !SMESH_MesherHelper::IsSameElemGeometry( smDS, SMDSGeom_QUADRANGLE,
                                                     /*nullSubMeshRes=*/false ))
       {
         SMESH_ComputeErrorPtr err = ComputePentahedralMesh(aMesh, aShape, proxymesh.get());
@@ -752,16 +747,12 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper
 
 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;
+    int nbFoundShells = 0;
     TopExp_Explorer exp1( exp0.Current(), TopAbs_SHELL );
     for ( ; exp1.More(); exp1.Next(), ++nbFoundShells)
       if ( nbFoundShells == 2 ) break;
@@ -769,11 +760,11 @@ bool StdMeshers_Hexa_3D::IsApplicable( const TopoDS_Shape & aShape, bool toCheck
       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;
+    exp1.Init( exp0.Current(), TopAbs_FACE );
+    int nbEdges = SMESH_MesherHelper::Count( exp1.Current(), TopAbs_EDGE, /*ignoreSame=*/true );
+    bool ok = ( nbEdges > 3 );
+    if ( toCheckAll && !ok ) return false;
+    if ( !toCheckAll && ok ) return true;
   }
   return toCheckAll;
 };