1 // Copyright (C) 2013-2023 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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(XAO::Dimension dim, int nbElements, const std::string& name = std::string(""));
55 * Gets the name of the group.
56 * \return the name of the group.
58 const std::string getName()
63 * Sets the name of the group.
64 * \param name the name to set.
66 void setName(const std::string& name)
72 * Gets the dimension of the group.
73 * \return the dimension of the group.
75 XAO::Dimension getDimension()
81 * Gets the numbers of elements in the geometry of the same type than the group.
82 * \return the number of elements in the associated geometry.
90 * Gets the number of elements in the group.
91 * \return the number of elements.
95 return m_elements.size();
99 * Gets the reference of an element.
100 * \param index the index of the element.
101 * \return the reference of the element.
102 * \note use begin() and end() if you need to iterate.
107 std::set<int>::iterator it = m_elements.begin();
108 std::advance(it, index);
113 * Adds an element to the group.
114 * \param value the index of the element to add.
119 * Removes an element from the group.
120 * \param value the index of the element to remove.
122 void remove(int value);
125 * Gets an iterator on the first element in the group.
126 * @return an iterator on the first element.
128 std::set<int>::iterator begin() { return m_elements.begin(); }
131 * Gets an iterator on the last element in the group.
132 * @return an iterator on the last element.
134 std::set<int>::iterator end() { return m_elements.end(); }
138 * Ensures that the given element is valid.
140 * @throw XAO_Exception if element is bigger than the number of elements.
142 void checkIndex(int element);
145 /** The name of the group. */
147 /** The number of elements in the associated geometry. */
149 /** The dimension of the group. */
150 XAO::Dimension m_dimension;
151 /** The number of elements in the group. */
153 /** The elements of the group. */
154 std::set<int> m_elements;