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;
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 
70  SMESHDS_SubMesh * GetSubMeshDS();
71 
72  SMESHDS_SubMesh* CreateSubMeshDS();
73  // Explicit SMESHDS_SubMesh creation method, required for persistence mechanism
74 
75  SMESH_subMesh *GetFirstToCompute();
76 
77  const std::map < int, SMESH_subMesh * >& DependsOn();
78  //const map < int, SMESH_subMesh * >&Dependants();
82  SMESH_subMeshIteratorPtr getDependsOnIterator(const bool includeSelf,
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 
129  void SetEventListener(EventListener* listener,
130  EventListenerData* data,
131  SMESH_subMesh* where);
132 
138  EventListenerData* GetEventListenerData(EventListener* listener) const;
139 
144  void DeleteEventListener(EventListener* listener);
145 
146 protected:
147 
149  std::map< EventListener*, EventListenerData* > myEventListeners;
151  std::list< std::pair< SMESH_subMesh*, EventListener* > > myOwnListeners;
152 
160  void SetEventListener(EventListener* listener, EventListenerData* data);
161 
168  void NotifyListenersOnEvent( const int event,
169  const event_type eventType,
170  SMESH_Hypothesis* hyp = 0);
171 
175  void DeleteOwnListeners();
176 
177  // ==================================================================
178 
179 public:
180 
182  AlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
183 
185  SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
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 
212  SMESH_Hypothesis::Hypothesis_Status CheckConcurentHypothesis (const int theHypType);
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 
235  bool SubMeshesComputed();
236 
237  bool SubMeshesReady();
238 
239  void RemoveSubMeshElementsAndNodes();
240  void UpdateDependantsState(const compute_event theEvent);
241  void UpdateSubMeshState(const compute_state theState);
242  void ComputeSubMeshStateEngine(int event);
243  void CleanDependants();
244  void CleanDependsOn();
245  void SetAlgoState(int state);
246 
251  TopoDS_Shape GetCollection(SMESH_Gen * theGen,
252  SMESH_Algo* theAlgo,
253  bool & theSubComputed);
254 
258  bool ApplyToCollection (SMESH_Algo* theAlgo,
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_subMeshEventListener EventListener
Data specific for EventListener and to be stored in a submesh.
bool IsApplicableHypotesis(const SMESH_Hypothesis *theHypothesis) const
A base for objects reacting on submesh events.
boost::shared_ptr< SMESH_ComputeError > SMESH_ComputeErrorPtr
TopoDS_Shape _subShape
int GetComputeState() const
SMESHDS_SubMesh * _subMeshDS
SMESH_subMeshEventListenerData EventListenerData
std::list< std::pair< SMESH_subMesh *, EventListener *> > myOwnListeners
std::map< EventListener *, EventListenerData *> myEventListeners
< event listeners to notify
boost::shared_ptr< SMDS_Iterator< SMESH_subMesh * > > SMESH_subMeshIteratorPtr
std::map< int, SMESH_subMesh *> _mapDepend
SMESH_Mesh * _father
std::map< SMESH_subMesh *, std::vector< int > > MapShapeNbElems
Definition: SMESH_Algo.hxx:55
#define SMESH_EXPORT
Definition: SMESH_SMESH.hxx:36
SMESH_ComputeErrorPtr _computeError
SMESH_Mesh * GetFather()
bool IsAlwaysComputed()
int GetAlgoState() const
SMESH_ComputeErrorPtr & GetComputeError()