From: eap Date: Tue, 24 Apr 2012 10:56:47 +0000 (+0000) Subject: In IsMoreLocalThanPredicate, take priority of sub-mehses into account X-Git-Tag: TRIPOLI_323~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1cae83f9430efb5ec1f8c212462eeb370182925d;p=modules%2Fsmesh.git In IsMoreLocalThanPredicate, take priority of sub-mehses into account --- diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 58c98844d..dae945eec 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -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; diff --git a/src/SMESH/SMESH_HypoFilter.cxx b/src/SMESH/SMESH_HypoFilter.cxx index 7841d2675..5552964bb 100644 --- a/src/SMESH/SMESH_HypoFilter.cxx +++ b/src/SMESH/SMESH_HypoFilter.cxx @@ -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 ); } //======================================================================= diff --git a/src/SMESH/SMESH_HypoFilter.hxx b/src/SMESH/SMESH_HypoFilter.hxx index fca26d33f..b4ace7d2a 100644 --- a/src/SMESH/SMESH_HypoFilter.hxx +++ b/src/SMESH/SMESH_HypoFilter.hxx @@ -36,9 +36,11 @@ #include #include #include +#include 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 {