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
00028
00029 #ifndef _SMESH_SUBMESH_HXX_
00030 #define _SMESH_SUBMESH_HXX_
00031
00032 #include "SMESH_SMESH.hxx"
00033
00034 #include "SMESHDS_Mesh.hxx"
00035 #include "SMESHDS_SubMesh.hxx"
00036 #include "SMESH_Hypothesis.hxx"
00037 #include "SMESH_ComputeError.hxx"
00038 #include "SMESH_Algo.hxx"
00039
00040 #include "Utils_SALOME_Exception.hxx"
00041
00042 #include <TopoDS_Shape.hxx>
00043
00044 #include <list>
00045 #include <map>
00046
00047 class SMESH_Mesh;
00048 class SMESH_Hypothesis;
00049 class SMESH_Algo;
00050 class SMESH_Gen;
00051 class SMESH_subMeshEventListener;
00052 class SMESH_subMeshEventListenerData;
00053 class SMESH_subMesh;
00054
00055 typedef SMESH_subMeshEventListener EventListener;
00056 typedef SMESH_subMeshEventListenerData EventListenerData;
00057
00058 typedef boost::shared_ptr< SMDS_Iterator<SMESH_subMesh*> > SMESH_subMeshIteratorPtr;
00059
00060
00061 class SMESH_EXPORT SMESH_subMesh
00062 {
00063 public:
00064 SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
00065 const TopoDS_Shape & aSubShape);
00066 virtual ~ SMESH_subMesh();
00067
00068 int GetId() const;
00069
00070 SMESH_Mesh* GetFather() { return _father; }
00071
00072 SMESHDS_SubMesh * GetSubMeshDS();
00073
00074 SMESHDS_SubMesh* CreateSubMeshDS();
00075
00076
00077 SMESH_subMesh *GetFirstToCompute();
00078
00079 const std::map < int, SMESH_subMesh * >& DependsOn();
00080
00084 SMESH_subMeshIteratorPtr getDependsOnIterator(const bool includeSelf,
00085 const bool complexShapeFirst);
00086
00087 const TopoDS_Shape & GetSubShape() const;
00088
00089 enum compute_state
00090 {
00091 NOT_READY, READY_TO_COMPUTE,
00092 COMPUTE_OK, FAILED_TO_COMPUTE
00093 };
00094 enum algo_state
00095 {
00096 NO_ALGO, MISSING_HYP, HYP_OK
00097 };
00098 enum algo_event
00099 {
00100 ADD_HYP , ADD_ALGO,
00101 REMOVE_HYP , REMOVE_ALGO,
00102 ADD_FATHER_HYP , ADD_FATHER_ALGO,
00103 REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO,
00104 MODIF_HYP
00105 };
00106 enum compute_event
00107 {
00108 MODIF_ALGO_STATE, COMPUTE,
00109 #ifdef WITH_SMESH_CANCEL_COMPUTE
00110 COMPUTE_CANCELED,
00111 #endif
00112 CLEAN, SUBMESH_COMPUTED, SUBMESH_RESTORED,
00113 MESH_ENTITY_REMOVED, CHECK_COMPUTE_STATE
00114 };
00115 enum event_type
00116 {
00117 ALGO_EVENT, COMPUTE_EVENT
00118 };
00119
00120
00121
00122
00123
00134 void SetEventListener(EventListener* listener,
00135 EventListenerData* data,
00136 SMESH_subMesh* where);
00137
00143 EventListenerData* GetEventListenerData(EventListener* listener) const;
00144
00149 void DeleteEventListener(EventListener* listener);
00150
00151 protected:
00152
00154 std::map< EventListener*, EventListenerData* > myEventListeners;
00156 std::list< std::pair< SMESH_subMesh*, EventListener* > > myOwnListeners;
00157
00165 void SetEventListener(EventListener* listener, EventListenerData* data);
00166
00173 void NotifyListenersOnEvent( const int event,
00174 const event_type eventType,
00175 SMESH_Hypothesis* hyp = 0);
00176
00180 void DeleteOwnListeners();
00181
00182
00183
00184 public:
00185
00186 SMESH_Hypothesis::Hypothesis_Status
00187 AlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
00188
00189 SMESH_Hypothesis::Hypothesis_Status
00190 SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
00191
00192 int GetAlgoState() const { return _algoState; }
00193 int GetComputeState() const { return _computeState; };
00194 SMESH_ComputeErrorPtr& GetComputeError() { return _computeError; }
00195
00196 void DumpAlgoState(bool isMain);
00197
00198 bool ComputeStateEngine(int event);
00199 void ComputeSubMeshStateEngine(int event);
00200
00201 bool Evaluate(MapShapeNbElems& aResMap);
00202
00203 bool IsConform(const SMESH_Algo* theAlgo);
00204
00205
00206 bool CanAddHypothesis(const SMESH_Hypothesis* theHypothesis) const;
00207
00208
00209
00210 static bool IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis,
00211 const TopAbs_ShapeEnum theShapeType);
00212
00213 bool IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis) const
00214 { return IsApplicableHypotesis( theHypothesis, _subShape.ShapeType() ); }
00215
00216
00217
00218 SMESH_Hypothesis::Hypothesis_Status CheckConcurentHypothesis (const int theHypType);
00219
00220
00224 bool IsEmpty() const;
00225
00226 bool IsMeshComputed() const;
00227
00228
00233 void SetIsAlwaysComputed(bool isAlCo);
00234 bool IsAlwaysComputed() { return _alwaysComputed; }
00235
00236
00243 bool FindIntersection( const SMESH_subMesh * theOther,
00244 std::set<const SMESH_subMesh*>& theSetOfCommon ) const;
00245
00246 protected:
00247
00248 void InsertDependence(const TopoDS_Shape aSubShape);
00249
00250 bool SubMeshesComputed();
00251
00252 bool SubMeshesReady();
00253
00254 void RemoveSubMeshElementsAndNodes();
00255 void UpdateDependantsState(const compute_event theEvent);
00256 void UpdateSubMeshState(const compute_state theState);
00257 void CleanDependants();
00258 void CleanDependsOn();
00259 void SetAlgoState(int state);
00260
00265 TopoDS_Shape GetCollection(SMESH_Gen * theGen,
00266 SMESH_Algo* theAlgo,
00267 bool & theSubComputed);
00268
00272 bool ApplyToCollection (SMESH_Algo* theAlgo,
00273 const TopoDS_Shape& theCollection);
00274
00279 bool CheckComputeError(SMESH_Algo* theAlgo, const TopoDS_Shape& theShape=TopoDS_Shape());
00280
00288 const SMESH_Hypothesis* GetSimilarAttached(const TopoDS_Shape& theShape,
00289 const SMESH_Hypothesis * theHyp,
00290 const int theHypType = 0);
00291
00292
00293 protected:
00294
00295 TopoDS_Shape _subShape;
00296 SMESHDS_SubMesh * _subMeshDS;
00297 SMESH_Mesh * _father;
00298 int _Id;
00299
00300 std::map < int, SMESH_subMesh * >_mapDepend;
00301 bool _dependenceAnalysed;
00302
00303 int _algoState;
00304 int _computeState;
00305 SMESH_ComputeErrorPtr _computeError;
00306
00307
00308
00309
00310 bool _alwaysComputed;
00311
00312 };
00313
00314 #endif