00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _SMESH_SUBMESH_HXX_
00028 #define _SMESH_SUBMESH_HXX_
00029
00030 #include "SMESH_SMESH.hxx"
00031
00032 #include "SMESHDS_Mesh.hxx"
00033 #include "SMESHDS_SubMesh.hxx"
00034 #include "SMESH_Hypothesis.hxx"
00035 #include "SMESH_ComputeError.hxx"
00036 #include "SMESH_Algo.hxx"
00037
00038 #include "Utils_SALOME_Exception.hxx"
00039
00040 #include <TopoDS_Shape.hxx>
00041
00042 #include <list>
00043 #include <map>
00044
00045 class SMESH_Mesh;
00046 class SMESH_Hypothesis;
00047 class SMESH_Algo;
00048 class SMESH_Gen;
00049 class SMESH_subMeshEventListener;
00050 struct SMESH_subMeshEventListenerData;
00051 class SMESH_subMesh;
00052
00053 typedef SMESH_subMeshEventListener EventListener;
00054 typedef SMESH_subMeshEventListenerData EventListenerData;
00055
00056 typedef boost::shared_ptr< SMDS_Iterator<SMESH_subMesh*> > SMESH_subMeshIteratorPtr;
00057
00058
00059 class SMESH_EXPORT SMESH_subMesh
00060 {
00061 public:
00062 SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
00063 const TopoDS_Shape & aSubShape);
00064 virtual ~ SMESH_subMesh();
00065
00066 int GetId() const;
00067
00068 SMESH_Mesh* GetFather() { return _father; }
00069
00070 SMESHDS_SubMesh * GetSubMeshDS();
00071
00072 SMESHDS_SubMesh* CreateSubMeshDS();
00073
00074
00075 SMESH_subMesh *GetFirstToCompute();
00076
00077 const std::map < int, SMESH_subMesh * >& DependsOn();
00078
00082 SMESH_subMeshIteratorPtr getDependsOnIterator(const bool includeSelf,
00083 const bool complexShapeFirst);
00084
00085 const TopoDS_Shape & GetSubShape() const;
00086
00087 enum compute_state
00088 {
00089 NOT_READY, READY_TO_COMPUTE,
00090 COMPUTE_OK, FAILED_TO_COMPUTE
00091 };
00092 enum algo_state
00093 {
00094 NO_ALGO, MISSING_HYP, HYP_OK
00095 };
00096 enum algo_event
00097 {
00098 ADD_HYP , ADD_ALGO,
00099 REMOVE_HYP , REMOVE_ALGO,
00100 ADD_FATHER_HYP , ADD_FATHER_ALGO,
00101 REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO,
00102 MODIF_HYP
00103 };
00104 enum compute_event
00105 {
00106 MODIF_ALGO_STATE, COMPUTE,
00107 CLEAN, SUBMESH_COMPUTED, SUBMESH_RESTORED,
00108 MESH_ENTITY_REMOVED, CHECK_COMPUTE_STATE
00109 };
00110 enum event_type
00111 {
00112 ALGO_EVENT, COMPUTE_EVENT
00113 };
00114
00115
00116
00117
00118
00129 void SetEventListener(EventListener* listener,
00130 EventListenerData* data,
00131 SMESH_subMesh* where);
00132
00138 EventListenerData* GetEventListenerData(EventListener* listener) const;
00139
00144 void DeleteEventListener(EventListener* listener);
00145
00146 protected:
00147
00149 std::map< EventListener*, EventListenerData* > myEventListeners;
00151 std::list< std::pair< SMESH_subMesh*, EventListener* > > myOwnListeners;
00152
00160 void SetEventListener(EventListener* listener, EventListenerData* data);
00161
00168 void NotifyListenersOnEvent( const int event,
00169 const event_type eventType,
00170 SMESH_Hypothesis* hyp = 0);
00171
00175 void DeleteOwnListeners();
00176
00177
00178
00179 public:
00180
00181 SMESH_Hypothesis::Hypothesis_Status
00182 AlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
00183
00184 SMESH_Hypothesis::Hypothesis_Status
00185 SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
00186
00187 int GetAlgoState() const { return _algoState; }
00188 int GetComputeState() const { return _computeState; };
00189 SMESH_ComputeErrorPtr& GetComputeError() { return _computeError; }
00190
00191 void DumpAlgoState(bool isMain);
00192
00193 bool ComputeStateEngine(int event);
00194
00195 bool Evaluate(MapShapeNbElems& aResMap);
00196
00197 bool IsConform(const SMESH_Algo* theAlgo);
00198
00199
00200 bool CanAddHypothesis(const SMESH_Hypothesis* theHypothesis) const;
00201
00202
00203
00204 static bool IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis,
00205 const TopAbs_ShapeEnum theShapeType);
00206
00207 bool IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis) const
00208 { return IsApplicableHypotesis( theHypothesis, _subShape.ShapeType() ); }
00209
00210
00211
00212 SMESH_Hypothesis::Hypothesis_Status CheckConcurentHypothesis (const int theHypType);
00213
00214
00218 bool IsEmpty() const;
00219
00220 bool IsMeshComputed() const;
00221
00222
00227 void SetIsAlwaysComputed(bool isAlCo);
00228 bool IsAlwaysComputed() { return _alwaysComputed; }
00229
00230
00231 protected:
00232
00233 void InsertDependence(const TopoDS_Shape aSubShape);
00234
00235 bool SubMeshesComputed();
00236
00237 bool SubMeshesReady();
00238
00239 void RemoveSubMeshElementsAndNodes();
00240 void UpdateDependantsState(const compute_event theEvent);
00241 void UpdateSubMeshState(const compute_state theState);
00242 void ComputeSubMeshStateEngine(int event);
00243 void CleanDependants();
00244 void CleanDependsOn();
00245 void SetAlgoState(int state);
00246
00251 TopoDS_Shape GetCollection(SMESH_Gen * theGen,
00252 SMESH_Algo* theAlgo,
00253 bool & theSubComputed);
00254
00258 bool ApplyToCollection (SMESH_Algo* theAlgo,
00259 const TopoDS_Shape& theCollection);
00260
00265 bool CheckComputeError(SMESH_Algo* theAlgo, const TopoDS_Shape& theShape=TopoDS_Shape());
00266
00274 const SMESH_Hypothesis* GetSimilarAttached(const TopoDS_Shape& theShape,
00275 const SMESH_Hypothesis * theHyp,
00276 const int theHypType = 0);
00277
00278
00279 protected:
00280
00281 TopoDS_Shape _subShape;
00282 SMESHDS_SubMesh * _subMeshDS;
00283 SMESH_Mesh * _father;
00284 int _Id;
00285
00286 std::map < int, SMESH_subMesh * >_mapDepend;
00287 bool _dependenceAnalysed;
00288
00289 int _algoState;
00290 int _computeState;
00291 SMESH_ComputeErrorPtr _computeError;
00292
00293
00294
00295
00296 bool _alwaysComputed;
00297
00298 };
00299
00300 #endif