Back to index

salome-smesh  6.5.0
SMESHDS_SubMesh.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  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 SMESHDS : management of mesh data and SMESH document
00024 //  File   : SMESHDS_SubMesh.hxx
00025 //  Module : SMESH
00026 //
00027 #ifndef _SMESHDS_SubMesh_HeaderFile
00028 #define _SMESHDS_SubMesh_HeaderFile
00029 
00030 #include "SMESH_SMESHDS.hxx"
00031 
00032 #include "SMDS_Mesh.hxx"
00033 #include <set>
00034 #include <vector>
00035 
00036 class SMESHDS_SubMesh;
00037 typedef SMDS_Iterator<const SMESHDS_SubMesh*> SMESHDS_SubMeshIterator;
00038 typedef boost::shared_ptr< SMESHDS_SubMeshIterator > SMESHDS_SubMeshIteratorPtr;
00039 
00040 class SMESHDS_Mesh;
00041 
00042 class SMESHDS_EXPORT SMESHDS_SubMesh
00043 {
00044  public:
00045   SMESHDS_SubMesh(SMESHDS_Mesh *parent, int index);
00046   virtual ~SMESHDS_SubMesh();
00047 
00048   virtual bool IsComplexSubmesh() const { return !mySubMeshes.empty(); }
00049 
00050   // if !IsComplexSubmesh()
00051   virtual void AddElement(const SMDS_MeshElement * ME);
00052   virtual bool RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted); // ret true if ME was in
00053   virtual void AddNode(const SMDS_MeshNode * ME);
00054   virtual bool RemoveNode(const SMDS_MeshNode * ME, bool isNodeDeleted);       // ret true if ME was in
00055 
00056   // if IsComplexSubmesh()
00057   void AddSubMesh( const SMESHDS_SubMesh* theSubMesh );
00058   bool RemoveSubMesh( const SMESHDS_SubMesh* theSubMesh );
00059   void RemoveAllSubmeshes();
00060   bool ContainsSubMesh( const SMESHDS_SubMesh* theSubMesh ) const;
00061   int  NbSubMeshes() const { return mySubMeshes.size(); }
00062   SMESHDS_SubMeshIteratorPtr GetSubMeshIterator() const;
00063 
00064   // for both types
00065   virtual int NbElements() const;
00066   virtual SMDS_ElemIteratorPtr GetElements() const;
00067   virtual int NbNodes() const;
00068   virtual SMDS_NodeIteratorPtr GetNodes() const;
00069   virtual bool Contains(const SMDS_MeshElement * ME) const;      // check if elem or node is in
00070 
00071   // clear the contents
00072   virtual void Clear();
00073   int getSize();
00074   void compactList();
00075 
00076   inline SMESHDS_Mesh *getParent() {return myParent; };
00077 
00078  private:
00079   SMESHDS_Mesh * myParent;
00080   std::vector<const SMDS_MeshElement*> myElements;
00081   std::vector<const SMDS_MeshNode*> myNodes;
00082 
00083   int myUnusedIdNodes;
00084   int myUnusedIdElements;
00085   int myIndex;
00086 
00087   std::set<const SMESHDS_SubMesh*> mySubMeshes;
00088 };
00089 #endif