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.salome-platform.org/ or email : webmaster.salome@opencascade.com
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_ComputeError.hxx"
38 #include "SMESH_Algo.hxx"
39 #include "SMESH_0D_Algo.hxx"
40 #include "SMESH_1D_Algo.hxx"
41 #include "SMESH_2D_Algo.hxx"
42 #include "SMESH_3D_Algo.hxx"
43 #include "SMESH_Mesh.hxx"
45 #include <TopoDS_Shape.hxx>
49 class SMESHDS_Document;
51 typedef SMESH_Hypothesis::Hypothesis_Status TAlgoStateErrorName;
53 typedef struct studyContextStruct
55 std::map < int, SMESH_Hypothesis * >mapHypothesis;
56 std::map < int, SMESH_Mesh * >mapMesh;
57 SMESHDS_Document * myDocument;
60 class SMESH_EXPORT SMESH_Gen
66 SMESH_Mesh* CreateMesh(int theStudyId, bool theIsEmbeddedMode)
67 throw(SALOME_Exception);
70 * \brief Computes aMesh on aShape
71 * \param anUpward - compute from vertices up to more complex shape (internal usage)
72 * \retval bool - true if none submesh failed to compute
74 bool Compute(::SMESH_Mesh & aMesh,
75 const TopoDS_Shape & aShape,
76 const bool anUpward=false);
78 bool CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
79 // notify on bad state of attached algos, return false
80 // if Compute() would fail because of some algo bad state
83 struct TAlgoStateError
85 TAlgoStateErrorName _name;
86 const SMESH_Algo* _algo;
90 TAlgoStateError(): _algoDim(0),_algo(0),_name(SMESH_Hypothesis::HYP_OK) {}
91 void Set(TAlgoStateErrorName name, const SMESH_Algo* algo, bool isGlobal)
92 { _name = name; _algo = algo; _algoDim = algo->GetDim(); _isGlobalAlgo = isGlobal; }
93 void Set(TAlgoStateErrorName name, const int algoDim, bool isGlobal)
94 { _name = name; _algo = 0; _algoDim = algoDim; _isGlobalAlgo = isGlobal; }
97 bool GetAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
98 std::list< SMESH_Gen::TAlgoStateError > & theErrors);
99 // notify on bad state of attached algos, return false
100 // if Compute() would fail because of some algo bad state
101 // theErrors list contains problems description
103 StudyContextStruct *GetStudyContext(int studyId);
105 static int GetShapeDim(const TopAbs_ShapeEnum & aShapeType);
106 static int GetShapeDim(const TopoDS_Shape & aShape)
107 { return GetShapeDim( aShape.ShapeType() ); }
108 SMESH_Algo* GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, TopoDS_Shape* assignedTo=0);
109 static bool IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh);
111 // inherited methods from SALOMEDS::Driver
113 void Save(int studyId, const char *aUrlOfFile);
114 void Load(int studyId, const char *aUrlOfFile);
115 void Close(int studyId);
116 const char *ComponentDataType();
118 const char *IORToLocalPersistentID(const char *IORString, bool & IsAFile);
119 const char *LocalPersistentIDToIOR(const char *aLocalPersistentID);
123 std::map < int, SMESH_Algo * >_mapAlgo;
124 std::map < int, SMESH_0D_Algo * >_map0D_Algo;
125 std::map < int, SMESH_1D_Algo * >_map1D_Algo;
126 std::map < int, SMESH_2D_Algo * >_map2D_Algo;
127 std::map < int, SMESH_3D_Algo * >_map3D_Algo;
131 int _localId; // unique Id of created objects, within SMESH_Gen entity
132 std::map < int, StudyContextStruct * >_mapStudyContext;
134 // hypotheses managing