Version: 8.3.0
SMESH_subMesh Class Reference

#include <SMESH_subMesh.hxx>

Data Structures

struct  OwnListenerData
 

Public Types

enum  compute_state { NOT_READY, READY_TO_COMPUTE, COMPUTE_OK, FAILED_TO_COMPUTE }
 
enum  algo_state { NO_ALGO, MISSING_HYP, HYP_OK }
 
enum  algo_event {
  ADD_HYP, ADD_ALGO, REMOVE_HYP, REMOVE_ALGO,
  ADD_FATHER_HYP, ADD_FATHER_ALGO, REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO,
  MODIF_HYP
}
 
enum  compute_event {
  MODIF_ALGO_STATE, COMPUTE, COMPUTE_SUBMESH, COMPUTE_NOGEOM,
  COMPUTE_CANCELED, CLEAN, SUBMESH_COMPUTED, SUBMESH_RESTORED,
  SUBMESH_LOADED, MESH_ENTITY_REMOVED, CHECK_COMPUTE_STATE
}
 
enum  event_type { ALGO_EVENT, COMPUTE_EVENT }
 

Public Member Functions

 SMESH_subMesh (int Id, SMESH_Mesh *father, SMESHDS_Mesh *meshDS, const TopoDS_Shape &aSubShape)
 default constructor: More...
 
virtual ~SMESH_subMesh ()
 
int GetId () const
 
SMESH_MeshGetFather ()
 
SMESHDS_SubMeshGetSubMeshDS ()
 
const SMESHDS_SubMeshGetSubMeshDS () const
 
SMESHDS_SubMeshCreateSubMeshDS ()
 
SMESH_subMeshGetFirstToCompute ()
 
SMESH_AlgoGetAlgo () const
 Returns a current algorithm. More...
 
const std::map< int,
SMESH_subMesh * > & 
DependsOn ()
 Returns all sub-meshes this one depend on. More...
 
bool DependsOn (const SMESH_subMesh *other) const
 
bool DependsOn (const int shapeID) const
 
SMESH_subMeshIteratorPtr getDependsOnIterator (const bool includeSelf, const bool complexShapeFirst=false) const
 Return iterator on the sub-meshes this one depends on. More...
 
const std::vector
< SMESH_subMesh * > & 
GetAncestors () const
 Returns ancestor sub-meshes. More...
 
void ClearAncestors ()
 Clears the vector of ancestor sub-meshes. More...
 
const TopoDS_Shape & GetSubShape () const
 
void SetEventListener (EventListener *listener, EventListenerData *data, SMESH_subMesh *where)
 Sets an event listener and its data to a submesh. More...
 
EventListenerDataGetEventListenerData (EventListener *listener, const bool myOwn=false) const
 Return an event listener data. More...
 
EventListenerDataGetEventListenerData (const std::string &listenerName, const bool myOwn=false) const
 Return an event listener data. More...
 
void DeleteEventListener (EventListener *listener)
 Unregister the listener and delete it and it's data. More...
 
SMESH_Hypothesis::Hypothesis_Status AlgoStateEngine (algo_event event, SMESH_Hypothesis *anHyp)
 Treats modification of hypotheses definition. More...
 
SMESH_Hypothesis::Hypothesis_Status SubMeshesAlgoStateEngine (algo_event event, SMESH_Hypothesis *anHyp, bool exitOnFatal=false)
 Send an event to sub-meshes. More...
 
algo_state GetAlgoState () const
 
compute_state GetComputeState () const
 
SMESH_ComputeErrorPtrGetComputeError ()
 
void DumpAlgoState (bool isMain)
 
bool ComputeStateEngine (compute_event event)
 
void ComputeSubMeshStateEngine (compute_event event, const bool includeSelf=false)
 
bool Evaluate (MapShapeNbElems &aResMap)
 
bool IsConform (const SMESH_Algo *theAlgo)
 
bool CanAddHypothesis (const SMESH_Hypothesis *theHypothesis) const
 
bool IsApplicableHypotesis (const SMESH_Hypothesis *theHypothesis) const
 
SMESH_Hypothesis::Hypothesis_Status CheckConcurentHypothesis (const int theHypType)
 
bool IsEmpty () const
 Return true if no mesh entities is bound to the submesh. More...
 
bool IsMeshComputed () const
 
void SetIsAlwaysComputed (bool isAlCo)
 Allow algo->Compute() if a subshape of lower dim is meshed but none mesh entity is bound to it. More...
 
bool IsAlwaysComputed ()
 
bool SubMeshesComputed (bool *isFailedToCompute=0) const
 Return true if all sub-meshes have been meshed. More...
 
int GetComputeCost () const
 Return cost of computing this sub-mesh. More...
 
bool FindIntersection (const SMESH_subMesh *theOther, std::set< const SMESH_subMesh * > &theSetOfCommon) const
 Find common submeshes (based on shared subshapes with other. More...
 

Static Public Member Functions

static bool IsApplicableHypotesis (const SMESH_Hypothesis *theHypothesis, const TopAbs_ShapeEnum theShapeType)
 

Protected Member Functions

void setEventListener (EventListener *listener, EventListenerData *data)
 Sets an event listener and its data to a submesh. More...
 
void notifyListenersOnEvent (const int event, const event_type eventType, SMESH_Hypothesis *hyp=0)
 Notify stored event listeners on the occurred event. More...
 
void deleteOwnListeners ()
 Delete event listeners depending on algo of this submesh. More...
 
void loadDependentMeshes ()
 loads dependent meshes on SUBMESH_LOADED event More...
 
void insertDependence (const TopoDS_Shape aShape, TopAbs_ShapeEnum aSubType, TopAbs_ShapeEnum avoidType=TopAbs_SHAPE)
 Add sub-meshes on sub-shapes of a given type into the dependence map. More...
 
void removeSubMeshElementsAndNodes ()
 
void updateDependantsState (const compute_event theEvent)
 
void updateSubMeshState (const compute_state theState)
 
void cleanDependants ()
 
void cleanDependsOn (SMESH_Algo *algoRequiringCleaning=0)
 Remove elements from sub-meshes. More...
 
void setAlgoState (algo_state state)
 
TopoDS_Shape getCollection (SMESH_Gen *theGen, SMESH_Algo *theAlgo, bool &theSubComputed, bool &theSubFailed, std::vector< SMESH_subMesh * > &theSubs)
 Return a shape containing all sub-shapes of the MainShape that can be meshed at once along with _subShape. More...
 
bool checkComputeError (SMESH_Algo *theAlgo, const bool theComputeOK, const TopoDS_Shape &theShape=TopoDS_Shape())
 Update compute_state by _computeError. More...
 
const SMESH_HypothesisgetSimilarAttached (const TopoDS_Shape &theShape, const SMESH_Hypothesis *theHyp, const int theHypType=0)
 Return a hypothesis attached to theShape. More...
 
int computeCost () const
 Return cost of computing this sub-mesh. More...
 

Protected Attributes

std::map< EventListener
*, EventListenerData * > 
_eventListeners
 < event listeners to notify More...
 
std::list< OwnListenerData_ownListeners
 
TopoDS_Shape _subShape
 
SMESHDS_SubMesh_subMeshDS
 
SMESH_Mesh_father
 
int _Id
 
std::map< int, SMESH_subMesh * > _mapDepend
 
bool _dependenceAnalysed
 
std::vector< SMESH_subMesh * > _ancestors
 
SMESH_Algo_algo
 
algo_state _algoState
 
compute_state _computeState
 
SMESH_ComputeErrorPtr _computeError
 
int _computeCost
 
int _realComputeCost
 
bool _alwaysComputed
 

Member Enumeration Documentation

Enumerator
ADD_HYP 
ADD_ALGO 
REMOVE_HYP 
REMOVE_ALGO 
ADD_FATHER_HYP 
ADD_FATHER_ALGO 
REMOVE_FATHER_HYP 
REMOVE_FATHER_ALGO 
MODIF_HYP 
Enumerator
NO_ALGO 
MISSING_HYP 
HYP_OK 
Enumerator
MODIF_ALGO_STATE 
COMPUTE 
COMPUTE_SUBMESH 
COMPUTE_NOGEOM 
COMPUTE_CANCELED 
CLEAN 
SUBMESH_COMPUTED 
SUBMESH_RESTORED 
SUBMESH_LOADED 
MESH_ENTITY_REMOVED 
CHECK_COMPUTE_STATE 
Enumerator
NOT_READY 
READY_TO_COMPUTE 
COMPUTE_OK 
FAILED_TO_COMPUTE 
Enumerator
ALGO_EVENT 
COMPUTE_EVENT 

Constructor & Destructor Documentation

SMESH_subMesh::SMESH_subMesh ( int  Id,
SMESH_Mesh father,
SMESHDS_Mesh meshDS,
const TopoDS_Shape &  aSubShape 
)

default constructor:

References SMESH::HYP_OK, and SMESHDS_Mesh::MeshElements().

Referenced by GetAncestors(), and getDependsOnIterator().

SMESH_subMesh::~SMESH_subMesh ( )
virtual

Member Function Documentation

bool SMESH_subMesh::CanAddHypothesis ( const SMESH_Hypothesis theHypothesis) const
bool SMESH_subMesh::checkComputeError ( SMESH_Algo theAlgo,
const bool  theComputeOK,
const TopoDS_Shape &  theShape = TopoDS_Shape() 
)
protected

Update compute_state by _computeError.

Update compute_state by _computeError and send proper events to dependent submeshes.

Return values
bool- false if there are errors
bool- true if _computeError is NOT set

References COMPERR_NO_MESH_ON_SHAPE, Edge, SMESH_Algo::isDegenerated(), and SMESH_ComputeError::New().

SMESH_Hypothesis::Hypothesis_Status SMESH_subMesh::CheckConcurentHypothesis ( const int  theHypType)
void SMESH_subMesh::cleanDependants ( )
protected
void SMESH_subMesh::cleanDependsOn ( SMESH_Algo algoRequiringCleaning = 0)
protected

Remove elements from sub-meshes.

Parameters
algoRequiringCleaning- an all-dimensional algorithm whose presence causes the cleaning.

References SMESH_HypoFilter::And(), SMESH_Gen::GetShapeDim(), SMESH_MesherHelper::GetShapeOfHypothesis(), SMESH_HypoFilter::Init(), SMESH_HypoFilter::IsAlgo(), and SMESH_HypoFilter::IsMoreLocalThan().

void SMESH_subMesh::ClearAncestors ( )

Clears the vector of ancestor sub-meshes.

References _ancestors.

int SMESH_subMesh::computeCost ( ) const
protected

Return cost of computing this sub-mesh.

The cost depends on the shape type and number of sub-meshes this one DependsOn().

Returns
int - the computation cost in abstract units.
void SMESH_subMesh::ComputeSubMeshStateEngine ( compute_event  event,
const bool  includeSelf = false 
)
SMESHDS_SubMesh * SMESH_subMesh::CreateSubMeshDS ( )
void SMESH_subMesh::DeleteEventListener ( EventListener listener)

Unregister the listener and delete it and it's data.

Unregister the listener and delete listener's data.

Parameters
listener- the event listener to delete
listener- the event listener

References _eventListeners.

void SMESH_subMesh::deleteOwnListeners ( )
protected

Delete event listeners depending on algo of this submesh.

References _father, _ownListeners, and MESHCUT::d.

const map< int, SMESH_subMesh * > & SMESH_subMesh::DependsOn ( )

Returns all sub-meshes this one depend on.

bool SMESH_subMesh::DependsOn ( const SMESH_subMesh other) const
bool SMESH_subMesh::DependsOn ( const int  shapeID) const
void SMESH_subMesh::DumpAlgoState ( bool  isMain)
bool SMESH_subMesh::FindIntersection ( const SMESH_subMesh theOther,
std::set< const SMESH_subMesh * > &  theSetOfCommon 
) const

Find common submeshes (based on shared subshapes with other.

Find common submeshes (based on shared sub-shapes with other.

Parameters
theOthersubmesh to check
theCommonIdsset of common submesh IDs NOTE: this method does not cleat set before collect common IDs
theOthersubmesh to check
theSetOfCommonset of common submesh

References _mapDepend.

SMESH_Algo * SMESH_subMesh::GetAlgo ( ) const

Returns a current algorithm.

References me.

algo_state SMESH_subMesh::GetAlgoState ( ) const
const std::vector< SMESH_subMesh * > & SMESH_subMesh::GetAncestors ( ) const

Returns ancestor sub-meshes.

Finds them if not yet found.

References _ancestors, _father, _subShape, me, and SMESH_subMesh().

TopoDS_Shape SMESH_subMesh::getCollection ( SMESH_Gen theGen,
SMESH_Algo theAlgo,
bool theSubComputed,
bool theSubFailed,
std::vector< SMESH_subMesh * > &  theSubs 
)
protected

Return a shape containing all sub-shapes of the MainShape that can be meshed at once along with _subShape.

int SMESH_subMesh::GetComputeCost ( ) const

Return cost of computing this sub-mesh.

If hypotheses are not well defined, zero is returned

Returns
int - the computation cost in abstract units.
SMESH_ComputeErrorPtr& SMESH_subMesh::GetComputeError ( )
compute_state SMESH_subMesh::GetComputeState ( ) const
SMESH_subMeshIteratorPtr SMESH_subMesh::getDependsOnIterator ( const bool  includeSelf,
const bool  reverse = false 
) const

Return iterator on the sub-meshes this one depends on.

Return iterator on the submeshes this one depends on.

By default most simple sub-meshes go first.

Parameters
includeSelf- this submesh to be returned also
reverse- if true, complex shape submeshes go first

References me, and SMESH_subMesh().

EventListenerData* SMESH_subMesh::GetEventListenerData ( EventListener listener,
const bool  myOwn = false 
) const

Return an event listener data.

Parameters
listener- the listener whose data is
myOwn- if true, returns a listener set by this sub-mesh, else returns a listener listening to events of this sub-mesh
Return values
EventListenerData*- found data, maybe NULL

Referenced by VISCOUS_3D::ToClearSubWithMain().

EventListenerData* SMESH_subMesh::GetEventListenerData ( const std::string &  listenerName,
const bool  myOwn = false 
) const

Return an event listener data.

Parameters
listenerName- the listener name
myOwn- if true, returns a listener set by this sub-mesh, else returns a listener listening to events of this sub-mesh
Return values
EventListenerData*- found data, maybe NULL
SMESH_Mesh* SMESH_subMesh::GetFather ( )
SMESH_subMesh * SMESH_subMesh::GetFirstToCompute ( )
int SMESH_subMesh::GetId ( ) const
const SMESH_Hypothesis * SMESH_subMesh::getSimilarAttached ( const TopoDS_Shape &  theShape,
const SMESH_Hypothesis theHyp,
const int  theHypType = 0 
)
protected

Return a hypothesis attached to theShape.

If theHyp is provided, similar but not same hypotheses is returned; else an applicable ones having theHypType is returned

References SMESH_HypoFilter::And(), SMESH_HypoFilter::AndNot(), SMESH_HypoFilter::HasDim(), SMESH_HypoFilter::HasName(), SMESH_HypoFilter::HasType(), SMESH_HypoFilter::Init(), SMESH_HypoFilter::Is(), SMESH_HypoFilter::IsApplicableTo(), and SMESH_HypoFilter::IsAuxiliary().

SMESHDS_SubMesh * SMESH_subMesh::GetSubMeshDS ( )
const SMESHDS_SubMesh* SMESH_subMesh::GetSubMeshDS ( ) const
const TopoDS_Shape& SMESH_subMesh::GetSubShape ( ) const
void SMESH_subMesh::insertDependence ( const TopoDS_Shape  aShape,
TopAbs_ShapeEnum  aSubType,
TopAbs_ShapeEnum  avoidType = TopAbs_SHAPE 
)
protected

Add sub-meshes on sub-shapes of a given type into the dependence map.

bool SMESH_subMesh::IsAlwaysComputed ( )
bool SMESH_subMesh::IsApplicableHypotesis ( const SMESH_Hypothesis theHypothesis,
const TopAbs_ShapeEnum  theShapeType 
)
static
bool SMESH_subMesh::IsApplicableHypotesis ( const SMESH_Hypothesis theHypothesis) const
bool SMESH_subMesh::IsConform ( const SMESH_Algo theAlgo)
bool SMESH_subMesh::IsEmpty ( ) const

Return true if no mesh entities is bound to the submesh.

bool SMESH_subMesh::IsMeshComputed ( ) const
void SMESH_subMesh::loadDependentMeshes ( )
protected

loads dependent meshes on SUBMESH_LOADED event

References _father, _ownListeners, and MESHCUT::d.

void SMESH_subMesh::notifyListenersOnEvent ( const int  event,
const event_type  eventType,
SMESH_Hypothesis hyp = 0 
)
protected

Notify stored event listeners on the occurred event.

Parameters
event- algo_event or compute_event itself
eventType- algo_event or compute_event
hyp- hypothesis, if eventType is algo_event

References _eventListeners.

void SMESH_subMesh::removeSubMeshElementsAndNodes ( )
protected
void SMESH_subMesh::setAlgoState ( algo_state  state)
protected
void SMESH_subMesh::SetEventListener ( EventListener listener,
EventListenerData data,
SMESH_subMesh where 
)

Sets an event listener and its data to a submesh.

Parameters
listener- the listener to store
data- the listener data to store
where- the submesh to store the listener and it's data

The method remembers the submesh it puts the listener in order to delete it when HYP_OK algo_state is lost After being set, event listener is notified on each event of submesh.

Parameters
listener- the listener to store
data- the listener data to store
where- the submesh to store the listener and it's data

It remembers the submesh where it puts the listener in order to delete them when HYP_OK algo_state is lost After being set, event listener is notified on each event of where submesh.

References _ownListeners.

Referenced by VISCOUS_3D::ToClearSubWithMain().

void SMESH_subMesh::setEventListener ( EventListener listener,
EventListenerData data 
)
protected

Sets an event listener and its data to a submesh.

Parameters
listener- the listener to store
data- the listener data to store

After being set, event listener is notified on each event of a submesh.

References _eventListeners, SMESH_subMeshEventListener::GetName(), and SMESH_subMeshEventListenerData::IsDeletable().

void SMESH_subMesh::SetIsAlwaysComputed ( bool  isAlCo)

Allow algo->Compute() if a subshape of lower dim is meshed but none mesh entity is bound to it.

Allow algo->Compute() if a sub-shape of lower dim is meshed but none mesh entity is bound to it (PAL13615, 2nd part)

Referenced by StdMeshers_UseExisting_2D::Compute(), and StdMeshers_UseExisting_1D::Compute().

SMESH_Hypothesis::Hypothesis_Status SMESH_subMesh::SubMeshesAlgoStateEngine ( algo_event  event,
SMESH_Hypothesis anHyp,
bool  exitOnFatal = false 
)

Send an event to sub-meshes.

Parameters
[in]event- the event
[in]anHyp- an hypothesis
[in]exitOnFatal- to stop iteration on sub-meshes if a sub-mesh reports a fatal result
Returns
SMESH_Hypothesis::Hypothesis_Status - the worst result

Optional description of a problematic situation (if any) can be retrieved via GetComputeError().

References SMESH_Hypothesis::HYP_OK, and SMESH_Hypothesis::IsStatusFatal().

bool SMESH_subMesh::SubMeshesComputed ( bool isFailedToCompute = 0) const

Return true if all sub-meshes have been meshed.

References SMESH_Gen::GetShapeDim(), SMESHDS_SubMesh::NbElements(), and SMESHDS_SubMesh::NbNodes().

void SMESH_subMesh::updateDependantsState ( const compute_event  theEvent)
protected
void SMESH_subMesh::updateSubMeshState ( const compute_state  theState)
protected

Field Documentation

SMESH_Algo* SMESH_subMesh::_algo
protected
algo_state SMESH_subMesh::_algoState
protected
bool SMESH_subMesh::_alwaysComputed
protected
std::vector< SMESH_subMesh * > SMESH_subMesh::_ancestors
protected

Referenced by ClearAncestors(), and GetAncestors().

int SMESH_subMesh::_computeCost
protected
SMESH_ComputeErrorPtr SMESH_subMesh::_computeError
protected
compute_state SMESH_subMesh::_computeState
protected
bool SMESH_subMesh::_dependenceAnalysed
protected
std::map< EventListener*, EventListenerData* > SMESH_subMesh::_eventListeners
protected

< event listeners to notify

event listeners to delete when HYP_OK algo_state is lost

Referenced by DeleteEventListener(), notifyListenersOnEvent(), and setEventListener().

SMESH_Mesh* SMESH_subMesh::_father
protected
int SMESH_subMesh::_Id
protected
std::map< int, SMESH_subMesh * > SMESH_subMesh::_mapDepend
protected

Referenced by FindIntersection().

std::list< OwnListenerData > SMESH_subMesh::_ownListeners
protected
int SMESH_subMesh::_realComputeCost
protected
SMESHDS_SubMesh* SMESH_subMesh::_subMeshDS
protected
TopoDS_Shape SMESH_subMesh::_subShape
protected

Referenced by GetAncestors().