Version: 6.3.1

src/SMESH/SMESH_Mesh.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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 
00023 //  SMESH SMESH : implementaion of SMESH idl descriptions
00024 //  File   : SMESH_Mesh.hxx
00025 //  Author : Paul RASCLE, EDF
00026 //  Module : SMESH
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;           // id given by creator (unique within the creator instance)
00308   int                        _studyId;
00309   int                        _idDoc;        // id given by SMESHDS_Document
00310   int                        _groupId;      // id generator for group objects
00311   int                        _nbSubShapes;  // initial nb of subshapes in the shape to mesh
00312   bool                       _isShapeToMesh;// set to true when a shape is given (only once)
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   // Struct calling RemoveGroup at CORBA API implementation level, used
00330   // to make an upper level be consistent with a lower one when group removal
00331   // is invoked by hyp modification 
00332   TRmGroupCallUp*            _rmGroupCallUp;
00333 
00334 protected:
00335   SMESH_Mesh();
00336   SMESH_Mesh(const SMESH_Mesh&) {};
00337 };
00338 
00339 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS