Salome HOME
yfr : Merge with v1.2
[modules/smesh.git] / src / SMESH / SMESH_subMesh.hxx
1 //  SMESH SMESH : implementaion of SMESH idl descriptions
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESH_subMesh.hxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //  $Header$
28
29 #ifndef _SMESH_SUBMESH_HXX_
30 #define _SMESH_SUBMESH_HXX_
31
32 #include "SMESHDS_Mesh.hxx"
33 #include "SMESHDS_SubMesh.hxx"
34 #include "Utils_SALOME_Exception.hxx"
35 #include <TopoDS_Shape.hxx>
36 #include <TColStd_IndexedMapOfTransient.hxx>
37 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
38
39 #include <set>
40 #include <list>
41 #include <map>
42
43 class SMESH_Mesh;
44 class SMESH_Hypothesis;
45
46 class SMESH_subMesh
47 {
48 public:
49   SMESH_subMesh(int Id,
50                 SMESH_Mesh* father,
51                 const Handle(SMESHDS_Mesh)& meshDS,
52                 const TopoDS_Shape & aSubShape);
53   virtual ~SMESH_subMesh();
54
55   int GetId();
56
57 //   bool Contains(const TopoDS_Shape & aSubShape)
58 //     throw (SALOME_Exception);
59
60   const Handle(SMESHDS_SubMesh)& GetSubMeshDS()
61     throw (SALOME_Exception);
62
63   SMESH_subMesh* GetFirstToCompute()
64     throw (SALOME_Exception);
65
66   const map<int, SMESH_subMesh*>& DependsOn();
67   const map<int, SMESH_subMesh*>& Dependants();
68
69   const TopoDS_Shape& GetSubShape();
70
71   bool _vertexSet;   // only for vertex subMesh, set to false for dim > 0
72
73   enum compute_state { NOT_READY, READY_TO_COMPUTE,
74                        COMPUTE_OK, FAILED_TO_COMPUTE };
75   enum algo_state { NO_ALGO, MISSING_HYP, HYP_OK };
76   enum algo_event {ADD_HYP, ADD_ALGO,
77                    REMOVE_HYP, REMOVE_ALGO,
78                    ADD_FATHER_HYP, ADD_FATHER_ALGO,
79                    REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO};
80   enum compute_event {MODIF_HYP, MODIF_ALGO_STATE, COMPUTE,
81                       CLEAN, CLEANDEP, SUBMESH_COMPUTED};
82
83   bool AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
84     throw (SALOME_Exception);
85
86   void SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
87     throw (SALOME_Exception);
88
89   void DumpAlgoState(bool isMain);
90
91   bool ComputeStateEngine(int event)
92     throw (SALOME_Exception);
93
94   int GetComputeState() {return _computeState;};
95
96 protected:
97   void InsertDependence(const TopoDS_Shape aSubShape);
98 //   void FinalizeDependence(list<TopoDS_Shape>& shapeList);
99
100   bool SubMeshesComputed()
101     throw (SALOME_Exception);
102
103   bool SubMeshesReady();
104
105   void RemoveSubMeshElementsAndNodes();
106   void UpdateDependantsState();
107   void CleanDependants();
108   void ExtractDependants(const TopTools_IndexedDataMapOfShapeListOfShape& M,
109                          const TopAbs_ShapeEnum etype);
110   void SetAlgoState(int state);
111
112   TopoDS_Shape _subShape;
113   Handle (SMESHDS_Mesh) _meshDS;
114   Handle (SMESHDS_SubMesh) _subMeshDS;
115   int _Id;
116   SMESH_Mesh* _father;
117   map<int, SMESH_subMesh*> _mapDepend;
118   map<int, SMESH_subMesh*> _mapDependants;
119   bool _dependenceAnalysed;
120   bool _dependantsFound;
121
122   int _algoState;
123   int _oldAlgoState;
124   int _computeState;
125
126 };
127
128 #endif