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 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 00054 int SubGroupsNb() const { return myChildren.size(); } 00055 00056 SMDSAbs_ElementType GetType() const { return myType; } 00057 00058 bool Contains(const SMDS_MeshElement * theElem) const; 00059 00060 void InitIterator() const 00061 { const_cast<TIterator&>(myIterator) = myElements.begin(); } 00062 00063 bool More() const { return myIterator != myElements.end(); } 00064 00065 const SMDS_MeshElement* Next() const 00066 { return *(const_cast<TIterator&>(myIterator))++; } 00067 00068 void InitSubGroupsIterator() const 00069 { const_cast<TGroupIterator&>(myGroupIterator) = myChildren.begin(); } 00070 00071 bool MoreSubGroups() const { return myGroupIterator != myChildren.end(); } 00072 00073 const SMDS_MeshGroup* NextSubGroup() const 00074 { return *(const_cast<TGroupIterator&>(myGroupIterator))++; } 00075 00076 private: 00077 SMDS_MeshGroup(SMDS_MeshGroup* theParent, 00078 const SMDSAbs_ElementType theType = SMDSAbs_All); 00079 00080 typedef std::set<const SMDS_MeshElement *>::const_iterator TIterator; 00081 typedef std::list<const SMDS_MeshGroup *>::const_iterator TGroupIterator; 00082 00083 const SMDS_Mesh * myMesh; 00084 SMDSAbs_ElementType myType; 00085 std::set<const SMDS_MeshElement *> myElements; 00086 SMDS_MeshGroup * myParent; 00087 std::list<const SMDS_MeshGroup*> myChildren; 00088 TIterator myIterator; 00089 TGroupIterator myGroupIterator; 00090 }; 00091 #endif