Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _SMESH_MESH_HXX_
00029 #define _SMESH_MESH_HXX_
00030
00031 #include "SMESH_SMESH.hxx"
00032
00033 #include "SMESH_Hypothesis.hxx"
00034
00035 #include "SMESHDS_Mesh.hxx"
00036 #include "SMESHDS_Command.hxx"
00037 #include "SMDSAbs_ElementType.hxx"
00038
00039 #include "Utils_SALOME_Exception.hxx"
00040
00041 #include <TopoDS_Shape.hxx>
00042 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
00043
00044 #include <map>
00045 #include <list>
00046
00047 #ifdef WNT
00048 #pragma warning(disable:4251) // Warning DLL Interface ...
00049 #pragma warning(disable:4290) // Warning Exception ...
00050 #endif
00051
00052 class SMESH_Gen;
00053 class SMESHDS_Document;
00054 class SMESH_Group;
00055 class TopTools_ListOfShape;
00056 class SMESH_subMesh;
00057 class SMESH_HypoFilter;
00058 class TopoDS_Solid;
00059
00060 typedef std::list<int> TListOfInt;
00061 typedef std::list<TListOfInt> TListOfListOfInt;
00062
00063 class SMESH_EXPORT SMESH_Mesh
00064 {
00065 public:
00066 SMESH_Mesh(int theLocalId,
00067 int theStudyId,
00068 SMESH_Gen* theGen,
00069 bool theIsEmbeddedMode,
00070 SMESHDS_Document* theDocument);
00071
00072 virtual ~SMESH_Mesh();
00073
00077 void ShapeToMesh(const TopoDS_Shape & aShape);
00081 TopoDS_Shape GetShapeToMesh() const;
00085 bool HasShapeToMesh() const { return _isShapeToMesh; }
00089 double GetShapeDiagonalSize() const;
00093 static double GetShapeDiagonalSize(const TopoDS_Shape & aShape);
00098 static const TopoDS_Solid& PseudoShape();
00099
00103 void Clear();
00104
00108 void ClearSubMesh(const int theShapeId);
00109
00110 int UNVToMesh(const char* theFileName);
00114 int MEDToMesh(const char* theFileName, const char* theMeshName);
00115
00116 int STLToMesh(const char* theFileName);
00117
00118 SMESH_Hypothesis::Hypothesis_Status
00119 AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
00120 throw(SALOME_Exception);
00121
00122 SMESH_Hypothesis::Hypothesis_Status
00123 RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
00124 throw(SALOME_Exception);
00125
00126 const std::list <const SMESHDS_Hypothesis * >&
00127 GetHypothesisList(const TopoDS_Shape & aSubShape) const
00128 throw(SALOME_Exception);
00129
00130 const SMESH_Hypothesis * GetHypothesis(const TopoDS_Shape & aSubShape,
00131 const SMESH_HypoFilter& aFilter,
00132 const bool andAncestors,
00133 TopoDS_Shape* assignedTo=0) const;
00134
00135 int GetHypotheses(const TopoDS_Shape & aSubShape,
00136 const SMESH_HypoFilter& aFilter,
00137 std::list <const SMESHDS_Hypothesis * >& aHypList,
00138 const bool andAncestors) const;
00139
00140 const std::list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);
00141
00142 void ClearLog() throw(SALOME_Exception);
00143
00144 int GetId() const { return _id; }
00145
00146 SMESHDS_Mesh * GetMeshDS() { return _myMeshDS; }
00147
00148 const SMESHDS_Mesh * GetMeshDS() const { return _myMeshDS; }
00149
00150 SMESH_Gen *GetGen() { return _gen; }
00151
00152 SMESH_subMesh *GetSubMesh(const TopoDS_Shape & aSubShape)
00153 throw(SALOME_Exception);
00154
00155 SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape) const
00156 throw(SALOME_Exception);
00157
00158 SMESH_subMesh *GetSubMeshContaining(const int aShapeID) const
00159 throw(SALOME_Exception);
00163 std::list<SMESH_subMesh*> GetGroupSubMeshesContaining(const TopoDS_Shape & shape) const
00164 throw(SALOME_Exception);
00168 void NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* theChangedHyp);
00169
00170 const std::list < SMESH_subMesh * >&
00171 GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp) throw(SALOME_Exception);
00175 bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
00176 const SMESH_subMesh * aSubMesh);
00180 bool IsNotConformAllowed() const;
00181
00182 bool IsMainShape(const TopoDS_Shape& theShape) const;
00187 const TopTools_ListOfShape& GetAncestors(const TopoDS_Shape& theSubShape) const;
00188
00189 void SetAutoColor(bool theAutoColor) throw(SALOME_Exception);
00190
00191 bool GetAutoColor() throw(SALOME_Exception);
00192
00197 void SetIsModified(bool isModified);
00198
00199 bool GetIsModified() const { return _isModified; }
00200
00206 bool HasModificationsToDiscard() const;
00207
00211 typedef TopTools_IndexedDataMapOfShapeListOfShape TAncestorMap;
00212 const TAncestorMap& GetAncestorMap() const { return _mapAncestors; }
00217 bool HasDuplicatedGroupNamesMED();
00218
00219 void ExportMED(const char *file,
00220 const char* theMeshName = NULL,
00221 bool theAutoGroups = true,
00222 int theVersion = 0)
00223 throw(SALOME_Exception);
00224
00225 void ExportDAT(const char *file) throw(SALOME_Exception);
00226 void ExportUNV(const char *file) throw(SALOME_Exception);
00227 void ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception);
00228
00229 int NbNodes() const throw(SALOME_Exception);
00230
00231 int Nb0DElements() const throw(SALOME_Exception);
00232
00233 int NbEdges(SMDSAbs_ElementOrder order = ORDER_ANY) const throw(SALOME_Exception);
00234
00235 int NbFaces(SMDSAbs_ElementOrder order = ORDER_ANY) const throw(SALOME_Exception);
00236
00237 int NbTriangles(SMDSAbs_ElementOrder order = ORDER_ANY) const throw(SALOME_Exception);
00238
00239 int NbQuadrangles(SMDSAbs_ElementOrder order = ORDER_ANY) const throw(SALOME_Exception);
00240
00241 int NbPolygons() const throw(SALOME_Exception);
00242
00243 int NbVolumes(SMDSAbs_ElementOrder order = ORDER_ANY) const throw(SALOME_Exception);
00244
00245 int NbTetras(SMDSAbs_ElementOrder order = ORDER_ANY) const throw(SALOME_Exception);
00246
00247 int NbHexas(SMDSAbs_ElementOrder order = ORDER_ANY) const throw(SALOME_Exception);
00248
00249 int NbPyramids(SMDSAbs_ElementOrder order = ORDER_ANY) const throw(SALOME_Exception);
00250
00251 int NbPrisms(SMDSAbs_ElementOrder order = ORDER_ANY) const throw(SALOME_Exception);
00252
00253 int NbPolyhedrons() const throw(SALOME_Exception);
00254
00255 int NbSubMesh() const throw(SALOME_Exception);
00256
00257 int NbGroup() const { return _mapGroup.size(); }
00258
00259 SMESH_Group* AddGroup (const SMDSAbs_ElementType theType,
00260 const char* theName,
00261 int& theId,
00262 const TopoDS_Shape& theShape=TopoDS_Shape());
00263
00264 typedef boost::shared_ptr< SMDS_Iterator<SMESH_Group*> > GroupIteratorPtr;
00265 GroupIteratorPtr GetGroups() const;
00266
00267 std::list<int> GetGroupIds() const;
00268
00269 SMESH_Group* GetGroup (const int theGroupID);
00270
00271 bool RemoveGroup (const int theGroupID);
00272
00273 SMESH_Group* ConvertToStandalone ( int theGroupID );
00274
00275 struct TRmGroupCallUp
00276 {
00277 virtual void RemoveGroup (const int theGroupID)=0;
00278 virtual ~TRmGroupCallUp() {}
00279 };
00280 void SetRemoveGroupCallUp( TRmGroupCallUp * upCaller );
00281
00282
00283 SMDSAbs_ElementType GetElementType( const int id, const bool iselem );
00284
00285 void ClearMeshOrder();
00286 void SetMeshOrder(const TListOfListOfInt& theOrder );
00287 const TListOfListOfInt& GetMeshOrder() const;
00288
00294 bool SortByMeshOrder(std::list<SMESH_subMesh*>& theListToSort) const;
00295
00296
00297
00298 ostream& Dump(ostream & save);
00299
00300 private:
00301
00302 void fillAncestorsMap(const TopoDS_Shape& theShape);
00303 std::list<SMESH_subMesh*> getAncestorsSubMeshes
00304 (const TopoDS_Shape& theSubShape) const;
00305
00306 protected:
00307 int _id;
00308 int _studyId;
00309 int _idDoc;
00310 int _groupId;
00311 int _nbSubShapes;
00312 bool _isShapeToMesh;
00313 std::list <SMESH_subMesh*> _subMeshesUsingHypothesisList;
00314 SMESHDS_Document * _myDocument;
00315 SMESHDS_Mesh * _myMeshDS;
00316 SMESH_Gen * _gen;
00317 std::map <int, SMESH_subMesh*> _mapSubMesh;
00318 std::map <int, SMESH_Group*> _mapGroup;
00319
00320 bool _isAutoColor;
00321 bool _isModified;
00322
00323 double _shapeDiagonal;
00324
00325 TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors;
00326
00327 TListOfListOfInt _mySubMeshOrder;
00328
00329
00330
00331
00332 TRmGroupCallUp* _rmGroupCallUp;
00333
00334 protected:
00335 SMESH_Mesh();
00336 SMESH_Mesh(const SMESH_Mesh&) {};
00337 };
00338
00339 #endif