52457: Addition of hypotheses is 8 time longer than meshing.

More optimization
This commit is contained in:
eap 2014-07-23 20:04:21 +04:00
parent 80a2161a03
commit f1013bf724
9 changed files with 630 additions and 529 deletions

File diff suppressed because it is too large Load Diff

View File

@ -774,7 +774,7 @@ protected:
bool registerElement(int ID, SMDS_MeshElement * element);
void addChildrenWithNodes(std::set<const SMDS_MeshElement*>& setOfChildren,
const SMDS_MeshElement * element,
const SMDS_MeshElement * element,
std::set<const SMDS_MeshElement*>& nodes);
inline void adjustmyCellsCapacity(int ID)
@ -818,8 +818,8 @@ protected:
//! SMDS_MeshCells refer to vtk cells (vtk id != index in myCells),store reference to this mesh, and sub-shape
SetOfCells myCells;
//! for cells only: index = ID for SMDS users, value = ID in vtkUnstructuredGrid
//std::vector<int> myCellIdSmdsToVtk;
//! a buffer to speed up elements addition by excluding some memory allocation
std::vector<vtkIdType> myNodeIds;
//! for cells only: index = ID in vtkUnstructuredGrid, value = ID for SMDS users
std::vector<int> myCellIdVtkToSmds;

View File

@ -232,7 +232,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
if ( aShapesId && aShapeDim > (int)aDim )
continue;
SMESH_Algo* algo = GetAlgo( aMesh, aSubShape, &algoShape );
SMESH_Algo* algo = GetAlgo( smToCompute, &algoShape );
if ( algo && !algo->NeedDiscreteBoundary() )
{
if ( algo->SupportSubmeshes() )
@ -308,7 +308,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
sm = smVec[i];
// get a shape the algo is assigned to
if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape ))
if ( !GetAlgo( sm, & algoShape ))
continue; // strange...
// look for more local algos
@ -331,7 +331,8 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
.And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
.And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh ));
if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( smToCompute, filter, true))
{
if ( ! subAlgo->NeedDiscreteBoundary() ) continue;
SMESH_Hypothesis::Hypothesis_Status status;
if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
@ -477,7 +478,7 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh,
const int aShapeDim = GetShapeDim( aSubShape );
if ( aShapeDim < 1 ) break;
SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
SMESH_Algo* algo = GetAlgo( smToCompute );
if ( algo && !algo->NeedDiscreteBoundary() ) {
if ( algo->SupportSubmeshes() ) {
smWithAlgoSupportingSubmeshes.push_front( smToCompute );
@ -508,7 +509,7 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh,
// get a shape the algo is assigned to
TopoDS_Shape algoShape;
if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape ))
if ( !GetAlgo( sm, & algoShape ))
continue; // strange...
// look for more local algos
@ -525,7 +526,8 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh,
.And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
.And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh ));
if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( smToCompute, filter, true ))
{
if ( ! subAlgo->NeedDiscreteBoundary() ) continue;
SMESH_Hypothesis::Hypothesis_Status status;
if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
@ -1013,6 +1015,23 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
TopoDS_Shape* assignedTo)
{
return GetAlgo( aMesh.GetSubMesh( aShape ), assignedTo );
}
//=============================================================================
/*!
* Finds algo to mesh a sub-mesh. Optionally returns a shape the found algo is bound to
*/
//=============================================================================
SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_subMesh * aSubMesh,
TopoDS_Shape* assignedTo)
{
if ( !aSubMesh ) return 0;
const TopoDS_Shape & aShape = aSubMesh->GetSubShape();
SMESH_Mesh& aMesh = *aSubMesh->GetFather();
SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
filter.And( filter.IsApplicableTo( aShape ));
@ -1020,7 +1039,7 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh,
TopoDS_Shape assignedToShape;
SMESH_Algo* algo =
(SMESH_Algo*) aMesh.GetHypothesis( aShape, filter, true, &assignedToShape );
(SMESH_Algo*) aMesh.GetHypothesis( aSubMesh, filter, true, &assignedToShape );
if ( algo &&
aShape.ShapeType() == TopAbs_FACE &&
@ -1035,7 +1054,7 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh,
filter.AndNot( filter.Is( algo ));
TopoDS_Shape assignedToShape2;
SMESH_Algo* algo2 =
(SMESH_Algo*) aMesh.GetHypothesis( aShape, filter, true, &assignedToShape2 );
(SMESH_Algo*) aMesh.GetHypothesis( aSubMesh, filter, true, &assignedToShape2 );
if ( algo2 && // algo found
!assignedToShape2.IsSame( aMesh.GetShapeToMesh() ) && // algo is local
( SMESH_MesherHelper::GetGroupType( assignedToShape2 ) == // algo of the same level

View File

@ -147,6 +147,7 @@ public:
{ return GetShapeDim( aShape.ShapeType() ); }
SMESH_Algo* GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, TopoDS_Shape* assignedTo=0);
SMESH_Algo* GetAlgo(SMESH_subMesh * aSubMesh, TopoDS_Shape* assignedTo=0);
static bool IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh);

View File

@ -773,7 +773,30 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS
const bool andAncestors,
TopoDS_Shape* assignedTo) const
{
return GetHypothesis( const_cast< SMESH_Mesh* >(this)->GetSubMesh( aSubShape ),
aFilter, andAncestors, assignedTo );
}
//=======================================================================
/*!
* \brief Return the hypothesis assigned to the shape of a sub-mesh
* \param aSubMesh - the sub-mesh to check
* \param aFilter - the hypothesis filter
* \param andAncestors - flag to check hypos assigned to ancestors of the shape
* \param assignedTo - to return the shape the found hypo is assigned to
* \retval SMESH_Hypothesis* - the first hypo passed through aFilter
*/
//=======================================================================
const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const SMESH_subMesh * aSubMesh,
const SMESH_HypoFilter& aFilter,
const bool andAncestors,
TopoDS_Shape* assignedTo) const
{
if ( !aSubMesh ) return 0;
{
const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
for ( ; hyp != hypList.end(); hyp++ ) {
@ -787,9 +810,12 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS
if ( andAncestors )
{
// user sorted submeshes of ancestors, according to stored submesh priority
getAncestorsSubMeshes( aSubShape, _ancestorSubMeshes );
vector<SMESH_subMesh*>::const_iterator smIt = _ancestorSubMeshes.begin();
for ( ; smIt != _ancestorSubMeshes.end(); smIt++ )
std::vector< SMESH_subMesh * > & ancestors =
const_cast< std::vector< SMESH_subMesh * > & > ( aSubMesh->GetAncestors() );
SortByMeshOrder( ancestors );
vector<SMESH_subMesh*>::const_iterator smIt = ancestors.begin();
for ( ; smIt != ancestors.end(); smIt++ )
{
const TopoDS_Shape& curSh = (*smIt)->GetSubShape();
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(curSh);
@ -808,7 +834,7 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS
//================================================================================
/*!
* \brief Return hypothesis assigned to the shape
* \brief Return hypotheses assigned to the shape
* \param aSubShape - the shape to check
* \param aFilter - the hypothesis filter
* \param aHypList - the list of the found hypotheses
@ -823,6 +849,29 @@ int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
const bool andAncestors,
list< TopoDS_Shape > * assignedTo/*=0*/) const
{
return GetHypotheses( const_cast< SMESH_Mesh* >(this)->GetSubMesh( aSubShape ),
aFilter, aHypList, andAncestors, assignedTo );
}
//================================================================================
/*!
* \brief Return hypotheses assigned to the shape of a sub-mesh
* \param aSubShape - the sub-mesh to check
* \param aFilter - the hypothesis filter
* \param aHypList - the list of the found hypotheses
* \param andAncestors - flag to check hypos assigned to ancestors of the shape
* \retval int - number of unique hypos in aHypList
*/
//================================================================================
int SMESH_Mesh::GetHypotheses(const SMESH_subMesh * aSubMesh,
const SMESH_HypoFilter& aFilter,
list <const SMESHDS_Hypothesis * >& aHypList,
const bool andAncestors,
list< TopoDS_Shape > * assignedTo/*=0*/) const
{
if ( !aSubMesh ) return 0;
set<string> hypTypes; // to exclude same type hypos from the result list
int nbHyps = 0;
@ -840,6 +889,7 @@ int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
// get hypos from aSubShape
{
const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
if ( aFilter.IsOk (cSMESH_Hyp( *hyp ), aSubShape) &&
@ -857,16 +907,15 @@ int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
// get hypos from ancestors of aSubShape
if ( andAncestors )
{
TopTools_MapOfShape map;
// user sorted submeshes of ancestors, according to stored submesh priority
getAncestorsSubMeshes( aSubShape, _ancestorSubMeshes );
vector<SMESH_subMesh*>::const_iterator smIt = _ancestorSubMeshes.begin();
for ( ; smIt != _ancestorSubMeshes.end(); smIt++ )
std::vector< SMESH_subMesh * > & ancestors =
const_cast< std::vector< SMESH_subMesh * > & > ( aSubMesh->GetAncestors() );
SortByMeshOrder( ancestors );
vector<SMESH_subMesh*>::const_iterator smIt = ancestors.begin();
for ( ; smIt != ancestors.end(); smIt++ )
{
const TopoDS_Shape& curSh = (*smIt)->GetSubShape();
if ( !map.Add( curSh ))
continue;
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(curSh);
for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
if (( aFilter.IsOk( cSMESH_Hyp( *hyp ), curSh )) &&
@ -1047,9 +1096,7 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp ))
return false;
const TopoDS_Shape & aSubShape = const_cast<SMESH_subMesh*>( aSubMesh )->GetSubShape();
SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape );
SMESH_Algo *algo = aSubMesh->GetAlgo();
// algorithm
if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO)
@ -1062,7 +1109,7 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
const SMESH_HypoFilter* hypoKind;
if (( hypoKind = algo->GetCompatibleHypoFilter( !hyp->IsAuxiliary() ))) {
list <const SMESHDS_Hypothesis * > usedHyps;
if ( GetHypotheses( aSubShape, *hypoKind, usedHyps, true ))
if ( GetHypotheses( aSubMesh, *hypoKind, usedHyps, true ))
return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() );
}
}
@ -1134,7 +1181,7 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h
{
// check if hyp is used by algo
usedHyps.clear();
if ( GetHypotheses( aSubShape, *compatibleHypoKind, usedHyps, true ) &&
if ( GetHypotheses( aSubMesh, *compatibleHypoKind, usedHyps, true ) &&
find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() )
{
aSubMesh->AlgoStateEngine(SMESH_subMesh::MODIF_HYP,
@ -2138,7 +2185,10 @@ void SMESH_Mesh::fillAncestorsMap(const TopoDS_Shape& theShape)
while ( ancIt.More() && ancIt.Value().ShapeType() >= memberType )
ancIt.Next();
if ( ancIt.More() )
{
ancList.InsertBefore( theShape, ancIt );
GetSubMesh( des.Current() )->ClearAncestors(); // to re-fill _ancestors
}
}
}
{

View File

@ -148,6 +148,17 @@ public:
const bool andAncestors,
std::list< TopoDS_Shape > * assignedTo=0) const;
const SMESH_Hypothesis * GetHypothesis(const SMESH_subMesh * aSubMesh,
const SMESH_HypoFilter& aFilter,
const bool andAncestors,
TopoDS_Shape* assignedTo=0) const;
int GetHypotheses(const SMESH_subMesh * aSubMesh,
const SMESH_HypoFilter& aFilter,
std::list< const SMESHDS_Hypothesis * >& aHypList,
const bool andAncestors,
std::list< TopoDS_Shape > * assignedTo=0) const;
SMESH_Hypothesis * GetHypothesis(const int aHypID) const;
const std::list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);

View File

@ -47,13 +47,14 @@
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <gp_Pnt.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Iterator.hxx>
#include <gp_Pnt.hxx>
#include <Standard_OutOfMemory.hxx>
#include <Standard_ErrorHandler.hxx>
@ -195,7 +196,10 @@ SMESH_subMesh *SMESH_subMesh::GetFirstToCompute()
SMESH_Algo* SMESH_subMesh::GetAlgo() const
{
if ( !_algo )
((SMESH_subMesh*)this)->_algo = _father->GetGen()->GetAlgo(*_father, _subShape);
{
SMESH_subMesh* me = const_cast< SMESH_subMesh* >( this );
me->_algo = _father->GetGen()->GetAlgo( me );
}
return _algo;
}
@ -735,7 +739,7 @@ SMESH_Hypothesis::Hypothesis_Status
SMESH_HypoFilter filter( SMESH_HypoFilter::HasType( algo->GetType() ));
filter.Or( SMESH_HypoFilter::HasType( algo->GetType()+1 ));
filter.Or( SMESH_HypoFilter::HasType( algo->GetType()+2 ));
if ( SMESH_Algo * curAlgo = (SMESH_Algo*)_father->GetHypothesis(_subShape, filter, true ))
if ( SMESH_Algo * curAlgo = (SMESH_Algo*)_father->GetHypothesis( this, filter, true ))
if ( !curAlgo->NeedDiscreteBoundary() )
algoRequiringCleaning = curAlgo;
}
@ -964,7 +968,7 @@ SMESH_Hypothesis::Hypothesis_Status
f.Init( SMESH_HypoFilter::IsAlgo() );
f.And( SMESH_HypoFilter::IsApplicableTo( _subShape ));
f.AndNot( SMESH_HypoFilter::Is( algo ));
const SMESH_Hypothesis * prevAlgo = _father->GetHypothesis( _subShape, f, true );
const SMESH_Hypothesis * prevAlgo = _father->GetHypothesis( this, f, true );
if (prevAlgo &&
string(algo->GetName()) != string(prevAlgo->GetName()) )
modifiedHyp = true;
@ -1023,7 +1027,7 @@ SMESH_Hypothesis::Hypothesis_Status
f.Init( SMESH_HypoFilter::IsAlgo() );
f.And( SMESH_HypoFilter::IsApplicableTo( _subShape ));
f.AndNot( SMESH_HypoFilter::Is( algo ));
const SMESH_Hypothesis* prevAlgo = _father->GetHypothesis( _subShape, f, true );
const SMESH_Hypothesis* prevAlgo = _father->GetHypothesis( this, f, true );
if (prevAlgo &&
string(algo->GetName()) != string(prevAlgo->GetName()) )
modifiedHyp = true;
@ -1089,21 +1093,22 @@ SMESH_Hypothesis::Hypothesis_Status
{
// is algo hidden?
SMESH_Gen* gen = _father->GetGen();
TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape ));
for ( ; ( ret == SMESH_Hypothesis::HYP_OK && it.More()); it.Next() ) {
if ( SMESH_Algo* upperAlgo = gen->GetAlgo( *_father, it.Value() ))
const std::vector< SMESH_subMesh * > & ancestors = GetAncestors();
for ( size_t iA = 0; ( ret == SMESH_Hypothesis::HYP_OK && iA < ancestors.size()); ++iA ) {
if ( SMESH_Algo* upperAlgo = ancestors[ iA ]->GetAlgo() )
if ( !upperAlgo->NeedDiscreteBoundary() && !upperAlgo->SupportSubmeshes())
ret = SMESH_Hypothesis::HYP_HIDDEN_ALGO;
}
// is algo hiding?
if ( ret == SMESH_Hypothesis::HYP_OK &&
!algo->NeedDiscreteBoundary() &&
!algo->SupportSubmeshes()) {
!algo->SupportSubmeshes())
{
TopoDS_Shape algoAssignedTo, otherAssignedTo;
gen->GetAlgo( *_father, _subShape, &algoAssignedTo );
gen->GetAlgo( this, &algoAssignedTo );
map<int, SMESH_subMesh*>::reverse_iterator i_sm = _mapDepend.rbegin();
for ( ; ( ret == SMESH_Hypothesis::HYP_OK && i_sm != _mapDepend.rend()) ; ++i_sm )
if ( gen->GetAlgo( *_father, i_sm->second->_subShape, &otherAssignedTo ) &&
if ( gen->GetAlgo( i_sm->second, &otherAssignedTo ) &&
SMESH_MesherHelper::IsSubShape( /*sub=*/otherAssignedTo, /*main=*/algoAssignedTo ))
ret = SMESH_Hypothesis::HYP_HIDING_ALGO;
}
@ -1177,16 +1182,16 @@ bool SMESH_subMesh::IsConform(const SMESH_Algo* theAlgo)
for (; itsub.More(); itsub.Next())
{
// loop on adjacent subShapes
TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( itsub.Value() ));
for (; it.More(); it.Next())
const std::vector< SMESH_subMesh * > & ancestors = GetAncestors();
for ( size_t iA = 0; iA < ancestors.size(); ++iA )
{
const TopoDS_Shape& adjacent = it.Value();
const TopoDS_Shape& adjacent = ancestors[ iA ]->GetSubShape();
if ( _subShape.IsSame( adjacent )) continue;
if ( adjacent.ShapeType() != _subShape.ShapeType())
break;
// check algo attached to smAdjacent
SMESH_Algo * algo = gen->GetAlgo((*_father), adjacent);
SMESH_Algo * algo = ancestors[ iA ]->GetAlgo();
if (algo &&
!algo->NeedDiscreteBoundary() &&
algo->OnlyUnaryInput())
@ -2035,12 +2040,10 @@ void SMESH_subMesh::ComputeSubMeshStateEngine(int event, const bool includeSelf)
void SMESH_subMesh::updateDependantsState(const compute_event theEvent)
{
TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape ));
for (; it.More(); it.Next())
const std::vector< SMESH_subMesh * > & ancestors = GetAncestors();
for ( size_t iA = 0; iA < ancestors.size(); ++iA )
{
const TopoDS_Shape& ancestor = it.Value();
if ( SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor))
aSubMesh->ComputeStateEngine( theEvent );
ancestors[ iA ]->ComputeStateEngine( theEvent );
}
}
@ -2054,19 +2057,17 @@ void SMESH_subMesh::cleanDependants()
{
int dimToClean = SMESH_Gen::GetShapeDim( _subShape ) + 1;
TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape ));
for (; it.More(); it.Next())
const std::vector< SMESH_subMesh * > & ancestors = GetAncestors();
for ( size_t iA = 0; iA < ancestors.size(); ++iA )
{
const TopoDS_Shape& ancestor = it.Value();
if ( SMESH_Gen::GetShapeDim( ancestor ) == dimToClean ) {
const TopoDS_Shape& ancestor = ancestors[ iA ]->GetSubShape();
if ( SMESH_Gen::GetShapeDim( ancestor ) == dimToClean )
{
// PAL8021. do not go upper than SOLID, else ComputeStateEngine(CLEAN)
// will erase mesh on other shapes in a compound
if ( ancestor.ShapeType() >= TopAbs_SOLID ) {
SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor);
if (aSubMesh &&
!aSubMesh->IsEmpty() ) // prevent infinite CLEAN via event lesteners
aSubMesh->ComputeStateEngine(CLEAN);
}
if ( ancestor.ShapeType() >= TopAbs_SOLID &&
!ancestors[ iA ]->IsEmpty() ) // prevent infinite CLEAN via event lesteners
ancestors[ iA ]->ComputeStateEngine(CLEAN);
}
}
}
@ -2142,7 +2143,7 @@ TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * theGen,
}
else if ( subMesh->GetComputeState() == READY_TO_COMPUTE )
{
SMESH_Algo* anAlgo = theGen->GetAlgo( *_father, S );
SMESH_Algo* anAlgo = theGen->GetAlgo( subMesh );
if (strcmp( anAlgo->GetName(), theAlgo->GetName()) == 0 && // same algo
anAlgo->GetUsedHypothesis( *_father, S, ignoreAuxiliaryHyps ) == aUsedHyp) // same hyps
aBuilder.Add( aCompound, S );
@ -2576,6 +2577,44 @@ SMESH_subMeshIteratorPtr SMESH_subMesh::getDependsOnIterator(const bool includeS
}
}
//================================================================================
/*!
* \brief Returns ancestor sub-meshes. Finds them if not yet found.
*/
//================================================================================
const std::vector< SMESH_subMesh * > & SMESH_subMesh::GetAncestors() const
{
if ( _ancestors.empty() &&
!_subShape.IsSame( _father->GetShapeToMesh() ))
{
const TopTools_ListOfShape& ancShapes = _father->GetAncestors( _subShape );
SMESH_subMesh* me = const_cast< SMESH_subMesh* >( this );
me->_ancestors.reserve( ancShapes.Extent() );
TopTools_MapOfShape map;
for ( TopTools_ListIteratorOfListOfShape it( ancShapes ); it.More(); it.Next() )
if ( SMESH_subMesh* sm = _father->GetSubMeshContaining( it.Value() ))
if ( map.Add( it.Value() ))
me->_ancestors.push_back( sm );
}
return _ancestors;
}
//================================================================================
/*!
* \brief Clears the vector of ancestor sub-meshes
*/
//================================================================================
void SMESH_subMesh::ClearAncestors()
{
_ancestors.clear();
}
//================================================================================
/*!
* \brief Find common submeshes (based on shared sub-shapes with other

View File

@ -88,6 +88,9 @@ class SMESH_EXPORT SMESH_subMesh
SMESH_subMeshIteratorPtr getDependsOnIterator(const bool includeSelf,
const bool complexShapeFirst=false) const;
const std::vector< SMESH_subMesh * > & GetAncestors() const;
void ClearAncestors();
const TopoDS_Shape & GetSubShape() const;
enum compute_state
@ -325,6 +328,7 @@ protected:
std::map < int, SMESH_subMesh * >_mapDepend;
bool _dependenceAnalysed;
std::vector< SMESH_subMesh * > _ancestors;
SMESH_Algo * _algo; // the algorithm found by last *StateEngine() call
algo_state _algoState;

View File

@ -209,23 +209,22 @@ namespace {
/*!
* \brief Returns a local 1D hypothesis used for theEdge
*/
const SMESH_Hypothesis* getLocal1DHyp (SMESH_Mesh& theMesh,
const TopoDS_Shape& theEdge,
const SMESH_Hypothesis* getLocal1DHyp (SMESH_subMesh* theSubMesh,
//const TopoDS_Shape& theEdge,
TopoDS_Shape* theSssignedTo=0)
{
static SMESH_HypoFilter hypo;
hypo.Init( hypo.HasDim( 1 )).
AndNot ( hypo.IsAlgo() ).
AndNot ( hypo.IsAssignedTo( theMesh.GetShapeToMesh() ));
AndNot ( hypo.IsAssignedTo( theSubMesh->GetFather()->GetShapeToMesh() ));
return theMesh.GetHypothesis( theEdge, hypo, true, theSssignedTo );
return theSubMesh->GetFather()->GetHypothesis( theSubMesh, hypo, true, theSssignedTo );
}
//=============================================================================
/*!
* \brief Returns a propagation hypothesis assigned to theEdge
*/
const SMESH_Hypothesis* getProagationHyp (SMESH_Mesh& theMesh,
const TopoDS_Shape& theEdge)
const SMESH_Hypothesis* getProagationHyp (SMESH_subMesh* theSubMesh)
{
static SMESH_HypoFilter propagHypFilter;
if ( propagHypFilter.IsEmpty() )
@ -234,7 +233,7 @@ namespace {
Init( SMESH_HypoFilter::HasName( StdMeshers_Propagation::GetName ())).
Or ( SMESH_HypoFilter::HasName( StdMeshers_PropagOfDistribution::GetName ()));
}
return theMesh.GetHypothesis( theEdge, propagHypFilter, true );
return theSubMesh->GetFather()->GetHypothesis( theSubMesh, propagHypFilter, true );
}
//================================================================================
/*!
@ -261,13 +260,13 @@ namespace {
SMESH_Mesh* mesh = theMainSubMesh->GetFather();
TopoDS_Shape shapeOfHyp1D; // shape to which an hyp being propagated is assigned
const SMESH_Hypothesis* hyp1D = getLocal1DHyp( *mesh, theMainEdge, &shapeOfHyp1D );
const SMESH_Hypothesis* hyp1D = getLocal1DHyp( theMainSubMesh, &shapeOfHyp1D );
SMESH_HypoFilter moreLocalCheck( SMESH_HypoFilter::IsMoreLocalThan( shapeOfHyp1D, *mesh ));
PropagationMgrData* chainData = getData( theMainSubMesh );
chainData->SetState( HAS_PROPAG_HYP );
if ( const SMESH_Hypothesis * propagHyp = getProagationHyp( *mesh, theMainEdge ))
if ( const SMESH_Hypothesis * propagHyp = getProagationHyp( theMainSubMesh ))
chainData->myIsPropagOfDistribution =
( StdMeshers_PropagOfDistribution::GetName() == propagHyp->GetName() );
@ -279,6 +278,8 @@ namespace {
TopTools_MapOfShape checkedShapes;
checkedShapes.Add( theMainEdge );
vector<TopoDS_Edge> edges;
list<SMESH_subMesh*>::iterator smIt = chain.begin();
for ( ; smIt != chain.end(); ++smIt )
{
@ -295,9 +296,8 @@ namespace {
continue;
// Get ordered edges and find index of anE in a sequence
edges.clear();
BRepTools_WireExplorer aWE (TopoDS::Wire(itA.Value()));
vector<TopoDS_Edge> edges;
edges.reserve(4);
int edgeIndex = 0;
for (; aWE.More(); aWE.Next()) {
TopoDS_Edge edge = aWE.Current();
@ -361,7 +361,7 @@ namespace {
if ( oppData->State() == WAIT_PROPAG_HYP ) // ... anOppE is not in any chain
{
oppData->SetSource( theMainSubMesh );
if ( ! (hyp1D = getLocal1DHyp( *mesh, anOppE, &shapeOfHyp1D )) || //...no 1d hyp on anOppE
if ( ! (hyp1D = getLocal1DHyp( oppSM, &shapeOfHyp1D )) || //...no 1d hyp on anOppE
! (moreLocalCheck.IsOk( hyp1D, shapeOfHyp1D ))) // ... or hyp1D is "more global"
{
oppData->myForward = data->myForward;
@ -373,8 +373,8 @@ namespace {
DBGMSG( "set IN_CHAIN on " << oppSM->GetId() );
if ( oppSM->GetAlgoState() != SMESH_subMesh::HYP_OK )
// make oppSM check algo state
if ( SMESH_Algo* algo = mesh->GetGen()->GetAlgo( *mesh, anOppE ))
oppSM->AlgoStateEngine(SMESH_subMesh::ADD_FATHER_ALGO,algo);
if ( SMESH_Algo* algo = oppSM->GetAlgo() )
oppSM->AlgoStateEngine(SMESH_subMesh::ADD_FATHER_ALGO, algo);
}
else {
oppData->SetState( LAST_IN_CHAIN );
@ -490,7 +490,7 @@ namespace {
submesh->SetEventListener( getListener(), data, submesh );
const SMESH_Hypothesis * propagHyp =
getProagationHyp( *submesh->GetFather(), submesh->GetSubShape() );
getProagationHyp( submesh );
if ( propagHyp )
{
data->myIsPropagOfDistribution =
@ -556,11 +556,10 @@ namespace {
case WAIT_PROPAG_HYP: { // propagation hyp or local 1D hyp is missing
// --------------------------------------------------------
bool hasPropagHyp = ( isPropagHyp ||
getProagationHyp( *subMesh->GetFather(), subMesh->GetSubShape()) );
bool hasPropagHyp = ( isPropagHyp || getProagationHyp( subMesh ));
if ( !hasPropagHyp )
return;
bool hasLocal1DHyp = getLocal1DHyp( *subMesh->GetFather(), subMesh->GetSubShape());
bool hasLocal1DHyp = getLocal1DHyp( subMesh );
if ( !hasLocal1DHyp )
return;
if ( event == SMESH_subMesh::ADD_HYP ||
@ -577,7 +576,7 @@ namespace {
switch ( event ) {
case SMESH_subMesh::REMOVE_HYP:
case SMESH_subMesh::REMOVE_FATHER_HYP: // remove propagation hyp
if ( isPropagHyp && !getProagationHyp( *subMesh->GetFather(), subMesh->GetSubShape()) )
if ( isPropagHyp && !getProagationHyp( subMesh ))
{
DBGMSG( "REMOVE_HYP propagation from HAS_PROPAG_HYP " << subMesh->GetId() );
// clear propagation chain