1 // Copyright (C) 2013 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Nathalie Gore (OpenCascade), Frederic Pons (OpenCascade)
21 #ifndef __XAO_GROUP_HXX__
22 #define __XAO_GROUP_HXX__
27 #include "XAO_XaoUtils.hxx"
33 * Class to represent a Geometrical Group.
40 * @param dim the dimension of the group.
41 * @param nbElements the number of geometrical elements for the dimension in the geometry.
42 * @param name the name of the group.
44 Group(const XAO::Dimension& dim, const int& nbElements, const std::string& name = std::string(""))
45 throw (XAO_Exception);
53 * Gets the name of the group.
54 * \return the name of the group.
56 const std::string getName()
61 * Sets the name of the group.
62 * \param name the name to set.
64 void setName(const std::string& name)
70 * Gets the dimension of the group.
71 * \return the dimension of the group.
73 const XAO::Dimension getDimension()
79 * Gets the numbers of elements in the geometry of the same type than the group.
80 * \return the number of elements in the associated geometry.
82 const int getNbElements()
88 * Gets the number of elements in the group.
89 * \return the number of elements.
91 const int count() const
93 return m_elements.size();
97 * Gets the reference of an element.
98 * \param index the index of the element.
99 * \return the reference of the element.
100 * \note use begin() and end() if you need to iterate.
102 const int get(const int& index)
105 std::set<int>::iterator it = m_elements.begin();
106 std::advance(it, index);
111 * Adds an element to the group.
112 * \param value the index of the element to add.
114 void add(const int& value);
117 * Removes an element from the group.
118 * \param value the index of the element to remove.
120 void remove(const int& value);
123 * Gets an iterator on the first element in the group.
124 * @return an iterator on the first element.
126 std::set<int>::iterator begin() { return m_elements.begin(); }
129 * Gets an iterator on the last element in the group.
130 * @return an iterator on the last element.
132 std::set<int>::iterator end() { return m_elements.end(); }
136 * Ensures that the given element is valid.
138 * @throw XAO_Exception if element is bigger than the number of elements.
140 void checkIndex(const int& element)
141 throw (XAO_Exception);
144 /** The name of the group. */
146 /** The number of elements in the associated geometry. */
148 /** The dimension of the group. */
149 XAO::Dimension m_dimension;
150 /** The number of elements in the group. */
152 /** The elements of the group. */
153 std::set<int> m_elements;