SALOME - SMESH
|
00001 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE 00002 // 00003 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, 00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 00005 // 00006 // This library is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public 00008 // License as published by the Free Software Foundation; either 00009 // version 2.1 of the License. 00010 // 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public 00017 // License along with this library; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 // 00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com 00021 // 00022 // SMESH SMESH : implementaion of SMESH idl descriptions 00023 // File : SMESH_Gen.hxx 00024 // Author : Paul RASCLE, EDF 00025 // Module : SMESH 00026 // 00027 00028 #ifndef _SMESH_GEN_HXX_ 00029 #define _SMESH_GEN_HXX_ 00030 00031 #include "SMESH_SMESH.hxx" 00032 00033 #include "Utils_SALOME_Exception.hxx" 00034 00035 #include "SMESH_Hypothesis.hxx" 00036 #include "SMESH_ComputeError.hxx" 00037 #include "SMESH_Algo.hxx" 00038 #include "SMESH_0D_Algo.hxx" 00039 #include "SMESH_1D_Algo.hxx" 00040 #include "SMESH_2D_Algo.hxx" 00041 #include "SMESH_3D_Algo.hxx" 00042 #include "SMESH_Mesh.hxx" 00043 00044 #include <TopoDS_Shape.hxx> 00045 00046 #include <map> 00047 #include <list> 00048 00049 class SMESHDS_Document; 00050 00051 typedef SMESH_Hypothesis::Hypothesis_Status TAlgoStateErrorName; 00052 00053 typedef struct studyContextStruct 00054 { 00055 std::map < int, SMESH_Hypothesis * >mapHypothesis; 00056 std::map < int, SMESH_Mesh * >mapMesh; 00057 SMESHDS_Document * myDocument; 00058 } StudyContextStruct; 00059 00060 typedef std::set<int> TSetOfInt; 00061 00062 class SMESH_EXPORT SMESH_Gen 00063 { 00064 public: 00065 SMESH_Gen(); 00066 ~SMESH_Gen(); 00067 00068 SMESH_Mesh* CreateMesh(int theStudyId, bool theIsEmbeddedMode) 00069 throw(SALOME_Exception); 00070 00078 bool Compute(::SMESH_Mesh & aMesh, 00079 const TopoDS_Shape & aShape, 00080 const bool anUpward=false, 00081 const ::MeshDimension aDim=::MeshDim_3D, 00082 TSetOfInt* aShapesId=0); 00083 00091 bool Evaluate(::SMESH_Mesh & aMesh, 00092 const TopoDS_Shape & aShape, 00093 MapShapeNbElems& aResMap, 00094 const bool anUpward=false, 00095 TSetOfInt* aShapesId=0); 00096 00097 bool CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); 00098 // notify on bad state of attached algos, return false 00099 // if Compute() would fail because of some algo bad state 00100 00105 void SetBoundaryBoxSegmentation( int theNbSegments ) { _segmentation = theNbSegments; } 00106 int GetBoundaryBoxSegmentation() const { return _segmentation; } 00110 void SetDefaultNbSegments(int nb) { _nbSegments = nb; } 00111 int GetDefaultNbSegments() const { return _nbSegments; } 00112 00113 struct TAlgoStateError 00114 { 00115 TAlgoStateErrorName _name; 00116 const SMESH_Algo* _algo; 00117 int _algoDim; 00118 bool _isGlobalAlgo; 00119 00120 TAlgoStateError(): _algoDim(0),_algo(0),_name(SMESH_Hypothesis::HYP_OK) {} 00121 void Set(TAlgoStateErrorName name, const SMESH_Algo* algo, bool isGlobal) 00122 { _name = name; _algo = algo; _algoDim = algo->GetDim(); _isGlobalAlgo = isGlobal; } 00123 void Set(TAlgoStateErrorName name, const int algoDim, bool isGlobal) 00124 { _name = name; _algo = 0; _algoDim = algoDim; _isGlobalAlgo = isGlobal; } 00125 }; 00126 00127 bool GetAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, 00128 std::list< SMESH_Gen::TAlgoStateError > & theErrors); 00129 // notify on bad state of attached algos, return false 00130 // if Compute() would fail because of some algo bad state 00131 // theErrors list contains problems description 00132 00133 StudyContextStruct *GetStudyContext(int studyId); 00134 00135 static int GetShapeDim(const TopAbs_ShapeEnum & aShapeType); 00136 static int GetShapeDim(const TopoDS_Shape & aShape) 00137 { return GetShapeDim( aShape.ShapeType() ); } 00138 SMESH_Algo* GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, TopoDS_Shape* assignedTo=0); 00139 static bool IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh); 00140 00141 int GetANewId(); 00142 00143 std::map < int, SMESH_Algo * >_mapAlgo; 00144 std::map < int, SMESH_0D_Algo * >_map0D_Algo; 00145 std::map < int, SMESH_1D_Algo * >_map1D_Algo; 00146 std::map < int, SMESH_2D_Algo * >_map2D_Algo; 00147 std::map < int, SMESH_3D_Algo * >_map3D_Algo; 00148 00149 private: 00150 00151 int _localId; // unique Id of created objects, within SMESH_Gen entity 00152 std::map < int, StudyContextStruct * >_mapStudyContext; 00153 00154 // hypotheses managing 00155 int _hypId; 00156 00157 // number of segments per diagonal of boundary box of geometry by which 00158 // default segment length of appropriate 1D hypotheses is defined 00159 int _segmentation; 00160 // default of segments 00161 int _nbSegments; 00162 }; 00163 00164 #endif