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_Gen.hxx
25 // Author : Paul RASCLE, EDF
29 #ifndef _SMESH_GEN_HXX_
30 #define _SMESH_GEN_HXX_
32 #include "SMESH_SMESH.hxx"
34 #include "Utils_SALOME_Exception.hxx"
36 #include "SMESH_Hypothesis.hxx"
37 #include "SMESH_Algo.hxx"
38 #include "SMESH_1D_Algo.hxx"
39 #include "SMESH_2D_Algo.hxx"
40 #include "SMESH_3D_Algo.hxx"
41 #include "SMESH_Mesh.hxx"
43 #include "SMESHDS_Document.hxx"
45 #include <TopoDS_Shape.hxx>
50 typedef struct studyContextStruct
52 std::map < int, SMESH_Hypothesis * >mapHypothesis;
53 std::map < int, SMESH_Mesh * >mapMesh;
54 SMESHDS_Document * myDocument;
57 class SMESH_EXPORT SMESH_Gen
63 // SMESH_Hypothesis *CreateHypothesis(const char *anHyp, int studyId)
64 // throw(SALOME_Exception);
65 SMESH_Mesh* CreateMesh(int studyId)
66 throw(SALOME_Exception);
67 bool Compute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
69 bool CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
70 // notify on bad state of attached algos, return false
71 // if Compute() would fail because of some algo bad state
74 enum TAlgoStateErrorName { NONE=0, MISSING_ALGO, MISSING_HYPO, NOT_CONFORM_MESH };
75 struct TAlgoStateError
77 TAlgoStateErrorName _name;
78 const SMESH_Algo* _algo;
82 TAlgoStateError(): _algoDim(0),_algo(0),_name(NONE) {}
83 void Set(TAlgoStateErrorName name, const SMESH_Algo* algo, bool isGlobal)
84 { _name = name; _algo = algo; _algoDim = algo->GetDim(); _isGlobalAlgo = isGlobal; }
85 void Set(TAlgoStateErrorName name, const int algoDim, bool isGlobal)
86 { _name = name; _algo = 0; _algoDim = algoDim; _isGlobalAlgo = isGlobal; }
89 bool GetAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
90 std::list< SMESH_Gen::TAlgoStateError > & theErrors);
91 // notify on bad state of attached algos, return false
92 // if Compute() would fail because of some algo bad state
93 // theErrors list contains problems description
96 StudyContextStruct *GetStudyContext(int studyId);
98 static int GetShapeDim(const TopAbs_ShapeEnum & aShapeType);
99 static int GetShapeDim(const TopoDS_Shape & aShape)
100 { return GetShapeDim( aShape.ShapeType() ); }
101 SMESH_Algo* GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
102 static bool IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh);
104 // inherited methods from SALOMEDS::Driver
106 void Save(int studyId, const char *aUrlOfFile);
107 void Load(int studyId, const char *aUrlOfFile);
108 void Close(int studyId);
109 const char *ComponentDataType();
111 const char *IORToLocalPersistentID(const char *IORString, bool & IsAFile);
112 const char *LocalPersistentIDToIOR(const char *aLocalPersistentID);
116 std::map < int, SMESH_Algo * >_mapAlgo;
117 std::map < int, SMESH_1D_Algo * >_map1D_Algo;
118 std::map < int, SMESH_2D_Algo * >_map2D_Algo;
119 std::map < int, SMESH_3D_Algo * >_map3D_Algo;
123 int _localId; // unique Id of created objects, within SMESH_Gen entity
124 std::map < int, StudyContextStruct * >_mapStudyContext;
126 // hypotheses managing