]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
In IsMoreLocalThanPredicate, take priority of sub-mehses into account
authoreap <eap@opencascade.com>
Tue, 24 Apr 2012 10:56:47 +0000 (10:56 +0000)
committereap <eap@opencascade.com>
Tue, 24 Apr 2012 10:56:47 +0000 (10:56 +0000)
src/SMESH/SMESH_Gen.cxx
src/SMESH/SMESH_HypoFilter.cxx
src/SMESH/SMESH_HypoFilter.hxx

index 58c98844dfc21ae4cd9834636bf3899d35eddb6c..dae945eec5e6b328942f1f362a686f9df6e1184b 100644 (file)
@@ -304,7 +304,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh &          aMesh,
         SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
         filter
           .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
-          .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh.GetShapeToMesh() ));
+          .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh ));
 
         if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
           SMESH_Hypothesis::Hypothesis_Status status;
@@ -516,7 +516,7 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh &          aMesh,
         SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
         filter
           .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
-          .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh.GetShapeToMesh() ));
+          .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh ));
 
         if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
           SMESH_Hypothesis::Hypothesis_Status status;
index 7841d2675732c11812bb81a56012e241f88e2e63..5552964bbcffce76194533616607fc53fa0bab27 100644 (file)
@@ -121,6 +121,34 @@ bool SMESH_HypoFilter::IsAssignedToPredicate::IsOk(const SMESH_Hypothesis* aHyp,
   return ( !_mainShape.IsNull() && !aShape.IsNull() && _mainShape.IsSame( aShape ));
 }
 
+//================================================================================
+/*!
+ * \brief Finds shapes preferable over _shape due to sub-mesh order
+ */
+//================================================================================
+
+void SMESH_HypoFilter::IsMoreLocalThanPredicate::findPreferable()
+{
+  const int shapeID = _mesh.GetMeshDS()->ShapeToIndex( _shape );
+  const TListOfListOfInt& listOfShapeIDList = _mesh.GetMeshOrder();
+  TListOfListOfInt::const_iterator listsIt = listOfShapeIDList.begin();
+  for ( ; listsIt != listOfShapeIDList.end(); ++listsIt )
+  {
+    const TListOfInt& idList  = *listsIt;
+    TListOfInt::const_iterator idIt =
+      std::find( idList.begin(), idList.end(), shapeID );
+    if ( idIt != idList.end() && *idIt != idList.front() )
+    {
+      for ( ; idIt != idList.end(); --idIt )
+      {
+        const TopoDS_Shape& shape = _mesh.GetMeshDS()->IndexToShape( *idIt );
+        if ( !shape.IsNull())
+          _preferableShapes.Add( shape );
+      }
+    }
+  }
+}
+
 //=======================================================================
 //function : IsMoreLocalThanPredicate::IsOk
 //purpose  : 
@@ -129,7 +157,7 @@ bool SMESH_HypoFilter::IsAssignedToPredicate::IsOk(const SMESH_Hypothesis* aHyp,
 bool SMESH_HypoFilter::IsMoreLocalThanPredicate::IsOk(const SMESH_Hypothesis* aHyp,
                                                       const TopoDS_Shape&     aShape) const
 {
-  if ( aShape.IsSame( _shapeToMesh ))
+  if ( aShape.IsSame( _mesh.GetShapeToMesh() ))
     return false; // aHyp is global
 
   if ( SMESH_MesherHelper::IsSubShape( aShape, /*mainShape=*/_shape ))
@@ -144,6 +172,10 @@ bool SMESH_HypoFilter::IsMoreLocalThanPredicate::IsOk(const SMESH_Hypothesis* aH
           if ( SMESH_MesherHelper::IsSubShape( exp.Current(), /*mainShape=*/_shape ))
             return true;
   }
+
+  if ( _preferableShapes.Contains( aShape ))
+    return true; // issue 21559, Mesh_6
+
   return false;
 }
 
@@ -297,9 +329,9 @@ SMESH_HypoPredicate* SMESH_HypoFilter::IsApplicableTo(const TopoDS_Shape& theSha
 //=======================================================================
 
 SMESH_HypoPredicate* SMESH_HypoFilter::IsMoreLocalThan(const TopoDS_Shape& theShape,
-                                                       const TopoDS_Shape& theShapeToMesh)
+                                                       const SMESH_Mesh&   theMesh)
 {
-  return new IsMoreLocalThanPredicate( theShape, theShapeToMesh);
+  return new IsMoreLocalThanPredicate( theShape, theMesh );
 }
 
 //=======================================================================
index fca26d33f3b15a6e32934bb5714114663aa21a5e..b4ace7d2a2434ed538024baf67ac90d6ab67b083 100644 (file)
 #include <list>
 #include <string>
 #include <TopoDS_Shape.hxx>
+#include <TopTools_MapOfShape.hxx>
 
 class SMESH_HypoFilter;
 class SMESH_Hypothesis;
+class SMESH_Mesh;
 
 class SMESH_EXPORT SMESH_HypoPredicate {
  public:
@@ -73,7 +75,7 @@ class SMESH_EXPORT SMESH_HypoFilter: public SMESH_HypoPredicate
   static SMESH_HypoPredicate* Is(const SMESH_Hypothesis* theHypo);
   static SMESH_HypoPredicate* IsGlobal(const TopoDS_Shape& theMainShape);
   static SMESH_HypoPredicate* IsMoreLocalThan(const TopoDS_Shape& theShape,
-                                              const TopoDS_Shape& theShapeToMesh);
+                                              const SMESH_Mesh&   theMesh);
   static SMESH_HypoPredicate* HasName(const std::string & theName);
   static SMESH_HypoPredicate* HasDim(const int theDim);
   static SMESH_HypoPredicate* HasType(const int theHypType);
@@ -170,12 +172,15 @@ class SMESH_EXPORT SMESH_HypoFilter: public SMESH_HypoPredicate
   };
         
   struct IsMoreLocalThanPredicate : public SMESH_HypoPredicate {
-    TopoDS_Shape _shape, _shapeToMesh;
+    TopoDS_Shape        _shape;
+    const SMESH_Mesh&   _mesh;
+    TopTools_MapOfShape _preferableShapes;
     IsMoreLocalThanPredicate( const TopoDS_Shape& shape,
-                              const TopoDS_Shape& shapeToMesh )
-      :_shape(shape),_shapeToMesh(shapeToMesh){}
+                              const SMESH_Mesh&   mesh )
+      :_shape(shape),_mesh(mesh) { findPreferable(); }
     bool IsOk(const SMESH_Hypothesis* aHyp,
               const TopoDS_Shape&     aShape) const;
+    void findPreferable();
   };
         
   struct IsAuxiliaryPredicate : public SMESH_HypoPredicate {