1 // SMESH SMESH : implementaion of SMESH idl descriptions
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESH_subMesh.hxx
25 // Author : Paul RASCLE, EDF
29 #ifndef _SMESH_SUBMESH_HXX_
30 #define _SMESH_SUBMESH_HXX_
32 #include "SMESHDS_Mesh.hxx"
33 #include "SMESHDS_SubMesh.hxx"
34 #include "SMESH_Hypothesis.hxx"
35 #include "Utils_SALOME_Exception.hxx"
36 #include <TopoDS_Shape.hxx>
37 #include <TColStd_IndexedMapOfTransient.hxx>
38 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
45 class SMESH_Hypothesis;
52 SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
53 const TopoDS_Shape & aSubShape);
54 virtual ~ SMESH_subMesh();
58 // bool Contains(const TopoDS_Shape & aSubShape)
59 // throw (SALOME_Exception);
61 SMESHDS_SubMesh * GetSubMeshDS();
63 SMESHDS_SubMesh* CreateSubMeshDS();
64 // Explicit SMESHDS_SubMesh creation method, required for persistence mechanism
66 SMESH_subMesh *GetFirstToCompute();
68 const map < int, SMESH_subMesh * >&DependsOn();
69 //const map < int, SMESH_subMesh * >&Dependants();
71 const TopoDS_Shape & GetSubShape();
73 bool _vertexSet; // only for vertex subMesh, set to false for dim > 0
77 NOT_READY, READY_TO_COMPUTE,
78 COMPUTE_OK, FAILED_TO_COMPUTE
82 NO_ALGO, MISSING_HYP, HYP_OK
87 REMOVE_HYP, REMOVE_ALGO,
88 ADD_FATHER_HYP, ADD_FATHER_ALGO,
89 REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO
93 MODIF_HYP, MODIF_ALGO_STATE, COMPUTE,
94 CLEAN, CLEANDEP, SUBMESH_COMPUTED, SUBMESH_RESTORED
97 SMESH_Hypothesis::Hypothesis_Status
98 AlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
100 SMESH_Hypothesis::Hypothesis_Status
101 SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
103 int GetAlgoState() { return _algoState; }
105 void DumpAlgoState(bool isMain);
107 bool ComputeStateEngine(int event);
109 int GetComputeState()
111 return _computeState;
114 bool IsConform(const SMESH_Algo* theAlgo);
115 // check if a conform mesh will be produced by the Algo
117 bool CanAddHypothesis(const SMESH_Hypothesis* theHypothesis) const;
118 // return true if theHypothesis can be attached to me:
119 // its dimention is checked
121 bool IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis) const;
122 // return true if theHypothesis can be used to mesh me:
123 // its shape type is checked
127 void InsertDependence(const TopoDS_Shape aSubShape);
129 bool SubMeshesComputed();
131 bool SubMeshesReady();
133 void RemoveSubMeshElementsAndNodes();
134 void UpdateDependantsState(const compute_event theEvent);
135 void UpdateSubMeshState(const compute_state theState);
136 void ComputeSubMeshStateEngine(int event);
137 void CleanDependants();
138 void CleanDependsOn();
139 void SetAlgoState(int state);
141 bool IsMeshComputed() const;
142 // check if _subMeshDS contains mesh elements
144 TopoDS_Shape GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlgo);
145 // return a shape containing all sub-shapes of the MainShape that can be
146 // meshed at once along with _subShape
148 bool ApplyToCollection (SMESH_Algo* theAlgo,
149 const TopoDS_Shape& theCollection);
150 // Apply theAlgo to all subshapes in theCollection
152 SMESH_Hypothesis::Hypothesis_Status CheckConcurentHypothesis (const int theHypType);
153 // check if there are several applicable hypothesis on fathers
155 int GetNbAttached(const TopoDS_Shape& theShape,
156 const SMESH_Hypothesis * theHyp,
157 const bool theAlgos = false);
158 // return nb of hypotheses attached to theShape.
159 // If theHyp is provided, similar but not same hypotheses
160 // are countered; else only applicable ones are countered
161 // depending on theAlgos flag
163 TopoDS_Shape _subShape;
164 SMESHDS_Mesh * _meshDS;
165 SMESHDS_SubMesh * _subMeshDS;
168 map < int, SMESH_subMesh * >_mapDepend;
169 //map < int, SMESH_subMesh * >_mapDependants;
170 bool _dependenceAnalysed;
171 //bool _dependantsFound;