SALOME - SMESH
SMESH_subMesh.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // SMESH SMESH : implementaion of SMESH idl descriptions
23 // File : SMESH_subMesh.hxx
24 // Author : Paul RASCLE, EDF
25 // Module : SMESH
26 //
27 #ifndef _SMESH_SUBMESH_HXX_
28 #define _SMESH_SUBMESH_HXX_
29 
30 #include "SMESH_SMESH.hxx"
31 
32 #include "SMESHDS_Mesh.hxx"
33 #include "SMESHDS_SubMesh.hxx"
34 #include "SMESH_Hypothesis.hxx"
35 #include "SMESH_ComputeError.hxx"
36 #include "SMESH_Algo.hxx"
37 
39 
40 #include <TopoDS_Shape.hxx>
41 
42 #include <list>
43 #include <map>
44 
45 class SMESH_Mesh;
46 class SMESH_Hypothesis;
47 class SMESH_Algo;
48 class SMESH_Gen;
51 class SMESH_subMesh;
52 
55 
56 typedef boost::shared_ptr< SMDS_Iterator<SMESH_subMesh*> > SMESH_subMeshIteratorPtr;
57 
58 
60 {
61  public:
62  SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
63  const TopoDS_Shape & aSubShape);
64  virtual ~ SMESH_subMesh();
65 
66  int GetId() const;
67 
68  SMESH_Mesh* GetFather() { return _father; }
69 
71 
73  // Explicit SMESHDS_SubMesh creation method, required for persistence mechanism
74 
76 
77  const std::map < int, SMESH_subMesh * >& DependsOn();
78  //const map < int, SMESH_subMesh * >&Dependants();
83  const bool complexShapeFirst);
84 
85  const TopoDS_Shape & GetSubShape() const;
86 
88  {
89  NOT_READY, READY_TO_COMPUTE,
90  COMPUTE_OK, FAILED_TO_COMPUTE
91  };
93  {
94  NO_ALGO, MISSING_HYP, HYP_OK
95  };
97  {
98  ADD_HYP , ADD_ALGO,
99  REMOVE_HYP , REMOVE_ALGO,
100  ADD_FATHER_HYP , ADD_FATHER_ALGO,
101  REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO,
102  MODIF_HYP
103  };
105  {
107  CLEAN, SUBMESH_COMPUTED, SUBMESH_RESTORED,
108  MESH_ENTITY_REMOVED, CHECK_COMPUTE_STATE
109  };
111  {
112  ALGO_EVENT, COMPUTE_EVENT
113  };
114 
115  // ==================================================================
116  // Members to track non hierarchical dependencies between submeshes
117  // ==================================================================
118 
130  EventListenerData* data,
131  SMESH_subMesh* where);
132 
139 
145 
146 protected:
147 
149  std::map< EventListener*, EventListenerData* > myEventListeners;
151  std::list< std::pair< SMESH_subMesh*, EventListener* > > myOwnListeners;
152 
161 
168  void NotifyListenersOnEvent( const int event,
169  const event_type eventType,
170  SMESH_Hypothesis* hyp = 0);
171 
176 
177  // ==================================================================
178 
179 public:
180 
182  AlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
183 
186 
187  int GetAlgoState() const { return _algoState; }
188  int GetComputeState() const { return _computeState; };
189  SMESH_ComputeErrorPtr& GetComputeError() { return _computeError; }
190 
191  void DumpAlgoState(bool isMain);
192 
193  bool ComputeStateEngine(int event);
194 
195  bool Evaluate(MapShapeNbElems& aResMap);
196 
197  bool IsConform(const SMESH_Algo* theAlgo);
198  // check if a conform mesh will be produced by the Algo
199 
200  bool CanAddHypothesis(const SMESH_Hypothesis* theHypothesis) const;
201  // return true if theHypothesis can be attached to me:
202  // its dimention is checked
203 
204  static bool IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis,
205  const TopAbs_ShapeEnum theShapeType);
206 
207  bool IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis) const
208  { return IsApplicableHypotesis( theHypothesis, _subShape.ShapeType() ); }
209  // return true if theHypothesis can be used to mesh me:
210  // its shape type is checked
211 
213  // check if there are several applicable hypothesis on fathers
214 
218  bool IsEmpty() const;
219 
220  bool IsMeshComputed() const;
221  // check if _subMeshDS contains mesh elements
222 
227  void SetIsAlwaysComputed(bool isAlCo);
228  bool IsAlwaysComputed() { return _alwaysComputed; }
229 
230 
231 protected:
232  // ==================================================================
233  void InsertDependence(const TopoDS_Shape aSubShape);
234 
236 
238 
240  void UpdateDependantsState(const compute_event theEvent);
241  void UpdateSubMeshState(const compute_state theState);
242  void ComputeSubMeshStateEngine(int event);
245  void SetAlgoState(int state);
246 
251  TopoDS_Shape GetCollection(SMESH_Gen * theGen,
252  SMESH_Algo* theAlgo,
253  bool & theSubComputed);
254 
259  const TopoDS_Shape& theCollection);
260 
265  bool CheckComputeError(SMESH_Algo* theAlgo, const TopoDS_Shape& theShape=TopoDS_Shape());
266 
274  const SMESH_Hypothesis* GetSimilarAttached(const TopoDS_Shape& theShape,
275  const SMESH_Hypothesis * theHyp,
276  const int theHypType = 0);
277  //
278 
279 protected:
280 
281  TopoDS_Shape _subShape;
284  int _Id;
285 
286  std::map < int, SMESH_subMesh * >_mapDepend;
288 
292 
293  // allow algo->Compute() if a subshape of lower dim is meshed but
294  // none mesh entity is bound to it. Eg StdMeshers_CompositeSegment_1D can
295  // mesh several edges as a whole and leave some of them without mesh entities
297 
298 };
299 
300 #endif
SMESH_ComputeError.hxx
SMESH_subMesh::SMESH_subMesh
SMESH_subMesh(int Id, SMESH_Mesh *father, SMESHDS_Mesh *meshDS, const TopoDS_Shape &aSubShape)
SMESH_subMesh::_computeError
SMESH_ComputeErrorPtr _computeError
Definition: SMESH_subMesh.hxx:291
SMESH_subMeshIteratorPtr
boost::shared_ptr< SMDS_Iterator< SMESH_subMesh * > > SMESH_subMeshIteratorPtr
Definition: SMESH_subMesh.hxx:56
SMESH_Algo
Definition: SMESH_Algo.hxx:62
SMESH_Algo.hxx
SMESH_subMesh::_subMeshDS
SMESHDS_SubMesh * _subMeshDS
Definition: SMESH_subMesh.hxx:282
SMESH_subMesh::InsertDependence
void InsertDependence(const TopoDS_Shape aSubShape)
SMESH_subMesh::CreateSubMeshDS
SMESHDS_SubMesh * CreateSubMeshDS()
SMESH_subMesh::GetEventListenerData
EventListenerData * GetEventListenerData(EventListener *listener) const
Return an event listener data.
SMESH_subMesh::IsMeshComputed
bool IsMeshComputed() const
SMESH_subMesh::GetSubMeshDS
SMESHDS_SubMesh * GetSubMeshDS()
SMESH_subMesh::Evaluate
bool Evaluate(MapShapeNbElems &aResMap)
SMESH_subMesh::REMOVE_HYP
@ REMOVE_HYP
Definition: SMESH_subMesh.hxx:99
SMESH_subMesh::SetAlgoState
void SetAlgoState(int state)
Utils_SALOME_Exception.hxx
SMESH_subMesh::CanAddHypothesis
bool CanAddHypothesis(const SMESH_Hypothesis *theHypothesis) const
SMESH_subMesh::RemoveSubMeshElementsAndNodes
void RemoveSubMeshElementsAndNodes()
SMESH_subMesh::_computeState
int _computeState
Definition: SMESH_subMesh.hxx:290
SMESH_subMesh::IsApplicableHypotesis
static bool IsApplicableHypotesis(const SMESH_Hypothesis *theHypothesis, const TopAbs_ShapeEnum theShapeType)
SMESH_subMesh::IsEmpty
bool IsEmpty() const
Return true if no mesh entities is bound to the submesh.
SMESH_subMesh::SetEventListener
void SetEventListener(EventListener *listener, EventListenerData *data)
Sets an event listener and its data to a submesh.
SMESH_subMesh::GetCollection
TopoDS_Shape GetCollection(SMESH_Gen *theGen, SMESH_Algo *theAlgo, bool &theSubComputed)
Return a shape containing all sub-shapes of the MainShape that can be meshed at once along with _subS...
SMESH_Hypothesis::Hypothesis_Status
Hypothesis_Status
Definition: SMESH_Hypothesis.hxx:51
SMESH_subMesh::ApplyToCollection
bool ApplyToCollection(SMESH_Algo *theAlgo, const TopoDS_Shape &theCollection)
Apply theAlgo to all subshapes in theCollection.
SMESH_subMesh::_dependenceAnalysed
bool _dependenceAnalysed
Definition: SMESH_subMesh.hxx:287
SMESH_subMeshEventListener
A base for objects reacting on submesh events.
Definition: SMESH_subMeshEventListener.hxx:44
SMESH_subMesh
Definition: SMESH_subMesh.hxx:60
SMESH_subMesh::UpdateSubMeshState
void UpdateSubMeshState(const compute_state theState)
SMESH_subMeshEventListenerData
Data specific for EventListener and to be stored in a submesh.
Definition: SMESH_subMeshEventListener.hxx:75
SMESH_subMesh::CleanDependsOn
void CleanDependsOn()
SMESH_subMesh::GetId
int GetId() const
SMESH_subMesh::GetComputeError
SMESH_ComputeErrorPtr & GetComputeError()
Definition: SMESH_subMesh.hxx:189
EventListenerData
SMESH_subMeshEventListenerData EventListenerData
Definition: SMESH_subMesh.hxx:54
SMESHDS_Mesh
Definition: SMESHDS_Mesh.hxx:59
SMESH_subMesh::UpdateDependantsState
void UpdateDependantsState(const compute_event theEvent)
SMESH_subMesh::event_type
event_type
Definition: SMESH_subMesh.hxx:111
EventListener
SMESH_subMeshEventListener EventListener
Definition: SMESH_subMesh.hxx:51
SMESH_subMesh::ALGO_EVENT
@ ALGO_EVENT
Definition: SMESH_subMesh.hxx:112
SMESH_Gen
Definition: SMESH_Gen.hxx:63
SMESH_subMesh::SetEventListener
void SetEventListener(EventListener *listener, EventListenerData *data, SMESH_subMesh *where)
Sets an event listener and its data to a submesh.
SMESH_subMesh::algo_state
algo_state
Definition: SMESH_subMesh.hxx:93
SMESH_subMesh::IsAlwaysComputed
bool IsAlwaysComputed()
Definition: SMESH_subMesh.hxx:228
SMESH_subMesh::GetComputeState
int GetComputeState() const
Definition: SMESH_subMesh.hxx:188
SMESH_subMesh::READY_TO_COMPUTE
@ READY_TO_COMPUTE
Definition: SMESH_subMesh.hxx:89
SMESH_ComputeErrorPtr
boost::shared_ptr< SMESH_ComputeError > SMESH_ComputeErrorPtr
Definition: SMESH_ComputeError.hxx:37
SMESH_subMesh::~ SMESH_subMesh
virtual ~ SMESH_subMesh()
SMESH_Hypothesis
Definition: SMESH_Hypothesis.hxx:48
SMESH_subMesh::DependsOn
const std::map< int, SMESH_subMesh * > & DependsOn()
SMESH_subMesh::compute_state
compute_state
Definition: SMESH_subMesh.hxx:88
SMESH_subMesh::_subShape
TopoDS_Shape _subShape
Definition: SMESH_subMesh.hxx:281
SMESH_subMesh::COMPUTE_OK
@ COMPUTE_OK
Definition: SMESH_subMesh.hxx:90
SMESH_subMesh::SubMeshesAlgoStateEngine
SMESH_Hypothesis::Hypothesis_Status SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis *anHyp)
SMESH_subMesh::_mapDepend
std::map< int, SMESH_subMesh * > _mapDepend
Definition: SMESH_subMesh.hxx:286
SMESH_subMesh::ComputeStateEngine
bool ComputeStateEngine(int event)
SMESH_Hypothesis.hxx
SMESH_subMesh::GetAlgoState
int GetAlgoState() const
Definition: SMESH_subMesh.hxx:187
SMESH_subMesh::CleanDependants
void CleanDependants()
MapShapeNbElems
std::map< SMESH_subMesh *, std::vector< int > > MapShapeNbElems
Definition: SMESH_Algo.hxx:55
SMESH_subMesh::GetSubShape
const TopoDS_Shape & GetSubShape() const
SMESH_subMesh::DeleteEventListener
void DeleteEventListener(EventListener *listener)
Unregister the listener and delete it and it's data.
SMESH_SMESH.hxx
SMESH_subMesh::MESH_ENTITY_REMOVED
@ MESH_ENTITY_REMOVED
Definition: SMESH_subMesh.hxx:108
SMESHDS_SubMesh
Definition: SMESHDS_SubMesh.hxx:39
SMESHDS_Mesh.hxx
SMESH_subMesh::getDependsOnIterator
SMESH_subMeshIteratorPtr getDependsOnIterator(const bool includeSelf, const bool complexShapeFirst)
Return iterator on the submeshes this one depends on.
SMESH_subMesh::REMOVE_FATHER_HYP
@ REMOVE_FATHER_HYP
Definition: SMESH_subMesh.hxx:101
SMESH_subMesh::MODIF_ALGO_STATE
@ MODIF_ALGO_STATE
Definition: SMESH_subMesh.hxx:106
SMESH_Mesh
Definition: SMESH_Mesh.hxx:55
SMESH_subMesh::algo_event
algo_event
Definition: SMESH_subMesh.hxx:97
SMESH_subMesh::_alwaysComputed
bool _alwaysComputed
Definition: SMESH_subMesh.hxx:296
SMESH_subMesh::NotifyListenersOnEvent
void NotifyListenersOnEvent(const int event, const event_type eventType, SMESH_Hypothesis *hyp=0)
Notify stored event listeners on the occured event.
SMESH_subMesh::DumpAlgoState
void DumpAlgoState(bool isMain)
SMESH_subMesh::ADD_HYP
@ ADD_HYP
Definition: SMESH_subMesh.hxx:98
SMESH_subMesh::GetFirstToCompute
SMESH_subMesh * GetFirstToCompute()
SMESH_subMesh::compute_event
compute_event
Definition: SMESH_subMesh.hxx:105
SMESH_subMesh::SetIsAlwaysComputed
void SetIsAlwaysComputed(bool isAlCo)
Allow algo->Compute() if a subshape of lower dim is meshed but none mesh entity is bound to it.
SMESH_subMesh::DeleteOwnListeners
void DeleteOwnListeners()
Delete event listeners depending on algo of this submesh.
SMESH_subMesh::_Id
int _Id
Definition: SMESH_subMesh.hxx:284
SMESH_subMesh::GetSimilarAttached
const SMESH_Hypothesis * GetSimilarAttached(const TopoDS_Shape &theShape, const SMESH_Hypothesis *theHyp, const int theHypType=0)
Return a hypothesis attached to theShape.
SMESH_subMesh::ADD_FATHER_HYP
@ ADD_FATHER_HYP
Definition: SMESH_subMesh.hxx:100
SMESH_subMesh::_algoState
int _algoState
Definition: SMESH_subMesh.hxx:289
SMESH_subMesh::SUBMESH_RESTORED
@ SUBMESH_RESTORED
Definition: SMESH_subMesh.hxx:107
SMESH_subMesh::SubMeshesComputed
bool SubMeshesComputed()
SMESH_subMesh::CheckComputeError
bool CheckComputeError(SMESH_Algo *theAlgo, const TopoDS_Shape &theShape=TopoDS_Shape())
Update compute_state by _computeError.
SMESH_subMesh::ComputeSubMeshStateEngine
void ComputeSubMeshStateEngine(int event)
SMESH_subMesh::IsApplicableHypotesis
bool IsApplicableHypotesis(const SMESH_Hypothesis *theHypothesis) const
Definition: SMESH_subMesh.hxx:207
SMESH_subMesh::AlgoStateEngine
SMESH_Hypothesis::Hypothesis_Status AlgoStateEngine(int event, SMESH_Hypothesis *anHyp)
SMESH_subMesh::NO_ALGO
@ NO_ALGO
Definition: SMESH_subMesh.hxx:94
SMESH_subMesh::GetFather
SMESH_Mesh * GetFather()
Definition: SMESH_subMesh.hxx:68
SMESHDS_SubMesh.hxx
SMESH_subMesh::myEventListeners
std::map< EventListener *, EventListenerData * > myEventListeners
< event listeners to notify
Definition: SMESH_subMesh.hxx:149
SMESH_subMesh::_father
SMESH_Mesh * _father
Definition: SMESH_subMesh.hxx:283
SMESH_subMesh::SubMeshesReady
bool SubMeshesReady()
SMESH_subMesh::myOwnListeners
std::list< std::pair< SMESH_subMesh *, EventListener * > > myOwnListeners
Definition: SMESH_subMesh.hxx:151
SMESH_subMesh::CheckConcurentHypothesis
SMESH_Hypothesis::Hypothesis_Status CheckConcurentHypothesis(const int theHypType)
SMESH_subMesh::IsConform
bool IsConform(const SMESH_Algo *theAlgo)
SMESH_EXPORT
#define SMESH_EXPORT
Definition: SMESH_SMESH.hxx:36