Version: 9.12.0
SMESH_Gen.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, 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 : webmaster.salome@opencascade.com
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_Algo.hxx"
36 #include "SMESH_ComputeError.hxx"
37 #include "SMESH_subMesh.hxx"
38 
39 #include <map>
40 #include <list>
41 #include <set>
42 #include <vector>
43 #include <string>
44 
45 
46 #include <TopoDS_Shape.hxx>
47 #include <TopTools_IndexedMapOfShape.hxx>
48 
49 class SMESHDS_Document;
50 class SMESH_Algo;
51 class SMESH_Mesh;
52 class SMESH_ParallelMesh;
53 class TopoDS_Shape;
54 
55 
57 
58 typedef struct studyContextStruct
59 {
60  std::map < int, SMESH_Hypothesis * >mapHypothesis;
61  std::map < int, SMESH_Mesh * >mapMesh;
64 
65 typedef std::set<int> TSetOfInt;
66 
68 {
69 public:
70  SMESH_Gen();
71  ~SMESH_Gen();
72 
73  SMESH_Mesh* CreateMesh(bool theIsEmbeddedMode);
74  SMESH_ParallelMesh* CreateParallelMesh(bool theIsEmbeddedMode);
75 
77  {
78  SHAPE_ONLY = 1, // to ignore algo->OnlyUnaryInput() feature and to compute a given shape only.
79  UPWARD = 2, // to compute from vertices up to more complex shape (internal usage)
80  COMPACT_MESH = 4, // to compact the mesh at the end
81  SHAPE_ONLY_UPWARD = 3 // SHAPE_ONLY | UPWARD
82  };
93  bool Compute(::SMESH_Mesh & aMesh,
94  const TopoDS_Shape & aShape,
95  const int aFlags = COMPACT_MESH,
97  TSetOfInt* aShapesId=0,
98  TopTools_IndexedMapOfShape* anAllowedSubShapes=0);
99 
100  void PrepareCompute(::SMESH_Mesh & aMesh,
101  const TopoDS_Shape & aShape);
102  void CancelCompute(::SMESH_Mesh & aMesh,
103  const TopoDS_Shape & aShape);
104 
105  const SMESH_subMesh* GetCurrentSubMesh() const;
106 
114  bool Evaluate(::SMESH_Mesh & aMesh,
115  const TopoDS_Shape & aShape,
116  MapShapeNbElems& aResMap,
117  const bool anUpward=false,
118  TSetOfInt* aShapesId=0);
119 
120  bool CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
121  // notify on bad state of attached algos, return false
122  // if Compute() would fail because of some algo bad state
123 
128  void SetBoundaryBoxSegmentation( int theNbSegments ) { _segmentation = theNbSegments; }
129  int GetBoundaryBoxSegmentation() const { return _segmentation; }
133  void SetDefaultNbSegments(int nb) { _nbSegments = nb; }
134  int GetDefaultNbSegments() const { return _nbSegments; }
135 
137  {
140  int _algoDim;
142 
143  TAlgoStateError(): _name(SMESH_Hypothesis::HYP_OK), _algo(0), _algoDim(0) {}
144  void Set(TAlgoStateErrorName name, const SMESH_Algo* algo, bool isGlobal)
145  { _name = name; _algo = algo; _algoDim = algo->GetDim(); _isGlobalAlgo = isGlobal; }
146  void Set(TAlgoStateErrorName name, const int algoDim, bool isGlobal)
147  { _name = name; _algo = 0; _algoDim = algoDim; _isGlobalAlgo = isGlobal; }
148  };
149 
150  bool GetAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
151  std::list< SMESH_Gen::TAlgoStateError > & theErrors);
152  // notify on bad state of attached algos, return false
153  // if Compute() would fail because of some algo bad state
154  // theErrors list contains problems description
155 
156  StudyContextStruct *GetStudyContext();
157 
158  static int GetShapeDim(const TopAbs_ShapeEnum & aShapeType);
159  static int GetShapeDim(const TopoDS_Shape & aShape)
160  { return GetShapeDim( aShape.ShapeType() ); }
161  static int GetFlatShapeDim(const TopoDS_Shape &aShape);
162 
163  SMESH_Algo* GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, TopoDS_Shape* assignedTo=0);
164  SMESH_Algo* GetAlgo(SMESH_subMesh * aSubMesh, TopoDS_Shape* assignedTo=0);
165 
166  static bool IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh);
167 
168  static std::vector< std::string > GetPluginXMLPaths();
169 
170  int GetANewId();
171 
172 public:
173  void send_mesh(SMESH_Mesh & aMesh, std::string filename);
174 
175  bool parallelComputeSubMeshes(
176  SMESH_Mesh & aMesh,
177  const TopoDS_Shape & aShape,
179  TSetOfInt* aShapesId,
180  TopTools_IndexedMapOfShape* allowedSubShapes,
181  SMESH_subMesh::compute_event &computeEvent,
182  const bool includeSelf,
183  const bool complexShapeFirst,
184  const bool aShapeOnly);
185 
186  bool sequentialComputeSubMeshes(
187  SMESH_Mesh & aMesh,
188  const TopoDS_Shape & aShape,
190  TSetOfInt* aShapesId /*=0*/,
191  TopTools_IndexedMapOfShape* allowedSubShapes,
192  SMESH_subMesh::compute_event &computeEvent,
193  const bool includeSelf,
194  const bool complexShapeFirst,
195  const bool aShapeOnly);
196 
197 private:
198 
199 
200 
201  int _localId; // unique Id of created objects, within SMESH_Gen entity
203 
204  // hypotheses managing
205  int _hypId;
206 
207  // number of segments per diagonal of boundary box of geometry by which
208  // default segment length of appropriate 1D hypotheses is defined
210  // default number of segments
212 
213  void setCurrentSubMesh(SMESH_subMesh* sm);
214  void resetCurrentSubMesh();
215 
216  volatile bool _compute_canceled;
217  std::list< SMESH_subMesh* > _sm_current;
218 };
219 
220 #endif
std::map< SMESH_subMesh *, std::vector< smIdType > > MapShapeNbElems
Definition: SMESH_Algo.hxx:61
SMESH_Hypothesis::Hypothesis_Status TAlgoStateErrorName
Definition: SMESH_Gen.hxx:53
struct studyContextStruct StudyContextStruct
std::set< int > TSetOfInt
Definition: SMESH_Gen.hxx:65
MeshDimension
Definition: SMESH_Hypothesis.hxx:40
@ MeshDim_3D
Definition: SMESH_Hypothesis.hxx:44
#define SMESH_EXPORT
Definition: SMESH_SMESH.hxx:37
Definition: SMESHDS_Document.hxx:38
Root of all algorithms.
Definition: SMESH_Algo.hxx:79
Definition: SMESH_Gen.hxx:68
bool Compute(::SMESH_Mesh &aMesh, const TopoDS_Shape &aShape, const int aFlags=COMPACT_MESH, const ::MeshDimension aDim=::MeshDim_3D, TSetOfInt *aShapesId=0, TopTools_IndexedMapOfShape *anAllowedSubShapes=0)
Computes aMesh on aShape.
void SetDefaultNbSegments(int nb)
Sets default number of segments per edge.
Definition: SMESH_Gen.hxx:133
static int GetShapeDim(const TopoDS_Shape &aShape)
Definition: SMESH_Gen.hxx:159
int _nbSegments
Definition: SMESH_Gen.hxx:211
bool Evaluate(::SMESH_Mesh &aMesh, const TopoDS_Shape &aShape, MapShapeNbElems &aResMap, const bool anUpward=false, TSetOfInt *aShapesId=0)
evaluates size of prospective mesh on a shape
volatile bool _compute_canceled
Definition: SMESH_Gen.hxx:216
int _localId
Definition: SMESH_Gen.hxx:201
int GetBoundaryBoxSegmentation() const
Definition: SMESH_Gen.hxx:129
StudyContextStruct * _studyContext
Definition: SMESH_Gen.hxx:202
void SetBoundaryBoxSegmentation(int theNbSegments)
Sets number of segments per diagonal of boundary box of geometry by which default segment length of a...
Definition: SMESH_Gen.hxx:128
int _hypId
Definition: SMESH_Gen.hxx:205
void CancelCompute(::SMESH_Mesh &aMesh, const TopoDS_Shape &aShape)
ComputeFlags
Definition: SMESH_Gen.hxx:77
int GetDefaultNbSegments() const
Definition: SMESH_Gen.hxx:134
int _segmentation
Definition: SMESH_Gen.hxx:209
std::list< SMESH_subMesh * > _sm_current
Definition: SMESH_Gen.hxx:217
Definition: SMESH_Hypothesis.hxx:48
Hypothesis_Status
Definition: SMESH_Hypothesis.hxx:51
virtual int GetDim() const
Definition: SMESH_Hypothesis.cxx:75
Definition: SMESH_Mesh.hxx:80
Definition: SMESH_ParallelMesh.hxx:45
Definition: SMESH_subMesh.hxx:61
compute_event
Definition: SMESH_subMesh.hxx:116
@ HYP_OK
Definition: SMESH_Mesh.idl:209
Definition: SMESH_Gen.hxx:137
bool _isGlobalAlgo
Definition: SMESH_Gen.hxx:141
TAlgoStateErrorName _name
Definition: SMESH_Gen.hxx:138
int _algoDim
Definition: SMESH_Gen.hxx:140
void Set(TAlgoStateErrorName name, const SMESH_Algo *algo, bool isGlobal)
Definition: SMESH_Gen.hxx:144
void Set(TAlgoStateErrorName name, const int algoDim, bool isGlobal)
Definition: SMESH_Gen.hxx:146
TAlgoStateError()
Definition: SMESH_Gen.hxx:143
const SMESH_Algo * _algo
Definition: SMESH_Gen.hxx:139
Definition: SMESH_Gen.hxx:59
SMESHDS_Document * myDocument
Definition: SMESH_Gen.hxx:62
std::map< int, SMESH_Hypothesis * > mapHypothesis
Definition: SMESH_Gen.hxx:60
std::map< int, SMESH_Mesh * > mapMesh
Definition: SMESH_Gen.hxx:61