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;
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;
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 :
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 ))
if ( SMESH_MesherHelper::IsSubShape( exp.Current(), /*mainShape=*/_shape ))
return true;
}
+
+ if ( _preferableShapes.Contains( aShape ))
+ return true; // issue 21559, Mesh_6
+
return false;
}
//=======================================================================
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 );
}
//=======================================================================
#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:
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);
};
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 {