mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-03-15 17:31:26 +05:00
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:
parent
261d5abd90
commit
0e55a67f3c
@ -45,7 +45,6 @@ SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen)
|
||||
// _compatibleHypothesis.push_back("hypothese_2D_bidon");
|
||||
_type = ALGO_2D;
|
||||
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()
|
||||
{
|
||||
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()) {
|
||||
const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
|
||||
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
|
||||
if(myCreateQuadratic)
|
||||
if(_quadraticMesh)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,6 @@ public:
|
||||
int NumberOfWires(const TopoDS_Shape& S);
|
||||
int NumberOfPoints(SMESH_Mesh& aMesh,const TopoDS_Wire& W);
|
||||
|
||||
protected:
|
||||
bool myCreateQuadratic;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -68,6 +68,7 @@ SMESH_Algo::SMESH_Algo(int hypId, int studyId,
|
||||
gen->_mapAlgo[hypId] = this;
|
||||
|
||||
_onlyUnaryInput = _requireDescretBoundary = true;
|
||||
_quadraticMesh = false;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -101,18 +102,17 @@ const vector < string > &SMESH_Algo::GetCompatibleHypothesis()
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
const list <const SMESHDS_Hypothesis *> & SMESH_Algo::GetUsedHypothesis(
|
||||
SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
|
||||
const list <const SMESHDS_Hypothesis *> &
|
||||
SMESH_Algo::GetUsedHypothesis(SMESH_Mesh & aMesh,
|
||||
const TopoDS_Shape & aShape,
|
||||
const bool ignoreAuxiliary)
|
||||
{
|
||||
_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 );
|
||||
if ( _usedHypList.size() > 1 )
|
||||
if ( ignoreAuxiliary && _usedHypList.size() > 1 )
|
||||
_usedHypList.clear(); //only one compatible hypothesis allowed
|
||||
}
|
||||
return _usedHypList;
|
||||
@ -126,18 +126,16 @@ const list <const SMESHDS_Hypothesis *> & SMESH_Algo::GetUsedHypothesis(
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
const list<const SMESHDS_Hypothesis *> & SMESH_Algo::GetAppliedHypothesis(
|
||||
SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
|
||||
const list<const SMESHDS_Hypothesis *> &
|
||||
SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh & aMesh,
|
||||
const TopoDS_Shape & aShape,
|
||||
const bool ignoreAuxiliary)
|
||||
{
|
||||
_appliedHypList.clear();
|
||||
if ( !_compatibleHypothesis.empty() )
|
||||
{
|
||||
SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( _compatibleHypothesis[0] ));
|
||||
for ( int i = 1; i < _compatibleHypothesis.size(); ++i )
|
||||
filter.Or( filter.HasName( _compatibleHypothesis[ i ] ));
|
||||
|
||||
SMESH_HypoFilter filter;
|
||||
if ( InitCompatibleHypoFilter( filter, ignoreAuxiliary ))
|
||||
aMesh.GetHypotheses( aShape, filter, _appliedHypList, false );
|
||||
}
|
||||
|
||||
return _appliedHypList;
|
||||
}
|
||||
|
||||
@ -267,3 +265,26 @@ bool SMESH_Algo::IsReversedSubMesh (const TopoDS_Face& theFace,
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
class SMESH_Gen;
|
||||
class SMESH_Mesh;
|
||||
class SMESH_HypoFilter;
|
||||
class TopoDS_Face;
|
||||
class SMESHDS_Mesh;
|
||||
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 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 *> &
|
||||
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);
|
||||
|
||||
|
||||
/*!
|
||||
* \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
|
||||
* \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 *> _usedHypList;
|
||||
|
||||
// quadratic mesh creation required
|
||||
bool _quadraticMesh;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -633,13 +633,14 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
|
||||
if ( algoList.empty() )
|
||||
return NULL;
|
||||
|
||||
if (algoList.size() > 1 ) { // check if there is one algo several times
|
||||
list <const SMESHDS_Hypothesis * >::iterator algo = algoList.begin();
|
||||
for ( ; algo != algoList.end(); ++algo )
|
||||
if ( (*algo) != algoList.front() &&
|
||||
(*algo)->GetName() != algoList.front()->GetName() )
|
||||
return NULL;
|
||||
}
|
||||
// Now it is checked in SMESH_Mesh::GetHypotheses()
|
||||
// if (algoList.size() > 1 ) { // check if there is one algo several times
|
||||
// list <const SMESHDS_Hypothesis * >::iterator algo = algoList.begin();
|
||||
// for ( ; algo != algoList.end(); ++algo )
|
||||
// if ( (*algo) != algoList.front() &&
|
||||
// (*algo)->GetName() != algoList.front()->GetName() )
|
||||
// return NULL;
|
||||
// }
|
||||
|
||||
return const_cast<SMESH_Algo*> ( static_cast<const SMESH_Algo* >( algoList.front() ));
|
||||
}
|
||||
|
@ -75,6 +75,17 @@ bool SMESH_HypoFilter::ApplicablePredicate::IsOk(const SMESH_Hypothesis* aHyp,
|
||||
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
|
||||
//purpose :
|
||||
@ -190,6 +201,17 @@ SMESH_HypoPredicate* SMESH_HypoFilter::IsAlgo()
|
||||
return new TypePredicate( MORE, SMESHDS_Hypothesis::PARAM_ALGO );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsAuxiliary
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SMESH_HypoPredicate* SMESH_HypoFilter::IsAuxiliary()
|
||||
{
|
||||
return new IsAuxiliaryPredicate();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsGlobal
|
||||
//purpose :
|
||||
|
@ -67,6 +67,7 @@ class SMESH_HypoFilter: public SMESH_HypoPredicate
|
||||
|
||||
// Create predicates
|
||||
static SMESH_HypoPredicate* IsAlgo();
|
||||
static SMESH_HypoPredicate* IsAuxiliary();
|
||||
static SMESH_HypoPredicate* IsApplicableTo(const TopoDS_Shape& theShape);
|
||||
static SMESH_HypoPredicate* IsAssignedTo(const TopoDS_Shape& theShape);
|
||||
static SMESH_HypoPredicate* Is(const SMESH_Hypothesis* theHypo);
|
||||
@ -158,6 +159,11 @@ class SMESH_HypoFilter: public SMESH_HypoPredicate
|
||||
const TopoDS_Shape& aShape) const;
|
||||
};
|
||||
|
||||
struct IsAuxiliaryPredicate : public SMESH_HypoPredicate {
|
||||
bool IsOk(const SMESH_Hypothesis* aHyp,
|
||||
const TopoDS_Shape& aShape) const;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -72,13 +72,14 @@ SMESH_Hypothesis::~SMESH_Hypothesis()
|
||||
|
||||
int SMESH_Hypothesis::GetDim() const
|
||||
{
|
||||
int dim = -1;
|
||||
int dim = 0;
|
||||
switch (_type)
|
||||
{
|
||||
case ALGO_1D: dim = 1; break;
|
||||
case ALGO_2D: dim = 2; 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;
|
||||
}
|
||||
@ -124,14 +125,15 @@ void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
|
||||
itm++)
|
||||
{
|
||||
SMESH_Mesh* mesh = (*itm).second;
|
||||
const list<SMESH_subMesh*>& subMeshes =
|
||||
mesh->GetSubMeshUsingHypothesis(this);
|
||||
mesh->NotifySubMeshesHypothesisModification( 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;
|
||||
for (its = subMeshes.begin(); its != subMeshes.end(); its++)
|
||||
(*its)->ComputeStateEngine(SMESH_subMesh::MODIF_HYP);
|
||||
// list<SMESH_subMesh*>::const_iterator its;
|
||||
// for (its = subMeshes.begin(); its != subMeshes.end(); its++)
|
||||
// (*its)->ComputeStateEngine(SMESH_subMesh::MODIF_HYP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,13 +54,24 @@ public:
|
||||
|
||||
SMESH_Hypothesis(int hypId, int studyId, SMESH_Gen* gen);
|
||||
virtual ~SMESH_Hypothesis();
|
||||
int GetDim() const;
|
||||
virtual int GetDim() const;
|
||||
int GetStudyId() const;
|
||||
void NotifySubMeshesHypothesisModification();
|
||||
int GetShapeType() const;
|
||||
const char* GetLibName() const;
|
||||
virtual void NotifySubMeshesHypothesisModification();
|
||||
virtual int GetShapeType() const;
|
||||
virtual const char* GetLibName() const;
|
||||
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:
|
||||
SMESH_Gen* _gen;
|
||||
int _studyId;
|
||||
|
@ -520,45 +520,62 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
bool SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
|
||||
const SMESH_HypoFilter& aFilter,
|
||||
list <const SMESHDS_Hypothesis * >& aHypList,
|
||||
const bool andAncestors) const
|
||||
//================================================================================
|
||||
/*!
|
||||
* \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,
|
||||
list <const SMESHDS_Hypothesis * >& aHypList,
|
||||
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);
|
||||
list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
|
||||
for ( ; hyp != hypList.end(); hyp++ )
|
||||
if ( aFilter.IsOk (static_cast<const SMESH_Hypothesis*>( *hyp ), aSubShape)) {
|
||||
for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
|
||||
if ( aFilter.IsOk (static_cast<const SMESH_Hypothesis*>( *hyp ), aSubShape) &&
|
||||
hypTypes.insert( (*hyp)->GetName() ).second )
|
||||
{
|
||||
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
|
||||
if ( !nbHyp && andAncestors )
|
||||
|
||||
// get hypos from ancestors of aSubShape
|
||||
if ( andAncestors )
|
||||
{
|
||||
TopTools_MapOfShape map;
|
||||
TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
|
||||
int shapeType = it.More() ? it.Value().ShapeType() : TopAbs_SHAPE;
|
||||
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;
|
||||
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
|
||||
list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
|
||||
for ( ; hyp != hypList.end(); hyp++ )
|
||||
if (aFilter.IsOk( static_cast<const SMESH_Hypothesis*>( *hyp ), it.Value() )) {
|
||||
aHypList.push_back( *hyp );
|
||||
nbHyp++;
|
||||
}
|
||||
for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
|
||||
if (aFilter.IsOk( static_cast<const SMESH_Hypothesis*>( *hyp ), it.Value() ) &&
|
||||
hypTypes.insert( (*hyp)->GetName() ).second ) {
|
||||
aHypList.push_back( *hyp );
|
||||
nbHyps++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nbHyp;
|
||||
return !aHypList.empty();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -690,15 +707,17 @@ throw(SALOME_Exception)
|
||||
//=======================================================================
|
||||
|
||||
bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
|
||||
const TopoDS_Shape & aSubShape)
|
||||
const SMESH_subMesh* aSubMesh)
|
||||
{
|
||||
SMESH_Hypothesis* hyp = static_cast<SMESH_Hypothesis*>(anHyp);
|
||||
// check if anHyp is applicable to aSubShape
|
||||
SMESH_subMesh * subMesh = GetSubMeshContaining( aSubShape );
|
||||
if ( !subMesh || !subMesh->IsApplicableHypotesis( hyp ))
|
||||
|
||||
// check if anHyp can be used to mesh aSubMesh
|
||||
if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp ))
|
||||
return false;
|
||||
|
||||
SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape);
|
||||
const TopoDS_Shape & aSubShape = const_cast<SMESH_subMesh*>( aSubMesh )->GetSubShape();
|
||||
|
||||
SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape );
|
||||
|
||||
// algorithm
|
||||
if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO)
|
||||
@ -708,17 +727,19 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
|
||||
if (algo)
|
||||
{
|
||||
// look trough hypotheses used by algo
|
||||
const list <const SMESHDS_Hypothesis * >&usedHyps =
|
||||
algo->GetUsedHypothesis(*this, aSubShape);
|
||||
return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() );
|
||||
SMESH_HypoFilter hypoKind;
|
||||
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() );
|
||||
}
|
||||
}
|
||||
|
||||
// look through all assigned hypotheses
|
||||
SMESH_HypoFilter filter( SMESH_HypoFilter::Is( hyp ));
|
||||
return GetHypothesis( aSubShape, filter, true );
|
||||
//SMESH_HypoFilter filter( SMESH_HypoFilter::Is( hyp ));
|
||||
return false; //GetHypothesis( aSubShape, filter, true );
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
@ -726,20 +747,78 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
|
||||
//=============================================================================
|
||||
|
||||
const list < SMESH_subMesh * >&
|
||||
SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
|
||||
throw(SALOME_Exception)
|
||||
SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
|
||||
throw(SALOME_Exception)
|
||||
{
|
||||
Unexpect aCatch(SalomeException);
|
||||
if(MYDEBUG) MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
|
||||
map < int, SMESH_subMesh * >::iterator itsm;
|
||||
_subMeshesUsingHypothesisList.clear();
|
||||
for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
|
||||
{
|
||||
SMESH_subMesh *aSubMesh = (*itsm).second;
|
||||
if ( IsUsedHypothesis ( anHyp, aSubMesh->GetSubShape() ))
|
||||
_subMeshesUsingHypothesisList.push_back(aSubMesh);
|
||||
}
|
||||
return _subMeshesUsingHypothesisList;
|
||||
if(MYDEBUG) MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
|
||||
map < int, SMESH_subMesh * >::iterator itsm;
|
||||
_subMeshesUsingHypothesisList.clear();
|
||||
for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
|
||||
{
|
||||
SMESH_subMesh *aSubMesh = (*itsm).second;
|
||||
if ( IsUsedHypothesis ( anHyp, aSubMesh ))
|
||||
_subMeshesUsingHypothesisList.push_back(aSubMesh);
|
||||
}
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -110,10 +110,10 @@ public:
|
||||
const SMESH_HypoFilter& aFilter,
|
||||
const bool andAncestors) const;
|
||||
|
||||
bool GetHypotheses(const TopoDS_Shape & aSubShape,
|
||||
const SMESH_HypoFilter& aFilter,
|
||||
list <const SMESHDS_Hypothesis * >& aHypList,
|
||||
const bool andAncestors) const;
|
||||
int GetHypotheses(const TopoDS_Shape & aSubShape,
|
||||
const SMESH_HypoFilter& aFilter,
|
||||
list <const SMESHDS_Hypothesis * >& aHypList,
|
||||
const bool andAncestors) const;
|
||||
|
||||
const list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);
|
||||
|
||||
@ -134,12 +134,15 @@ public:
|
||||
SMESH_subMesh *GetSubMeshContaining(const int aShapeID)
|
||||
throw(SALOME_Exception);
|
||||
|
||||
void NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* theChangedHyp);
|
||||
// Say all submeshes that theChangedHyp has been modified
|
||||
|
||||
const list < SMESH_subMesh * >&
|
||||
GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
|
||||
throw(SALOME_Exception);
|
||||
|
||||
bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
|
||||
const TopoDS_Shape & aSubShape);
|
||||
bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
|
||||
const SMESH_subMesh * aSubMesh);
|
||||
// Return True if anHyp is used to mesh aSubShape
|
||||
|
||||
bool IsNotConformAllowed() const;
|
||||
|
@ -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");
|
||||
return _subShape;
|
||||
@ -554,7 +554,7 @@ SMESH_Hypothesis::Hypothesis_Status
|
||||
if ( ! CanAddHypothesis( anHyp ))
|
||||
return SMESH_Hypothesis::HYP_BAD_DIM;
|
||||
|
||||
if ( GetSimilarAttached( _subShape, anHyp ) )
|
||||
if ( /*!anHyp->IsAuxiliary() &&*/ GetSimilarAttached( _subShape, anHyp ) )
|
||||
return SMESH_Hypothesis::HYP_ALREADY_EXIST;
|
||||
|
||||
if ( !_meshDS->AddHypothesis(_subShape, anHyp))
|
||||
@ -563,9 +563,9 @@ SMESH_Hypothesis::Hypothesis_Status
|
||||
// Serve Propagation of 1D hypothesis
|
||||
if (event == ADD_HYP) {
|
||||
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);
|
||||
TopTools_MapOfShape aMap;
|
||||
for (; exp.More(); exp.Next()) {
|
||||
@ -593,7 +593,11 @@ SMESH_Hypothesis::Hypothesis_Status
|
||||
} 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;
|
||||
}
|
||||
} // Serve Propagation of 1D hypothesis
|
||||
@ -612,7 +616,9 @@ SMESH_Hypothesis::Hypothesis_Status
|
||||
{
|
||||
bool isPropagationOk = true;
|
||||
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);
|
||||
TopTools_MapOfShape aMap;
|
||||
@ -634,7 +640,11 @@ SMESH_Hypothesis::Hypothesis_Status
|
||||
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;
|
||||
}
|
||||
} // Serve Propagation of 1D hypothesis
|
||||
@ -712,7 +722,7 @@ SMESH_Hypothesis::Hypothesis_Status
|
||||
SetAlgoState(HYP_OK);
|
||||
if (SMESH_Hypothesis::IsStatusFatal( ret ))
|
||||
_meshDS->RemoveHypothesis(_subShape, anHyp);
|
||||
else if (!_father->IsUsedHypothesis( anHyp, _subShape ))
|
||||
else if (!_father->IsUsedHypothesis( anHyp, this ))
|
||||
{
|
||||
_meshDS->RemoveHypothesis(_subShape, anHyp);
|
||||
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
|
||||
@ -802,7 +812,7 @@ SMESH_Hypothesis::Hypothesis_Status
|
||||
// ret should be fatal: anHyp was not added
|
||||
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
|
||||
}
|
||||
else if (!_father->IsUsedHypothesis( anHyp, _subShape ))
|
||||
else if (!_father->IsUsedHypothesis( anHyp, this ))
|
||||
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
|
||||
|
||||
if (SMESH_Hypothesis::IsStatusFatal( ret ))
|
||||
@ -866,7 +876,7 @@ SMESH_Hypothesis::Hypothesis_Status
|
||||
ASSERT(algo);
|
||||
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
|
||||
{
|
||||
if (_father->IsUsedHypothesis( anHyp, _subShape )) // new Hyp
|
||||
if (_father->IsUsedHypothesis( anHyp, this )) // new Hyp
|
||||
modifiedHyp = true;
|
||||
}
|
||||
else
|
||||
@ -1626,8 +1636,9 @@ TopoDS_Shape SMESH_subMesh::GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlg
|
||||
if ( mainShape.IsSame( _subShape ))
|
||||
return _subShape;
|
||||
|
||||
const bool ignoreAuxiliaryHyps = false;
|
||||
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
|
||||
// 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 &&
|
||||
anAlgo == theAlgo &&
|
||||
anAlgo->GetUsedHypothesis( *_father, S ) == aUsedHyp)
|
||||
anAlgo->GetUsedHypothesis( *_father, S, ignoreAuxiliaryHyps ) == aUsedHyp)
|
||||
{
|
||||
aBuilder.Add( aCompound, S );
|
||||
}
|
||||
@ -1656,26 +1667,31 @@ TopoDS_Shape SMESH_subMesh::GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlg
|
||||
|
||||
//=======================================================================
|
||||
//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
|
||||
// are countered; else only applicable ones having theHypType
|
||||
// are countered
|
||||
// is returned; else only applicable ones having theHypType
|
||||
// is returned
|
||||
//=======================================================================
|
||||
|
||||
const SMESH_Hypothesis* SMESH_subMesh::GetSimilarAttached(const TopoDS_Shape& theShape,
|
||||
const SMESH_Hypothesis * theHyp,
|
||||
const int theHypType)
|
||||
{
|
||||
SMESH_HypoFilter filter;
|
||||
filter.Init( SMESH_HypoFilter::HasType( theHyp ? theHyp->GetType() : theHypType ));
|
||||
SMESH_HypoFilter hypoKind;
|
||||
hypoKind.Init( hypoKind.HasType( theHyp ? theHyp->GetType() : theHypType ));
|
||||
if ( theHyp ) {
|
||||
filter.And( SMESH_HypoFilter::HasDim( theHyp->GetDim() ));
|
||||
filter.AndNot( SMESH_HypoFilter::Is( theHyp ));
|
||||
hypoKind.And ( hypoKind.HasDim( theHyp->GetDim() ));
|
||||
hypoKind.AndNot( hypoKind.Is( theHyp ));
|
||||
if ( theHyp->IsAuxiliary() )
|
||||
hypoKind.And( hypoKind.HasName( theHyp->GetName() ));
|
||||
else
|
||||
hypoKind.AndNot( hypoKind.IsAuxiliary());
|
||||
}
|
||||
else {
|
||||
hypoKind.And( hypoKind.IsApplicableTo( theShape ));
|
||||
}
|
||||
else
|
||||
filter.And( SMESH_HypoFilter::IsApplicableTo( theShape ));
|
||||
|
||||
return _father->GetHypothesis( theShape, filter, false );
|
||||
return _father->GetHypothesis( theShape, hypoKind, false );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -70,7 +70,7 @@ class SMESH_subMesh
|
||||
const map < int, SMESH_subMesh * >&DependsOn();
|
||||
//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
|
||||
|
||||
@ -103,17 +103,13 @@ class SMESH_subMesh
|
||||
SMESH_Hypothesis::Hypothesis_Status
|
||||
SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
|
||||
|
||||
int GetAlgoState() { return _algoState; }
|
||||
int GetAlgoState() const { return _algoState; }
|
||||
int GetComputeState() const { return _computeState; };
|
||||
|
||||
void DumpAlgoState(bool isMain);
|
||||
|
||||
bool ComputeStateEngine(int event);
|
||||
|
||||
int GetComputeState()
|
||||
{
|
||||
return _computeState;
|
||||
};
|
||||
|
||||
bool IsConform(const SMESH_Algo* theAlgo);
|
||||
// check if a conform mesh will be produced by the Algo
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user