Salome HOME
Regeression of the Test Case 3D_submesh/A0
[modules/smesh.git] / src / SMESH / SMESH_HypoFilter.cxx
index dd99ac11a474597ad75afa3855eb4bc98b28c7d5..f60a122a965563f9229e1b341677100446950199 100644 (file)
@@ -27,7 +27,9 @@
 //
 #include "SMESH_HypoFilter.hxx"
 
+#include "SMESH_Gen.hxx"
 #include "SMESH_Hypothesis.hxx"
+#include "SMESH_MesherHelper.hxx"
 #include "SMESH_subMesh.hxx"
 
 #include <TopExp_Explorer.hxx>
@@ -115,7 +117,7 @@ bool SMESH_HypoFilter::InstancePredicate::IsOk(const SMESH_Hypothesis* aHyp,
 //=======================================================================
 
 bool SMESH_HypoFilter::IsAssignedToPredicate::IsOk(const SMESH_Hypothesis* aHyp,
-                                               const TopoDS_Shape&     aShape) const
+                                                   const TopoDS_Shape&     aShape) const
 {
   return ( !_mainShape.IsNull() && !aShape.IsNull() && _mainShape.IsSame( aShape ));
 }
@@ -128,14 +130,19 @@ bool SMESH_HypoFilter::IsAssignedToPredicate::IsOk(const SMESH_Hypothesis* aHyp,
 bool SMESH_HypoFilter::IsMoreLocalThanPredicate::IsOk(const SMESH_Hypothesis* aHyp,
                                                       const TopoDS_Shape&     aShape) const
 {
-  // issue 0020963
-  // if aShape is COMPOUND (i.e. most probably a GEOM group) then
-  // it is more local if it contains shapes of less dimension than _shapeType
-  if ( aShape.ShapeType() == TopAbs_COMPOUND )
-    for ( int moreLocalType = _shapeType+1; moreLocalType < int(TopAbs_SHAPE); ++moreLocalType )
-      if ( TopExp_Explorer( aShape, TopAbs_ShapeEnum(moreLocalType)).More())
-        return true;
-  return ( aShape.ShapeType() > _shapeType );
+  if ( SMESH_MesherHelper::IsSubShape( aShape, /*mainShape=*/_shape ))
+    return true;
+
+  if ( aShape.ShapeType() == TopAbs_COMPOUND && 
+       !SMESH_MesherHelper::IsSubShape( _shape, /*mainShape=*/aShape)) // issue 0020963
+  {
+    for ( int type = TopAbs_SOLID; type < TopAbs_SHAPE; ++type )
+      if ( aHyp->GetDim() == SMESH_Gen::GetShapeDim( TopAbs_ShapeEnum( type )))
+        for ( TopExp_Explorer exp( aShape, TopAbs_ShapeEnum( type )); exp.More(); exp.Next())
+          if ( SMESH_MesherHelper::IsSubShape( exp.Current(), /*mainShape=*/_shape ))
+            return true;
+  }
+  return false;
 }
 
 //=======================================================================