Salome HOME
make GetMaxArea const
[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, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
50                 const TopoDS_Shape & aSubShape);
51         virtual ~ SMESH_subMesh();
52
53         int GetId();
54
55 //   bool Contains(const TopoDS_Shape & aSubShape)
56 //     throw (SALOME_Exception);
57
58         SMESHDS_SubMesh * GetSubMeshDS() throw(SALOME_Exception);
59
60         SMESH_subMesh *GetFirstToCompute() throw(SALOME_Exception);
61
62         const map < int, SMESH_subMesh * >&DependsOn();
63         const map < int, SMESH_subMesh * >&Dependants();
64
65         const TopoDS_Shape & GetSubShape();
66
67         bool _vertexSet;                        // only for vertex subMesh, set to false for dim > 0
68
69         enum compute_state
70         { NOT_READY, READY_TO_COMPUTE,
71                 COMPUTE_OK, FAILED_TO_COMPUTE
72         };
73         enum algo_state
74         { NO_ALGO, MISSING_HYP, HYP_OK };
75         enum algo_event
76         { ADD_HYP, ADD_ALGO,
77                 REMOVE_HYP, REMOVE_ALGO,
78                 ADD_FATHER_HYP, ADD_FATHER_ALGO,
79                 REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO
80         };
81         enum compute_event
82         { MODIF_HYP, MODIF_ALGO_STATE, COMPUTE,
83                 CLEAN, CLEANDEP, SUBMESH_COMPUTED
84         };
85
86         bool AlgoStateEngine(int event, SMESH_Hypothesis * anHyp)
87                 throw(SALOME_Exception);
88
89         void SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp)
90                 throw(SALOME_Exception);
91
92         void DumpAlgoState(bool isMain);
93
94         bool ComputeStateEngine(int event) throw(SALOME_Exception);
95
96         int GetComputeState()
97         {
98                 return _computeState;
99         };
100
101   protected:
102         void InsertDependence(const TopoDS_Shape aSubShape);
103 //   void FinalizeDependence(list<TopoDS_Shape>& shapeList);
104
105         bool SubMeshesComputed() throw(SALOME_Exception);
106
107         bool SubMeshesReady();
108
109         void RemoveSubMeshElementsAndNodes();
110         void UpdateDependantsState();
111         void CleanDependants();
112         void ExtractDependants(const TopTools_IndexedDataMapOfShapeListOfShape & M,
113                 const TopAbs_ShapeEnum etype);
114         void SetAlgoState(int state);
115
116         TopoDS_Shape _subShape;
117         SMESHDS_Mesh * _meshDS;
118         SMESHDS_SubMesh * _subMeshDS;
119         int _Id;
120         SMESH_Mesh *_father;
121         map < int, SMESH_subMesh * >_mapDepend;
122         map < int, SMESH_subMesh * >_mapDependants;
123         bool _dependenceAnalysed;
124         bool _dependantsFound;
125
126         int _algoState;
127         int _oldAlgoState;
128         int _computeState;
129
130 };
131
132 #endif