SHAPER  9.12.0
XAO_Group.hxx
1 // Copyright (C) 2013-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Nathalie Gore (OpenCascade), Frederic Pons (OpenCascade)
20 
21 #ifndef __XAO_GROUP_HXX__
22 #define __XAO_GROUP_HXX__
23 
24 #include <string>
25 #include <set>
26 
27 #include "XAO.hxx"
28 #include "XAO_XaoUtils.hxx"
29 #ifdef WIN32
30 #pragma warning(disable:4251) // Warning dll-interface ...
31 #endif
32 namespace XAO
33 {
38  class XAO_EXPORT Group
39  {
40  public:
47  Group(XAO::Dimension dim, int nbElements, const std::string& name = std::string(""));
48 
52  virtual ~Group();
53 
58  const std::string getName()
59  {
60  return m_name;
61  }
66  void setName(const std::string& name)
67  {
68  m_name = name;
69  }
70 
75  XAO::Dimension getDimension()
76  {
77  return m_dimension;
78  }
79 
85  {
86  return m_nbElements;
87  }
88 
93  int count() const
94  {
95  return m_elements.size();
96  }
97 
104  int get(int index)
105  {
106  checkIndex(index);
107  std::set<int>::iterator it = m_elements.begin();
108  std::advance(it, index);
109  return (*it);
110  }
111 
116  void add(int value);
117 
122  void remove(int value);
123 
128  std::set<int>::iterator begin() { return m_elements.begin(); }
129 
134  std::set<int>::iterator end() { return m_elements.end(); }
135 
136  private:
142  void checkIndex(int element);
143 
144  private:
146  std::string m_name;
148  int m_nbElements;
150  XAO::Dimension m_dimension;
152  int m_count;
154  std::set<int> m_elements;
155  };
156 }
157 
158 #endif
Class to represent a Geometrical Group.
Definition: XAO_Group.hxx:39
XAO::Dimension getDimension()
Gets the dimension of the group.
Definition: XAO_Group.hxx:75
int count() const
Gets the number of elements in the group.
Definition: XAO_Group.hxx:93
void setName(const std::string &name)
Sets the name of the group.
Definition: XAO_Group.hxx:66
const std::string getName()
Gets the name of the group.
Definition: XAO_Group.hxx:58
int get(int index)
Gets the reference of an element.
Definition: XAO_Group.hxx:104
std::set< int >::iterator end()
Gets an iterator on the last element in the group.
Definition: XAO_Group.hxx:134
int getNbElements()
Gets the numbers of elements in the geometry of the same type than the group.
Definition: XAO_Group.hxx:84
std::set< int >::iterator begin()
Gets an iterator on the first element in the group.
Definition: XAO_Group.hxx:128