Debian Codegraph @

src/3rdParty/salomesmesh/inc/SMESH_Gen.hxx

raw
1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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.salome-platform.org/ or email : [email protected]
21 //
22
23 // SMESH SMESH : implementation of SMESH idl descriptions
24 // File : SMESH_Gen.hxx
25 // Author : Paul RASCLE, EDF
26 // Module : SMESH
27 //
28 #ifndef _SMESH_GEN_HXX_
29 #define _SMESH_GEN_HXX_
30
31 #include "SMESH_SMESH.hxx"
32
33 #include "Utils_SALOME_Exception.hxx"
34
35 #include "SMESH_Hypothesis.hxx"
36 #include "SMESH_ComputeError.hxx"
37 #include "SMESH_Algo.hxx"
38 #include "SMESH_Mesh.hxx"
39
40 #include <TopoDS_Shape.hxx>
41
42 #include <map>
43 #include <list>
44 #include <vector>
45 #include <string>
46
47 class SMESHDS_Document;
48
49 typedef SMESH_Hypothesis::Hypothesis_Status TAlgoStateErrorName;
50
51 typedef struct studyContextStruct
52 {
53 std::map < int, SMESH_Hypothesis * >mapHypothesis;
54 std::map < int, SMESH_Mesh * >mapMesh;
55 SMESHDS_Document * myDocument;
56 } StudyContextStruct;
57
58 typedef std::set<int> TSetOfInt;
59
60 class SMESH_EXPORT SMESH_Gen
61 {
62 public:
63 SMESH_Gen();
64 ~SMESH_Gen();
65
66 SMESH_Mesh* CreateMesh(int theStudyId, bool theIsEmbeddedMode);
67
68 /*!
69 * \brief Computes aMesh on aShape
70 * \param aShapeOnly - if true, algo->OnlyUnaryInput() feature is ignored and
71 * only \a aShape is computed.
72 * \param anUpward - compute from vertices up to more complex shape (internal usage)
73 * \param aDim - upper level dimension of the mesh computation
74 * \param aShapesId - list of shapes with computed mesh entities (elements or nodes)
75 * \retval bool - true if none submesh failed to compute
76 */
77 bool Compute(::SMESH_Mesh & aMesh,
78 const TopoDS_Shape & aShape,
79 const bool aShapeOnly=false,
80 const bool anUpward=false,
81 const ::MeshDimension aDim=::MeshDim_3D,
82 TSetOfInt* aShapesId=0);
83
84 void PrepareCompute(::SMESH_Mesh & aMesh,
85 const TopoDS_Shape & aShape);
86 void CancelCompute(::SMESH_Mesh & aMesh,
87 const TopoDS_Shape & aShape);
88
89 const SMESH_subMesh* GetCurrentSubMesh() const;
90
91 /*!
92 * \brief evaluates size of prospective mesh on a shape
93 * \param aMesh - the mesh
94 * \param aShape - the shape
95 * \param aResMap - map for prospective numbers of elements
96 * \retval bool - is a success
97 */
98 bool Evaluate(::SMESH_Mesh & aMesh,
99 const TopoDS_Shape & aShape,
100 MapShapeNbElems& aResMap,
101 const bool anUpward=false,
102 TSetOfInt* aShapesId=0);
103
104 bool CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
105 // notify on bad state of attached algos, return false
106 // if Compute() would fail because of some algo bad state
107
108 /*!
109 * \brief Sets number of segments per diagonal of boundary box of geometry by which
110 * default segment length of appropriate 1D hypotheses is defined
111 */
112 void SetBoundaryBoxSegmentation( int theNbSegments ) { _segmentation = theNbSegments; }
113 int GetBoundaryBoxSegmentation() const { return _segmentation; }
114 /*!
115 * \brief Sets default number of segments per edge
116 */
117 void SetDefaultNbSegments(int nb) { _nbSegments = nb; }
118 int GetDefaultNbSegments() const { return _nbSegments; }
119
120 struct TAlgoStateError
121 {
122 TAlgoStateErrorName _name;
123 const SMESH_Algo* _algo;
124 int _algoDim;
125 bool _isGlobalAlgo;
126
127 TAlgoStateError(): _name(SMESH_Hypothesis::HYP_OK), _algo(0), _algoDim(0) {}
128 void Set(TAlgoStateErrorName name, const SMESH_Algo* algo, bool isGlobal)
129 { _name = name; _algo = algo; _algoDim = algo->GetDim(); _isGlobalAlgo = isGlobal; }
130 void Set(TAlgoStateErrorName name, const int algoDim, bool isGlobal)
131 { _name = name; _algo = 0; _algoDim = algoDim; _isGlobalAlgo = isGlobal; }
132 };
133
134 bool GetAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
135 std::list< SMESH_Gen::TAlgoStateError > & theErrors);
136 // notify on bad state of attached algos, return false
137 // if Compute() would fail because of some algo bad state
138 // theErrors list contains problems description
139
140 StudyContextStruct *GetStudyContext(int studyId);
141
142 static int GetShapeDim(const TopAbs_ShapeEnum & aShapeType);
143 static int GetShapeDim(const TopoDS_Shape & aShape)
144 { return GetShapeDim( aShape.ShapeType() ); }
145
146 SMESH_Algo* GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, TopoDS_Shape* assignedTo=0);
147 SMESH_Algo* GetAlgo(SMESH_subMesh * aSubMesh, TopoDS_Shape* assignedTo=0);
148
149 static bool IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh);
150
151 static std::vector< std::string > GetPluginXMLPaths();
152
153 int GetANewId();
154
155 // std::map < int, SMESH_Algo * >_mapAlgo;
156 // std::map < int, SMESH_0D_Algo * >_map0D_Algo;
157 // std::map < int, SMESH_1D_Algo * >_map1D_Algo;
158 // std::map < int, SMESH_2D_Algo * >_map2D_Algo;
159 // std::map < int, SMESH_3D_Algo * >_map3D_Algo;
160
161 private:
162
163 int _localId; // unique Id of created objects, within SMESH_Gen entity
164 std::map < int, StudyContextStruct * >_mapStudyContext;
165
166 // hypotheses managing
167 int _hypId;
168
169 // number of segments per diagonal of boundary box of geometry by which
170 // default segment length of appropriate 1D hypotheses is defined
171 int _segmentation;
172 // default number of segments
173 int _nbSegments;
174
175 void setCurrentSubMesh(SMESH_subMesh* sm);
176 void resetCurrentSubMesh();
177
178 volatile bool _compute_canceled;
179 std::list< SMESH_subMesh* > _sm_current;
180 };
181
182 #endif