fix the problem that an existing mesh is not deleted when a "Quadratic

Mesh" hypothesis is (un)assigned. Speed optimization of submesh
notifiacation on hypothesis modification
This commit is contained in:
eap 2006-03-03 13:59:10 +00:00
parent 261d5abd90
commit 0e55a67f3c
13 changed files with 296 additions and 128 deletions

View File

@ -45,7 +45,6 @@ SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen)
// _compatibleHypothesis.push_back("hypothese_2D_bidon"); // _compatibleHypothesis.push_back("hypothese_2D_bidon");
_type = ALGO_2D; _type = ALGO_2D;
gen->_map2D_Algo[hypId] = this; gen->_map2D_Algo[hypId] = this;
myCreateQuadratic = false;
} }
//============================================================================= //=============================================================================
@ -56,7 +55,6 @@ SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen)
SMESH_2D_Algo::~SMESH_2D_Algo() SMESH_2D_Algo::~SMESH_2D_Algo()
{ {
myCreateQuadratic = false;
} }
//============================================================================= //=============================================================================
@ -85,12 +83,10 @@ int SMESH_2D_Algo::NumberOfPoints(SMESH_Mesh& aMesh, const TopoDS_Wire& W)
for (TopExp_Explorer exp(W,TopAbs_EDGE); exp.More(); exp.Next()) { for (TopExp_Explorer exp(W,TopAbs_EDGE); exp.More(); exp.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(exp.Current()); const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if(myCreateQuadratic) if(_quadraticMesh)
nb = nb/2; nb = nb/2;
//SCRUTE(nb);
nbPoints += nb + 1; // internal points plus 1 vertex of 2 (last point ?) nbPoints += nb + 1; // internal points plus 1 vertex of 2 (last point ?)
} }
//SCRUTE(nbPoints);
return nbPoints; return nbPoints;
} }

View File

@ -43,8 +43,6 @@ public:
int NumberOfWires(const TopoDS_Shape& S); int NumberOfWires(const TopoDS_Shape& S);
int NumberOfPoints(SMESH_Mesh& aMesh,const TopoDS_Wire& W); int NumberOfPoints(SMESH_Mesh& aMesh,const TopoDS_Wire& W);
protected:
bool myCreateQuadratic;
}; };
#endif #endif

View File

@ -68,6 +68,7 @@ SMESH_Algo::SMESH_Algo(int hypId, int studyId,
gen->_mapAlgo[hypId] = this; gen->_mapAlgo[hypId] = this;
_onlyUnaryInput = _requireDescretBoundary = true; _onlyUnaryInput = _requireDescretBoundary = true;
_quadraticMesh = false;
} }
//============================================================================= //=============================================================================
@ -101,18 +102,17 @@ const vector < string > &SMESH_Algo::GetCompatibleHypothesis()
*/ */
//============================================================================= //=============================================================================
const list <const SMESHDS_Hypothesis *> & SMESH_Algo::GetUsedHypothesis( const list <const SMESHDS_Hypothesis *> &
SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) SMESH_Algo::GetUsedHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const bool ignoreAuxiliary)
{ {
_usedHypList.clear(); _usedHypList.clear();
if ( !_compatibleHypothesis.empty() ) SMESH_HypoFilter filter;
if ( InitCompatibleHypoFilter( filter, ignoreAuxiliary ))
{ {
SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( _compatibleHypothesis[0] ));
for ( int i = 1; i < _compatibleHypothesis.size(); ++i )
filter.Or( filter.HasName( _compatibleHypothesis[ i ] ));
aMesh.GetHypotheses( aShape, filter, _usedHypList, true ); aMesh.GetHypotheses( aShape, filter, _usedHypList, true );
if ( _usedHypList.size() > 1 ) if ( ignoreAuxiliary && _usedHypList.size() > 1 )
_usedHypList.clear(); //only one compatible hypothesis allowed _usedHypList.clear(); //only one compatible hypothesis allowed
} }
return _usedHypList; return _usedHypList;
@ -126,18 +126,16 @@ const list <const SMESHDS_Hypothesis *> & SMESH_Algo::GetUsedHypothesis(
*/ */
//============================================================================= //=============================================================================
const list<const SMESHDS_Hypothesis *> & SMESH_Algo::GetAppliedHypothesis( const list<const SMESHDS_Hypothesis *> &
SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const bool ignoreAuxiliary)
{ {
_appliedHypList.clear(); _appliedHypList.clear();
if ( !_compatibleHypothesis.empty() ) SMESH_HypoFilter filter;
{ if ( InitCompatibleHypoFilter( filter, ignoreAuxiliary ))
SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( _compatibleHypothesis[0] ));
for ( int i = 1; i < _compatibleHypothesis.size(); ++i )
filter.Or( filter.HasName( _compatibleHypothesis[ i ] ));
aMesh.GetHypotheses( aShape, filter, _appliedHypList, false ); aMesh.GetHypotheses( aShape, filter, _appliedHypList, false );
}
return _appliedHypList; return _appliedHypList;
} }
@ -267,3 +265,26 @@ bool SMESH_Algo::IsReversedSubMesh (const TopoDS_Face& theFace,
return Ne * Nf < 0.; return Ne * Nf < 0.;
} }
/*!
* \brief Make filter recognize only compatible hypotheses
* \param theFilter - the filter to initialize
* \param ignoreAuxiliary - make filter ignore compatible auxiliary hypotheses
*/
bool SMESH_Algo::InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter,
const bool ignoreAuxiliary) const
{
if ( !_compatibleHypothesis.empty() )
{
theFilter.Init( theFilter.HasName( _compatibleHypothesis[0] ));
for ( int i = 1; i < _compatibleHypothesis.size(); ++i )
theFilter.Or( theFilter.HasName( _compatibleHypothesis[ i ] ));
if ( ignoreAuxiliary )
theFilter.AndNot( theFilter.IsAuxiliary() );
return true;
}
return false;
}

View File

@ -42,6 +42,7 @@
class SMESH_Gen; class SMESH_Gen;
class SMESH_Mesh; class SMESH_Mesh;
class SMESH_HypoFilter;
class TopoDS_Face; class TopoDS_Face;
class SMESHDS_Mesh; class SMESHDS_Mesh;
class SMDS_MeshNode; class SMDS_MeshNode;
@ -60,13 +61,27 @@ class SMESH_Algo:public SMESH_Hypothesis
virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0; virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0;
virtual const std::list <const SMESHDS_Hypothesis *> & virtual const std::list <const SMESHDS_Hypothesis *> &
GetUsedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); GetUsedHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const bool ignoreAuxiliary=true);
const list <const SMESHDS_Hypothesis *> & const list <const SMESHDS_Hypothesis *> &
GetAppliedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); GetAppliedHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const bool ignoreAuxiliary=true);
static double EdgeLength(const TopoDS_Edge & E); static double EdgeLength(const TopoDS_Edge & E);
/*!
* \brief Make filter recognize only compatible hypotheses
* \param theFilter - the filter to initialize
* \param ignoreAuxiliary - make filter ignore compatible auxiliary hypotheses
* \retval bool - true if the algo has compatible hypotheses
*/
bool InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter,
const bool ignoreAuxiliary) const;
/*! /*!
* \brief Find out elements orientation on a geometrical face * \brief Find out elements orientation on a geometrical face
* \param theFace - The face correctly oriented in the shape being meshed * \param theFace - The face correctly oriented in the shape being meshed
@ -101,6 +116,8 @@ class SMESH_Algo:public SMESH_Hypothesis
std::list<const SMESHDS_Hypothesis *> _appliedHypList; std::list<const SMESHDS_Hypothesis *> _appliedHypList;
std::list<const SMESHDS_Hypothesis *> _usedHypList; std::list<const SMESHDS_Hypothesis *> _usedHypList;
// quadratic mesh creation required
bool _quadraticMesh;
}; };
#endif #endif

View File

@ -633,13 +633,14 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
if ( algoList.empty() ) if ( algoList.empty() )
return NULL; return NULL;
if (algoList.size() > 1 ) { // check if there is one algo several times // Now it is checked in SMESH_Mesh::GetHypotheses()
list <const SMESHDS_Hypothesis * >::iterator algo = algoList.begin(); // if (algoList.size() > 1 ) { // check if there is one algo several times
for ( ; algo != algoList.end(); ++algo ) // list <const SMESHDS_Hypothesis * >::iterator algo = algoList.begin();
if ( (*algo) != algoList.front() && // for ( ; algo != algoList.end(); ++algo )
(*algo)->GetName() != algoList.front()->GetName() ) // if ( (*algo) != algoList.front() &&
return NULL; // (*algo)->GetName() != algoList.front()->GetName() )
} // return NULL;
// }
return const_cast<SMESH_Algo*> ( static_cast<const SMESH_Algo* >( algoList.front() )); return const_cast<SMESH_Algo*> ( static_cast<const SMESH_Algo* >( algoList.front() ));
} }

View File

@ -75,6 +75,17 @@ bool SMESH_HypoFilter::ApplicablePredicate::IsOk(const SMESH_Hypothesis* aHyp,
return SMESH_subMesh::IsApplicableHypotesis( aHyp, (TopAbs_ShapeEnum)_shapeType ); return SMESH_subMesh::IsApplicableHypotesis( aHyp, (TopAbs_ShapeEnum)_shapeType );
}; };
//=======================================================================
//function : IsAuxiliaryPredicate::IsOk
//purpose :
//=======================================================================
bool SMESH_HypoFilter::IsAuxiliaryPredicate::IsOk(const SMESH_Hypothesis* aHyp,
const TopoDS_Shape& /*aShape*/) const
{
return aHyp->IsAuxiliary();
};
//======================================================================= //=======================================================================
//function : ApplicablePredicate::ApplicablePredicate //function : ApplicablePredicate::ApplicablePredicate
//purpose : //purpose :
@ -190,6 +201,17 @@ SMESH_HypoPredicate* SMESH_HypoFilter::IsAlgo()
return new TypePredicate( MORE, SMESHDS_Hypothesis::PARAM_ALGO ); return new TypePredicate( MORE, SMESHDS_Hypothesis::PARAM_ALGO );
} }
//=======================================================================
//function : IsAuxiliary
//purpose :
//=======================================================================
SMESH_HypoPredicate* SMESH_HypoFilter::IsAuxiliary()
{
return new IsAuxiliaryPredicate();
}
//======================================================================= //=======================================================================
//function : IsGlobal //function : IsGlobal
//purpose : //purpose :

View File

@ -67,6 +67,7 @@ class SMESH_HypoFilter: public SMESH_HypoPredicate
// Create predicates // Create predicates
static SMESH_HypoPredicate* IsAlgo(); static SMESH_HypoPredicate* IsAlgo();
static SMESH_HypoPredicate* IsAuxiliary();
static SMESH_HypoPredicate* IsApplicableTo(const TopoDS_Shape& theShape); static SMESH_HypoPredicate* IsApplicableTo(const TopoDS_Shape& theShape);
static SMESH_HypoPredicate* IsAssignedTo(const TopoDS_Shape& theShape); static SMESH_HypoPredicate* IsAssignedTo(const TopoDS_Shape& theShape);
static SMESH_HypoPredicate* Is(const SMESH_Hypothesis* theHypo); static SMESH_HypoPredicate* Is(const SMESH_Hypothesis* theHypo);
@ -158,6 +159,11 @@ class SMESH_HypoFilter: public SMESH_HypoPredicate
const TopoDS_Shape& aShape) const; const TopoDS_Shape& aShape) const;
}; };
struct IsAuxiliaryPredicate : public SMESH_HypoPredicate {
bool IsOk(const SMESH_Hypothesis* aHyp,
const TopoDS_Shape& aShape) const;
};
}; };

View File

@ -72,13 +72,14 @@ SMESH_Hypothesis::~SMESH_Hypothesis()
int SMESH_Hypothesis::GetDim() const int SMESH_Hypothesis::GetDim() const
{ {
int dim = -1; int dim = 0;
switch (_type) switch (_type)
{ {
case ALGO_1D: dim = 1; break; case ALGO_1D: dim = 1; break;
case ALGO_2D: dim = 2; break; case ALGO_2D: dim = 2; break;
case ALGO_3D: dim = 3; break; case ALGO_3D: dim = 3; break;
case PARAM_ALGO: dim = _param_algo_dim; break; case PARAM_ALGO:
dim = ( _param_algo_dim < 0 ) ? -_param_algo_dim : _param_algo_dim; break;
} }
return dim; return dim;
} }
@ -124,14 +125,15 @@ void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
itm++) itm++)
{ {
SMESH_Mesh* mesh = (*itm).second; SMESH_Mesh* mesh = (*itm).second;
const list<SMESH_subMesh*>& subMeshes = mesh->NotifySubMeshesHypothesisModification( this );
mesh->GetSubMeshUsingHypothesis(this); // const list<SMESH_subMesh*>& subMeshes =
// mesh->GetSubMeshUsingHypothesis(this);
//for all subMeshes using hypothesis // //for all subMeshes using hypothesis
list<SMESH_subMesh*>::const_iterator its; // list<SMESH_subMesh*>::const_iterator its;
for (its = subMeshes.begin(); its != subMeshes.end(); its++) // for (its = subMeshes.begin(); its != subMeshes.end(); its++)
(*its)->ComputeStateEngine(SMESH_subMesh::MODIF_HYP); // (*its)->ComputeStateEngine(SMESH_subMesh::MODIF_HYP);
} }
} }

View File

@ -54,13 +54,24 @@ public:
SMESH_Hypothesis(int hypId, int studyId, SMESH_Gen* gen); SMESH_Hypothesis(int hypId, int studyId, SMESH_Gen* gen);
virtual ~SMESH_Hypothesis(); virtual ~SMESH_Hypothesis();
int GetDim() const; virtual int GetDim() const;
int GetStudyId() const; int GetStudyId() const;
void NotifySubMeshesHypothesisModification(); virtual void NotifySubMeshesHypothesisModification();
int GetShapeType() const; virtual int GetShapeType() const;
const char* GetLibName() const; virtual const char* GetLibName() const;
void SetLibName(const char* theLibName); void SetLibName(const char* theLibName);
/*!
* \brief Return true if me is an auxiliary hypothesis
* \retval bool - auxiliary or not
*
* An auxiliary hypothesis is optional, i.e. an algorithm
* can work without it and another hypothesis of the same
* dimention can be assigned to the shape
*/
virtual bool IsAuxiliary() const
{ return GetType() == PARAM_ALGO && _param_algo_dim <= 0; }
protected: protected:
SMESH_Gen* _gen; SMESH_Gen* _gen;
int _studyId; int _studyId;

View File

@ -520,45 +520,62 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS
//purpose : //purpose :
//======================================================================= //=======================================================================
bool SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape, //================================================================================
/*!
* \brief Return hypothesis assigned to the shape
* \param aSubShape - the shape 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 TopoDS_Shape & aSubShape,
const SMESH_HypoFilter& aFilter, const SMESH_HypoFilter& aFilter,
list <const SMESHDS_Hypothesis * >& aHypList, list <const SMESHDS_Hypothesis * >& aHypList,
const bool andAncestors) const const bool andAncestors) const
{ {
int nbHyp = 0; set<string> hypTypes; // to exclude same type hypos from the result list
int nbHyps = 0;
// fill in hypTypes
list<const SMESHDS_Hypothesis*>::const_iterator hyp;
for ( hyp = aHypList.begin(); hyp != aHypList.end(); hyp++ )
if ( hypTypes.insert( (*hyp)->GetName() ).second )
nbHyps++;
// get hypos from aSubShape
{ {
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape); const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin(); for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
for ( ; hyp != hypList.end(); hyp++ ) if ( aFilter.IsOk (static_cast<const SMESH_Hypothesis*>( *hyp ), aSubShape) &&
if ( aFilter.IsOk (static_cast<const SMESH_Hypothesis*>( *hyp ), aSubShape)) { hypTypes.insert( (*hyp)->GetName() ).second )
{
aHypList.push_back( *hyp ); aHypList.push_back( *hyp );
nbHyp++; nbHyps++;
} }
} }
// get hypos from shape of one type only: if any hypo is found on edge, do
// not look up on faces // get hypos from ancestors of aSubShape
if ( !nbHyp && andAncestors ) if ( andAncestors )
{ {
TopTools_MapOfShape map; TopTools_MapOfShape map;
TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape )); TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
int shapeType = it.More() ? it.Value().ShapeType() : TopAbs_SHAPE;
for (; it.More(); it.Next() ) for (; it.More(); it.Next() )
{ {
if ( nbHyp && shapeType != it.Value().ShapeType() )
break;
shapeType = it.Value().ShapeType();
if ( !map.Add( it.Value() )) if ( !map.Add( it.Value() ))
continue; continue;
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value()); const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin(); for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
for ( ; hyp != hypList.end(); hyp++ ) if (aFilter.IsOk( static_cast<const SMESH_Hypothesis*>( *hyp ), it.Value() ) &&
if (aFilter.IsOk( static_cast<const SMESH_Hypothesis*>( *hyp ), it.Value() )) { hypTypes.insert( (*hyp)->GetName() ).second ) {
aHypList.push_back( *hyp ); aHypList.push_back( *hyp );
nbHyp++; nbHyps++;
} }
} }
} }
return nbHyp; return !aHypList.empty();
} }
//============================================================================= //=============================================================================
@ -690,14 +707,16 @@ throw(SALOME_Exception)
//======================================================================= //=======================================================================
bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp, bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
const TopoDS_Shape & aSubShape) const SMESH_subMesh* aSubMesh)
{ {
SMESH_Hypothesis* hyp = static_cast<SMESH_Hypothesis*>(anHyp); SMESH_Hypothesis* hyp = static_cast<SMESH_Hypothesis*>(anHyp);
// check if anHyp is applicable to aSubShape
SMESH_subMesh * subMesh = GetSubMeshContaining( aSubShape ); // check if anHyp can be used to mesh aSubMesh
if ( !subMesh || !subMesh->IsApplicableHypotesis( hyp )) if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp ))
return false; return false;
const TopoDS_Shape & aSubShape = const_cast<SMESH_subMesh*>( aSubMesh )->GetSubShape();
SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape ); SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape );
// algorithm // algorithm
@ -708,17 +727,19 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
if (algo) if (algo)
{ {
// look trough hypotheses used by algo // look trough hypotheses used by algo
const list <const SMESHDS_Hypothesis * >&usedHyps = SMESH_HypoFilter hypoKind;
algo->GetUsedHypothesis(*this, aSubShape); if ( algo->InitCompatibleHypoFilter( hypoKind, !hyp->IsAuxiliary() )) {
list <const SMESHDS_Hypothesis * > usedHyps;
if ( GetHypotheses( aSubShape, hypoKind, usedHyps, true ))
return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() ); return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() );
} }
}
// look through all assigned hypotheses // look through all assigned hypotheses
SMESH_HypoFilter filter( SMESH_HypoFilter::Is( hyp )); //SMESH_HypoFilter filter( SMESH_HypoFilter::Is( hyp ));
return GetHypothesis( aSubShape, filter, true ); return false; //GetHypothesis( aSubShape, filter, true );
} }
//============================================================================= //=============================================================================
/*! /*!
* *
@ -736,12 +757,70 @@ throw(SALOME_Exception)
for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++) for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
{ {
SMESH_subMesh *aSubMesh = (*itsm).second; SMESH_subMesh *aSubMesh = (*itsm).second;
if ( IsUsedHypothesis ( anHyp, aSubMesh->GetSubShape() )) if ( IsUsedHypothesis ( anHyp, aSubMesh ))
_subMeshesUsingHypothesisList.push_back(aSubMesh); _subMeshesUsingHypothesisList.push_back(aSubMesh);
} }
return _subMeshesUsingHypothesisList; return _subMeshesUsingHypothesisList;
} }
//=======================================================================
//function : NotifySubMeshesHypothesisModification
//purpose : Say all submeshes using theChangedHyp that it has been modified
//=======================================================================
void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* theChangedHyp)
{
Unexpect aCatch(SalomeException);
const SMESH_Hypothesis* hyp = static_cast<const SMESH_Hypothesis*>(theChangedHyp);
const SMESH_Algo *foundAlgo = 0;
SMESH_HypoFilter algoKind( SMESH_HypoFilter::IsAlgo() );
SMESH_HypoFilter compatibleHypoKind;
list <const SMESHDS_Hypothesis * > usedHyps;
map < int, SMESH_subMesh * >::iterator itsm;
for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
{
SMESH_subMesh *aSubMesh = (*itsm).second;
if ( aSubMesh->IsApplicableHypotesis( hyp ))
{
const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
if ( !foundAlgo ) // init filter for algo search
algoKind.And( algoKind.IsApplicableTo( aSubShape ));
const SMESH_Algo *algo = static_cast<const SMESH_Algo*>
( GetHypothesis( aSubShape, algoKind, true ));
if ( algo )
{
bool sameAlgo = ( algo == foundAlgo );
if ( !sameAlgo && foundAlgo )
sameAlgo = ( strcmp( algo->GetName(), foundAlgo->GetName() ) == 0);
if ( !sameAlgo ) { // init filter for used hypos search
if ( !algo->InitCompatibleHypoFilter( compatibleHypoKind, !hyp->IsAuxiliary() ))
continue; // algo does not use any hypothesis
foundAlgo = algo;
}
// check if hyp is used by algo
usedHyps.clear();
if ( GetHypotheses( aSubShape, compatibleHypoKind, usedHyps, true ) &&
find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() )
{
aSubMesh->ComputeStateEngine(SMESH_subMesh::MODIF_HYP);
if ( algo->GetDim() == 1 && IsPropagationHypothesis( aSubShape ))
CleanMeshOnPropagationChain( aSubShape );
}
}
}
}
}
//============================================================================= //=============================================================================
/*! /*!
* *

View File

@ -110,7 +110,7 @@ public:
const SMESH_HypoFilter& aFilter, const SMESH_HypoFilter& aFilter,
const bool andAncestors) const; const bool andAncestors) const;
bool GetHypotheses(const TopoDS_Shape & aSubShape, int GetHypotheses(const TopoDS_Shape & aSubShape,
const SMESH_HypoFilter& aFilter, const SMESH_HypoFilter& aFilter,
list <const SMESHDS_Hypothesis * >& aHypList, list <const SMESHDS_Hypothesis * >& aHypList,
const bool andAncestors) const; const bool andAncestors) const;
@ -134,12 +134,15 @@ public:
SMESH_subMesh *GetSubMeshContaining(const int aShapeID) SMESH_subMesh *GetSubMeshContaining(const int aShapeID)
throw(SALOME_Exception); throw(SALOME_Exception);
void NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* theChangedHyp);
// Say all submeshes that theChangedHyp has been modified
const list < SMESH_subMesh * >& const list < SMESH_subMesh * >&
GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp) GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
throw(SALOME_Exception); throw(SALOME_Exception);
bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp, bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
const TopoDS_Shape & aSubShape); const SMESH_subMesh * aSubMesh);
// Return True if anHyp is used to mesh aSubShape // Return True if anHyp is used to mesh aSubShape
bool IsNotConformAllowed() const; bool IsNotConformAllowed() const;

View File

@ -445,7 +445,7 @@ void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
*/ */
//============================================================================= //=============================================================================
const TopoDS_Shape & SMESH_subMesh::GetSubShape() const TopoDS_Shape & SMESH_subMesh::GetSubShape() const
{ {
//MESSAGE("SMESH_subMesh::GetSubShape"); //MESSAGE("SMESH_subMesh::GetSubShape");
return _subShape; return _subShape;
@ -554,7 +554,7 @@ SMESH_Hypothesis::Hypothesis_Status
if ( ! CanAddHypothesis( anHyp )) if ( ! CanAddHypothesis( anHyp ))
return SMESH_Hypothesis::HYP_BAD_DIM; return SMESH_Hypothesis::HYP_BAD_DIM;
if ( GetSimilarAttached( _subShape, anHyp ) ) if ( /*!anHyp->IsAuxiliary() &&*/ GetSimilarAttached( _subShape, anHyp ) )
return SMESH_Hypothesis::HYP_ALREADY_EXIST; return SMESH_Hypothesis::HYP_ALREADY_EXIST;
if ( !_meshDS->AddHypothesis(_subShape, anHyp)) if ( !_meshDS->AddHypothesis(_subShape, anHyp))
@ -563,9 +563,9 @@ SMESH_Hypothesis::Hypothesis_Status
// Serve Propagation of 1D hypothesis // Serve Propagation of 1D hypothesis
if (event == ADD_HYP) { if (event == ADD_HYP) {
bool isPropagationOk = true; bool isPropagationOk = true;
string hypName = anHyp->GetName(); bool isPropagationHyp = ( strcmp( "Propagation", anHyp->GetName() ) == 0 );
if (hypName == "Propagation") { if ( isPropagationHyp ) {
TopExp_Explorer exp (_subShape, TopAbs_EDGE); TopExp_Explorer exp (_subShape, TopAbs_EDGE);
TopTools_MapOfShape aMap; TopTools_MapOfShape aMap;
for (; exp.More(); exp.Next()) { for (; exp.More(); exp.Next()) {
@ -593,7 +593,11 @@ SMESH_Hypothesis::Hypothesis_Status
} else { } else {
} }
if (!isPropagationOk && ret < SMESH_Hypothesis::HYP_CONCURENT) { if ( isPropagationOk ) {
if ( isPropagationHyp )
return ret; // nothing more to do for "Propagation" hypothesis
}
else if ( ret < SMESH_Hypothesis::HYP_CONCURENT) {
ret = SMESH_Hypothesis::HYP_CONCURENT; ret = SMESH_Hypothesis::HYP_CONCURENT;
} }
} // Serve Propagation of 1D hypothesis } // Serve Propagation of 1D hypothesis
@ -612,7 +616,9 @@ SMESH_Hypothesis::Hypothesis_Status
{ {
bool isPropagationOk = true; bool isPropagationOk = true;
SMESH_HypoFilter propagFilter( SMESH_HypoFilter::HasName( "Propagation" )); SMESH_HypoFilter propagFilter( SMESH_HypoFilter::HasName( "Propagation" ));
if ( propagFilter.IsOk( anHyp, _subShape )) bool isPropagationHyp = propagFilter.IsOk( anHyp, _subShape );
if ( isPropagationHyp )
{ {
TopExp_Explorer exp (_subShape, TopAbs_EDGE); TopExp_Explorer exp (_subShape, TopAbs_EDGE);
TopTools_MapOfShape aMap; TopTools_MapOfShape aMap;
@ -634,7 +640,11 @@ SMESH_Hypothesis::Hypothesis_Status
isPropagationOk = _father->RebuildPropagationChains(); isPropagationOk = _father->RebuildPropagationChains();
} }
if (!isPropagationOk && ret < SMESH_Hypothesis::HYP_CONCURENT) { if ( isPropagationOk ) {
if ( isPropagationHyp )
return ret; // nothing more to do for "Propagation" hypothesis
}
else if ( ret < SMESH_Hypothesis::HYP_CONCURENT) {
ret = SMESH_Hypothesis::HYP_CONCURENT; ret = SMESH_Hypothesis::HYP_CONCURENT;
} }
} // Serve Propagation of 1D hypothesis } // Serve Propagation of 1D hypothesis
@ -712,7 +722,7 @@ SMESH_Hypothesis::Hypothesis_Status
SetAlgoState(HYP_OK); SetAlgoState(HYP_OK);
if (SMESH_Hypothesis::IsStatusFatal( ret )) if (SMESH_Hypothesis::IsStatusFatal( ret ))
_meshDS->RemoveHypothesis(_subShape, anHyp); _meshDS->RemoveHypothesis(_subShape, anHyp);
else if (!_father->IsUsedHypothesis( anHyp, _subShape )) else if (!_father->IsUsedHypothesis( anHyp, this ))
{ {
_meshDS->RemoveHypothesis(_subShape, anHyp); _meshDS->RemoveHypothesis(_subShape, anHyp);
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
@ -802,7 +812,7 @@ SMESH_Hypothesis::Hypothesis_Status
// ret should be fatal: anHyp was not added // ret should be fatal: anHyp was not added
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
} }
else if (!_father->IsUsedHypothesis( anHyp, _subShape )) else if (!_father->IsUsedHypothesis( anHyp, this ))
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
if (SMESH_Hypothesis::IsStatusFatal( ret )) if (SMESH_Hypothesis::IsStatusFatal( ret ))
@ -866,7 +876,7 @@ SMESH_Hypothesis::Hypothesis_Status
ASSERT(algo); ASSERT(algo);
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
{ {
if (_father->IsUsedHypothesis( anHyp, _subShape )) // new Hyp if (_father->IsUsedHypothesis( anHyp, this )) // new Hyp
modifiedHyp = true; modifiedHyp = true;
} }
else else
@ -1626,8 +1636,9 @@ TopoDS_Shape SMESH_subMesh::GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlg
if ( mainShape.IsSame( _subShape )) if ( mainShape.IsSame( _subShape ))
return _subShape; return _subShape;
const bool ignoreAuxiliaryHyps = false;
list<const SMESHDS_Hypothesis*> aUsedHyp = list<const SMESHDS_Hypothesis*> aUsedHyp =
theAlgo->GetUsedHypothesis( *_father, _subShape ); // copy theAlgo->GetUsedHypothesis( *_father, _subShape, ignoreAuxiliaryHyps ); // copy
// put in a compound all shapes with the same hypothesis assigned // put in a compound all shapes with the same hypothesis assigned
// and a good ComputState // and a good ComputState
@ -1645,7 +1656,7 @@ TopoDS_Shape SMESH_subMesh::GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlg
if (subMesh->GetComputeState() == READY_TO_COMPUTE && if (subMesh->GetComputeState() == READY_TO_COMPUTE &&
anAlgo == theAlgo && anAlgo == theAlgo &&
anAlgo->GetUsedHypothesis( *_father, S ) == aUsedHyp) anAlgo->GetUsedHypothesis( *_father, S, ignoreAuxiliaryHyps ) == aUsedHyp)
{ {
aBuilder.Add( aCompound, S ); aBuilder.Add( aCompound, S );
} }
@ -1656,26 +1667,31 @@ TopoDS_Shape SMESH_subMesh::GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlg
//======================================================================= //=======================================================================
//function : GetSimilarAttached //function : GetSimilarAttached
//purpose : return nb of hypotheses attached to theShape. //purpose : return a hypothesis attached to theShape.
// If theHyp is provided, similar but not same hypotheses // If theHyp is provided, similar but not same hypotheses
// are countered; else only applicable ones having theHypType // is returned; else only applicable ones having theHypType
// are countered // is returned
//======================================================================= //=======================================================================
const SMESH_Hypothesis* SMESH_subMesh::GetSimilarAttached(const TopoDS_Shape& theShape, const SMESH_Hypothesis* SMESH_subMesh::GetSimilarAttached(const TopoDS_Shape& theShape,
const SMESH_Hypothesis * theHyp, const SMESH_Hypothesis * theHyp,
const int theHypType) const int theHypType)
{ {
SMESH_HypoFilter filter; SMESH_HypoFilter hypoKind;
filter.Init( SMESH_HypoFilter::HasType( theHyp ? theHyp->GetType() : theHypType )); hypoKind.Init( hypoKind.HasType( theHyp ? theHyp->GetType() : theHypType ));
if ( theHyp ) { if ( theHyp ) {
filter.And( SMESH_HypoFilter::HasDim( theHyp->GetDim() )); hypoKind.And ( hypoKind.HasDim( theHyp->GetDim() ));
filter.AndNot( SMESH_HypoFilter::Is( theHyp )); hypoKind.AndNot( hypoKind.Is( theHyp ));
} if ( theHyp->IsAuxiliary() )
hypoKind.And( hypoKind.HasName( theHyp->GetName() ));
else else
filter.And( SMESH_HypoFilter::IsApplicableTo( theShape )); hypoKind.AndNot( hypoKind.IsAuxiliary());
}
else {
hypoKind.And( hypoKind.IsApplicableTo( theShape ));
}
return _father->GetHypothesis( theShape, filter, false ); return _father->GetHypothesis( theShape, hypoKind, false );
} }
//======================================================================= //=======================================================================

View File

@ -70,7 +70,7 @@ class SMESH_subMesh
const map < int, SMESH_subMesh * >&DependsOn(); const map < int, SMESH_subMesh * >&DependsOn();
//const map < int, SMESH_subMesh * >&Dependants(); //const map < int, SMESH_subMesh * >&Dependants();
const TopoDS_Shape & GetSubShape(); const TopoDS_Shape & GetSubShape() const;
// bool _vertexSet; // only for vertex subMesh, set to false for dim > 0 // bool _vertexSet; // only for vertex subMesh, set to false for dim > 0
@ -103,17 +103,13 @@ class SMESH_subMesh
SMESH_Hypothesis::Hypothesis_Status SMESH_Hypothesis::Hypothesis_Status
SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp); SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
int GetAlgoState() { return _algoState; } int GetAlgoState() const { return _algoState; }
int GetComputeState() const { return _computeState; };
void DumpAlgoState(bool isMain); void DumpAlgoState(bool isMain);
bool ComputeStateEngine(int event); bool ComputeStateEngine(int event);
int GetComputeState()
{
return _computeState;
};
bool IsConform(const SMESH_Algo* theAlgo); bool IsConform(const SMESH_Algo* theAlgo);
// check if a conform mesh will be produced by the Algo // check if a conform mesh will be produced by the Algo