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__
28 #include "XAO_XaoUtils.hxx"
30 #pragma warning(disable:4251) // Warning dll-interface ...
36 * Class to represent a Geometrical Group.
38 class XAO_EXPORT Group
43 * @param dim the dimension of the group.
44 * @param nbElements the number of geometrical elements for the dimension in the geometry.
45 * @param name the name of the group.
47 Group(const XAO::Dimension& dim, const int& nbElements, const std::string& name = std::string(""))
48 throw (XAO_Exception);
56 * Gets the name of the group.
57 * \return the name of the group.
59 const std::string getName()
64 * Sets the name of the group.
65 * \param name the name to set.
67 void setName(const std::string& name)
73 * Gets the dimension of the group.
74 * \return the dimension of the group.
76 const XAO::Dimension getDimension()
82 * Gets the numbers of elements in the geometry of the same type than the group.
83 * \return the number of elements in the associated geometry.
85 const int getNbElements()
91 * Gets the number of elements in the group.
92 * \return the number of elements.
94 const int count() const
96 return m_elements.size();
100 * Gets the reference of an element.
101 * \param index the index of the element.
102 * \return the reference of the element.
103 * \note use begin() and end() if you need to iterate.
105 const int get(const int& index)
108 std::set<int>::iterator it = m_elements.begin();
109 std::advance(it, index);
114 * Adds an element to the group.
115 * \param value the index of the element to add.
117 void add(const int& value);
120 * Removes an element from the group.
121 * \param value the index of the element to remove.
123 void remove(const int& value);
126 * Gets an iterator on the first element in the group.
127 * @return an iterator on the first element.
129 std::set<int>::iterator begin() { return m_elements.begin(); }
132 * Gets an iterator on the last element in the group.
133 * @return an iterator on the last element.
135 std::set<int>::iterator end() { return m_elements.end(); }
139 * Ensures that the given element is valid.
141 * @throw XAO_Exception if element is bigger than the number of elements.
143 void checkIndex(const int& element)
144 throw (XAO_Exception);
147 /** The name of the group. */
149 /** The number of elements in the associated geometry. */
151 /** The dimension of the group. */
152 XAO::Dimension m_dimension;
153 /** The number of elements in the group. */
155 /** The elements of the group. */
156 std::set<int> m_elements;