SALOME - SMESH
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SMESH_Mesh.hxx
Go to the documentation of this file.
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_Mesh.hxx
00024 //  Author : Paul RASCLE, EDF
00025 //  Module : SMESH
00026 //
00027 #ifndef _SMESH_MESH_HXX_
00028 #define _SMESH_MESH_HXX_
00029 
00030 #include "SMESH_SMESH.hxx"
00031 
00032 #include "SMESH_Hypothesis.hxx"
00033 
00034 #include "SMESHDS_Mesh.hxx"
00035 #include "SMESHDS_Command.hxx"
00036 #include "SMDSAbs_ElementType.hxx"
00037 
00038 #include "Utils_SALOME_Exception.hxx"
00039 
00040 #include <TopoDS_Shape.hxx>
00041 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
00042 
00043 #include <list>
00044 #include <map>
00045 
00046 class SMESH_Gen;
00047 class SMESHDS_Document;
00048 class SMESH_Group;
00049 class TopTools_ListOfShape;
00050 class SMESH_subMesh;
00051 class SMESH_HypoFilter;
00052 class TopoDS_Solid;
00053 
00054 class SMESH_EXPORT SMESH_Mesh
00055 {
00056 public:
00057   SMESH_Mesh(int               theLocalId, 
00058              int               theStudyId, 
00059              SMESH_Gen*        theGen,
00060              bool              theIsEmbeddedMode,
00061              SMESHDS_Document* theDocument);
00062   
00063   virtual ~SMESH_Mesh();
00064   
00068   void ShapeToMesh(const TopoDS_Shape & aShape);
00072   TopoDS_Shape GetShapeToMesh() const;
00076   bool HasShapeToMesh() const { return _isShapeToMesh; }
00080   double GetShapeDiagonalSize() const;
00084   static double GetShapeDiagonalSize(const TopoDS_Shape & aShape);
00089   static const TopoDS_Solid& PseudoShape();
00090 
00094   void Clear();
00095 
00099   void ClearSubMesh(const int theShapeId);
00100 
00101   int UNVToMesh(const char* theFileName);
00105   int MEDToMesh(const char* theFileName, const char* theMeshName);
00106   
00107   int STLToMesh(const char* theFileName);
00108 
00109   int DATToMesh(const char* theFileName);
00110 
00111   SMESH_Hypothesis::Hypothesis_Status
00112   AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
00113     throw(SALOME_Exception);
00114   
00115   SMESH_Hypothesis::Hypothesis_Status
00116   RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
00117     throw(SALOME_Exception);
00118   
00119   const std::list <const SMESHDS_Hypothesis * >&
00120   GetHypothesisList(const TopoDS_Shape & aSubShape) const
00121     throw(SALOME_Exception);
00122 
00123   const SMESH_Hypothesis * GetHypothesis(const TopoDS_Shape &    aSubShape,
00124                                          const SMESH_HypoFilter& aFilter,
00125                                          const bool              andAncestors,
00126                                          TopoDS_Shape*           assignedTo=0) const;
00127   
00128   int GetHypotheses(const TopoDS_Shape &                     aSubShape,
00129                     const SMESH_HypoFilter&                  aFilter,
00130                     std::list <const SMESHDS_Hypothesis * >& aHypList,
00131                     const bool                               andAncestors) const;
00132 
00133   const std::list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);
00134   
00135   void ClearLog() throw(SALOME_Exception);
00136   
00137   int GetId()                { return _id; }
00138   
00139   SMESHDS_Mesh * GetMeshDS() { return _myMeshDS; }
00140   
00141   SMESH_Gen *GetGen()        { return _gen; }
00142   
00143   SMESH_subMesh *GetSubMesh(const TopoDS_Shape & aSubShape)
00144     throw(SALOME_Exception);
00145   
00146   SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape) const
00147     throw(SALOME_Exception);
00148   
00149   SMESH_subMesh *GetSubMeshContaining(const int aShapeID) const
00150     throw(SALOME_Exception);
00154   std::list<SMESH_subMesh*> GetGroupSubMeshesContaining(const TopoDS_Shape & shape) const
00155     throw(SALOME_Exception);
00159   void NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* theChangedHyp);
00160 
00161   const std::list < SMESH_subMesh * >&
00162   GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp) throw(SALOME_Exception);
00166   bool IsUsedHypothesis(SMESHDS_Hypothesis *  anHyp,
00167                         const SMESH_subMesh * aSubMesh);
00171   bool IsNotConformAllowed() const;
00172   
00173   bool IsMainShape(const TopoDS_Shape& theShape) const;
00178   const TopTools_ListOfShape& GetAncestors(const TopoDS_Shape& theSubShape) const;
00179 
00180   void SetAutoColor(bool theAutoColor) throw(SALOME_Exception);
00181 
00182   bool GetAutoColor() throw(SALOME_Exception);
00183 
00187   typedef TopTools_IndexedDataMapOfShapeListOfShape TAncestorMap;
00188   const TAncestorMap& GetAncestorMap() const { return _mapAncestors; }
00193   bool HasDuplicatedGroupNamesMED();
00194 
00195   void ExportMED(const char *file, 
00196                  const char* theMeshName = NULL, 
00197                  bool theAutoGroups = true, 
00198                  int theVersion = 0) 
00199     throw(SALOME_Exception);
00200 
00201   void ExportDAT(const char *file) throw(SALOME_Exception);
00202   void ExportUNV(const char *file) throw(SALOME_Exception);
00203   void ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception);
00204   
00205   int NbNodes() throw(SALOME_Exception);
00206   
00207   int Nb0DElements() throw(SALOME_Exception);
00208   
00209   int NbEdges(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
00210   
00211   int NbFaces(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
00212   
00213   int NbTriangles(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
00214   
00215   int NbQuadrangles(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
00216 
00217   int NbPolygons() throw(SALOME_Exception);
00218   
00219   int NbVolumes(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
00220   
00221   int NbTetras(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
00222   
00223   int NbHexas(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
00224   
00225   int NbPyramids(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
00226 
00227   int NbPrisms(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
00228   
00229   int NbPolyhedrons() throw(SALOME_Exception);
00230   
00231   int NbSubMesh() throw(SALOME_Exception);
00232   
00233   int NbGroup() const { return _mapGroup.size(); }
00234   
00235   SMESH_Group* AddGroup (const SMDSAbs_ElementType theType,
00236                          const char*               theName,
00237                          int&                      theId,
00238                          const TopoDS_Shape&       theShape=TopoDS_Shape());
00239   
00240   typedef boost::shared_ptr< SMDS_Iterator<SMESH_Group*> > GroupIteratorPtr;
00241   GroupIteratorPtr GetGroups() const;
00242   
00243   std::list<int> GetGroupIds() const;
00244   
00245   SMESH_Group* GetGroup (const int theGroupID);
00246 
00247   void RemoveGroup (const int theGroupID);
00248 
00249   SMESH_Group* ConvertToStandalone ( int theGroupID );
00250 
00251   SMDSAbs_ElementType GetElementType( const int id, const bool iselem );
00252 
00253   //
00254   
00255   ostream& Dump(ostream & save);
00256   
00257 private:
00258   
00259 protected:
00260   int                        _id;           // id given by creator (unique within the creator instance)
00261   int                        _studyId;
00262   int                        _idDoc;        // id given by SMESHDS_Document
00263   int                        _groupId;      // id generator for group objects
00264   int                        _nbSubShapes;  // initial nb of subshapes in the shape to mesh
00265   bool                       _isShapeToMesh;// set to true when a shape is given (only once)
00266   std::list <SMESH_subMesh*> _subMeshesUsingHypothesisList;
00267   SMESHDS_Document *         _myDocument;
00268   SMESHDS_Mesh *             _myMeshDS;
00269   std::map <int, SMESH_subMesh*> _mapSubMesh;
00270   std::map <int, SMESH_Group*>   _mapGroup;
00271   SMESH_Gen *                _gen;
00272 
00273   bool                       _isAutoColor;
00274 
00275   double                     _shapeDiagonal; 
00276   
00277   TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors;
00278 
00279 protected:
00280   SMESH_Mesh() {};
00281   SMESH_Mesh(const SMESH_Mesh&) {};
00282 };
00283 
00284 #endif