X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH%2FSMESH_HypoFilter.cxx;h=ceb7c6fb29f9f440f9518ad6f2bf7d9efb9afa91;hb=3f3beb8b958607b3ac214b8234b5ae5d99facc13;hp=d23f7cbe0825d0dadbe20d870dd2101a75016850;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070;p=modules%2Fsmesh.git diff --git a/src/SMESH/SMESH_HypoFilter.cxx b/src/SMESH/SMESH_HypoFilter.cxx index d23f7cbe0..ceb7c6fb2 100644 --- a/src/SMESH/SMESH_HypoFilter.cxx +++ b/src/SMESH/SMESH_HypoFilter.cxx @@ -1,34 +1,38 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2013 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 +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SMESH SMESH : implementaion of SMESH idl descriptions // File : SMESH_HypoFilter.cxx // Module : SMESH -// $Header$ // #include "SMESH_HypoFilter.hxx" +#include "SMESH_Gen.hxx" #include "SMESH_Hypothesis.hxx" +#include "SMESH_MesherHelper.hxx" #include "SMESH_subMesh.hxx" +#include + using namespace std; @@ -112,11 +116,39 @@ 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 )); } +//================================================================================ +/*! + * \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 : @@ -125,7 +157,26 @@ bool SMESH_HypoFilter::IsAssignedToPredicate::IsOk(const SMESH_Hypothesis* aHyp, bool SMESH_HypoFilter::IsMoreLocalThanPredicate::IsOk(const SMESH_Hypothesis* aHyp, const TopoDS_Shape& aShape) const { - return ( aShape.ShapeType() > _shapeType ); + if ( aShape.IsSame( _mesh.GetShapeToMesh() )) + return false; // aHyp is global + + 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; + } + + if ( _preferableShapes.Contains( aShape )) + return true; // issue 21559, Mesh_6 + + return false; } //======================================================================= @@ -142,9 +193,9 @@ SMESH_HypoFilter::SMESH_HypoFilter() //purpose : //======================================================================= -SMESH_HypoFilter::SMESH_HypoFilter( SMESH_HypoPredicate* aPredicate, bool notNagate ) +SMESH_HypoFilter::SMESH_HypoFilter( SMESH_HypoPredicate* aPredicate, bool notNegate ) { - add( notNagate ? AND : AND_NOT, aPredicate ); + add( notNegate ? AND : AND_NOT, aPredicate ); } //======================================================================= @@ -277,9 +328,10 @@ SMESH_HypoPredicate* SMESH_HypoFilter::IsApplicableTo(const TopoDS_Shape& theSha //purpose : //======================================================================= -SMESH_HypoPredicate* SMESH_HypoFilter::IsMoreLocalThan(const TopoDS_Shape& theShape) +SMESH_HypoPredicate* SMESH_HypoFilter::IsMoreLocalThan(const TopoDS_Shape& theShape, + const SMESH_Mesh& theMesh) { - return new IsMoreLocalThanPredicate( theShape ); + return new IsMoreLocalThanPredicate( theShape, theMesh ); } //======================================================================= @@ -324,14 +376,14 @@ bool SMESH_HypoFilter::IsOk (const SMESH_Hypothesis* aHyp, //purpose : //======================================================================= -SMESH_HypoFilter & SMESH_HypoFilter::Init ( SMESH_HypoPredicate* aPredicate, bool notNagate ) +SMESH_HypoFilter & SMESH_HypoFilter::Init ( SMESH_HypoPredicate* aPredicate, bool notNegate ) { list::const_iterator pred = myPredicates.begin(); for ( ; pred != myPredicates.end(); ++pred ) delete *pred; myPredicates.clear(); - add( notNagate ? AND : AND_NOT, aPredicate ); + add( notNegate ? AND : AND_NOT, aPredicate ); return *this; } @@ -346,3 +398,5 @@ SMESH_HypoFilter::~SMESH_HypoFilter() Init(0); } + +