Back to index

salome-smesh  6.5.0
SMDS_MeshGroup.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 SMDS : implementaion of Salome mesh data structure
00024 //  File   : SMDS_MeshGroup.hxx
00025 //  Module : SMESH
00026 //
00027 #ifndef _SMDS_MeshGroup_HeaderFile
00028 #define _SMDS_MeshGroup_HeaderFile
00029 
00030 #include "SMESH_SMDS.hxx"
00031 
00032 #include "SMDS_Mesh.hxx"
00033 #include <set>
00034 
00035 class SMDS_EXPORT SMDS_MeshGroup:public SMDS_MeshObject
00036 {
00037   public:
00038         SMDS_MeshGroup(const SMDS_Mesh * theMesh,
00039                        const SMDSAbs_ElementType theType = SMDSAbs_All);
00040         const SMDS_MeshGroup * AddSubGroup
00041                       (const SMDSAbs_ElementType theType = SMDSAbs_All);
00042         virtual bool RemoveSubGroup(const SMDS_MeshGroup* theGroup);
00043         virtual bool RemoveFromParent();
00044 
00045         const SMDS_Mesh* GetMesh() const { return myMesh; }
00046 
00047         void SetType (const SMDSAbs_ElementType theType);
00048         void Clear();
00049         void Add(const SMDS_MeshElement * theElem);
00050         bool Remove(const SMDS_MeshElement * theElem);
00051         bool IsEmpty() const { return myElements.empty(); }
00052         int Extent() const { return myElements.size(); }
00053         int Tic() const { return myTic; }
00054 
00055         int SubGroupsNb() const { return myChildren.size(); }
00056 
00057         SMDSAbs_ElementType GetType() const { return myType; }
00058 
00059         bool Contains(const SMDS_MeshElement * theElem) const;
00060 
00061         void InitIterator() const
00062         { const_cast<TIterator&>(myIterator) = myElements.begin(); }
00063 
00064         bool More() const { return myIterator != myElements.end(); }
00065 
00066         const SMDS_MeshElement* Next() const
00067         { return *(const_cast<TIterator&>(myIterator))++; }
00068 
00069         void InitSubGroupsIterator() const
00070         { const_cast<TGroupIterator&>(myGroupIterator) = myChildren.begin(); }
00071 
00072         bool MoreSubGroups() const { return myGroupIterator != myChildren.end(); }
00073 
00074         const SMDS_MeshGroup* NextSubGroup() const
00075         { return *(const_cast<TGroupIterator&>(myGroupIterator))++; }
00076 
00077   private:
00078         SMDS_MeshGroup(SMDS_MeshGroup* theParent,
00079                        const SMDSAbs_ElementType theType = SMDSAbs_All);
00080 
00081         typedef std::set<const SMDS_MeshElement *>::const_iterator TIterator;
00082         typedef std::list<const SMDS_MeshGroup *>::const_iterator TGroupIterator;
00083 
00084         const SMDS_Mesh *                       myMesh;
00085         SMDSAbs_ElementType                     myType;
00086         std::set<const SMDS_MeshElement *>      myElements;
00087         SMDS_MeshGroup *                        myParent;
00088         std::list<const SMDS_MeshGroup*>        myChildren;
00089         TIterator                               myIterator;
00090         TGroupIterator                          myGroupIterator;
00091         int                                     myTic; // to track changes
00092 };
00093 #endif