SALOME - SMESH
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SMESH_Gen.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2008 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.
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 // SMESH SMESH : implementaion of SMESH idl descriptions
23 // File : SMESH_Gen.hxx
24 // Author : Paul RASCLE, EDF
25 // Module : SMESH
26 //
27 
28 #ifndef _SMESH_GEN_HXX_
29 #define _SMESH_GEN_HXX_
30 
31 #include "SMESH_SMESH.hxx"
32 
33 #include "SMESH_Exception.hxx"
34 
35 #include "SMESH_Hypothesis.hxx"
36 #include "SMESH_ComputeError.hxx"
37 #include "SMESH_Algo.hxx"
38 #include "SMESH_0D_Algo.hxx"
39 #include "SMESH_1D_Algo.hxx"
40 #include "SMESH_2D_Algo.hxx"
41 #include "SMESH_3D_Algo.hxx"
42 #include "SMESH_Mesh.hxx"
43 
44 #include <TopoDS_Shape.hxx>
45 
46 #include <map>
47 #include <list>
48 
50 
52 
53 typedef struct studyContextStruct
54 {
55  std::map < int, SMESH_Hypothesis * >mapHypothesis;
56  std::map < int, SMESH_Mesh * >mapMesh;
59 
60 typedef std::set<int> TSetOfInt;
61 
63 {
64  public:
65  SMESH_Gen();
66  ~SMESH_Gen();
67 
68  SMESH_Mesh* CreateMesh(int theStudyId, bool theIsEmbeddedMode)
69  throw(SMESH_Exception);
70 
78  bool Compute(::SMESH_Mesh & aMesh,
79  const TopoDS_Shape & aShape,
80  const bool anUpward=false,
82  TSetOfInt* aShapesId=0);
83 
84  bool CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
85  // notify on bad state of attached algos, return false
86  // if Compute() would fail because of some algo bad state
87 
92  void SetBoundaryBoxSegmentation( int theNbSegments ) { _segmentation = theNbSegments; }
93  int GetBoundaryBoxSegmentation() const { return _segmentation; }
97  void SetDefaultNbSegments(int nb) { _nbSegments = nb; }
98  int GetDefaultNbSegments() const { return _nbSegments; }
99 
101  {
104  int _algoDim;
106 
107  TAlgoStateError(): _algoDim(0),_algo(0),_name(SMESH_Hypothesis::HYP_OK) {}
108  void Set(TAlgoStateErrorName name, const SMESH_Algo* algo, bool isGlobal)
109  { _name = name; _algo = algo; _algoDim = algo->GetDim(); _isGlobalAlgo = isGlobal; }
110  void Set(TAlgoStateErrorName name, const int algoDim, bool isGlobal)
111  { _name = name; _algo = 0; _algoDim = algoDim; _isGlobalAlgo = isGlobal; }
112  };
113 
114  bool GetAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
115  std::list< SMESH_Gen::TAlgoStateError > & theErrors);
116  // notify on bad state of attached algos, return false
117  // if Compute() would fail because of some algo bad state
118  // theErrors list contains problems description
119 
120  StudyContextStruct *GetStudyContext(int studyId);
121 
122  static int GetShapeDim(const TopAbs_ShapeEnum & aShapeType);
123  static int GetShapeDim(const TopoDS_Shape & aShape)
124  { return GetShapeDim( aShape.ShapeType() ); }
125  SMESH_Algo* GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, TopoDS_Shape* assignedTo=0);
126  static bool IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh);
127 
128  // inherited methods from SALOMEDS::Driver
129 
130 // void Save(int studyId, const char *aUrlOfFile);
131 // void Load(int studyId, const char *aUrlOfFile);
132 // void Close(int studyId);
133 // const char *ComponentDataType();
134 
135 // const char *IORToLocalPersistentID(const char *IORString, bool & IsAFile);
136 // const char *LocalPersistentIDToIOR(const char *aLocalPersistentID);
137 
138  int GetANewId();
139 
140  std::map < int, SMESH_Algo * >_mapAlgo;
141  std::map < int, SMESH_0D_Algo * >_map0D_Algo;
142  std::map < int, SMESH_1D_Algo * >_map1D_Algo;
143  std::map < int, SMESH_2D_Algo * >_map2D_Algo;
144  std::map < int, SMESH_3D_Algo * >_map3D_Algo;
145 
146  private:
147 
148  int _localId; // unique Id of created objects, within SMESH_Gen entity
149  std::map < int, StudyContextStruct * >_mapStudyContext;
150 
151  // hypotheses managing
152  int _hypId;
153 
154  // number of segments per diagonal of boundary box of geometry by which
155  // default segment length of appropriate 1D hypotheses is defined
157  // default of segments
159 };
160 
161 #endif
int _nbSegments
Definition: SMESH_Gen.hxx:158
SMESHDS_Document * myDocument
Definition: SMESH_Gen.hxx:57
virtual int GetDim() const
std::map< int, SMESH_3D_Algo * > _map3D_Algo
Definition: SMESH_Gen.hxx:144
void Set(TAlgoStateErrorName name, const SMESH_Algo *algo, bool isGlobal)
Definition: SMESH_Gen.hxx:108
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:92
TAlgoStateErrorName _name
Definition: SMESH_Gen.hxx:102
int _localId
Definition: SMESH_Gen.hxx:148
std::map< int, StudyContextStruct * > _mapStudyContext
Definition: SMESH_Gen.hxx:149
void Set(TAlgoStateErrorName name, const int algoDim, bool isGlobal)
Definition: SMESH_Gen.hxx:110
struct studyContextStruct StudyContextStruct
int _segmentation
Definition: SMESH_Gen.hxx:156
std::map< int, SMESH_2D_Algo * > _map2D_Algo
Definition: SMESH_Gen.hxx:143
int GetDefaultNbSegments() const
Definition: SMESH_Gen.hxx:98
std::map< int, SMESH_1D_Algo * > _map1D_Algo
Definition: SMESH_Gen.hxx:142
void SetDefaultNbSegments(int nb)
Sets default number of segments per edge.
Definition: SMESH_Gen.hxx:97
int GetBoundaryBoxSegmentation() const
Definition: SMESH_Gen.hxx:93
MeshDimension
std::map< int, SMESH_Algo * > _mapAlgo
Definition: SMESH_Gen.hxx:140
std::map< int, SMESH_0D_Algo * > _map0D_Algo
Definition: SMESH_Gen.hxx:141
static int GetShapeDim(const TopoDS_Shape &aShape)
Definition: SMESH_Gen.hxx:123
const SMESH_Algo * _algo
Definition: SMESH_Gen.hxx:103
SMESH_Hypothesis::Hypothesis_Status TAlgoStateErrorName
Definition: SMESH_Gen.hxx:49
std::map< int, SMESH_Mesh * > mapMesh
Definition: SMESH_Gen.hxx:56
std::map< int, SMESH_Hypothesis * > mapHypothesis
Definition: SMESH_Gen.hxx:55
std::set< int > TSetOfInt
Definition: SMESH_Gen.hxx:60
#define SMESH_EXPORT