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