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 : Frederic Pons (OpenCascade)
21 #ifndef __XAO_GEOMETRICELEMENT_HXX__
22 #define __XAO_GEOMETRICELEMENT_HXX__
26 #include "XAO_Exception.hxx"
31 * \class GeometricElement
32 * Generic class to manipulate a topologic element (vertex, edge, face or solid).
34 class GeometricElement
38 * Default constructor.
42 * Constructor with name and reference.
43 * \param name the name of the element.
44 * \param reference the reference of the element.
46 GeometricElement(const std::string& name, const std::string& reference);
50 virtual ~GeometricElement();
53 * Gets the name of the element.
56 const std::string getName()
61 * Sets the name of the element
62 * \param name the name to set.
64 void setName(const std::string& name)
70 * Checks if the element has a name.
71 * @return true if the element has a name, false otherwise.
76 * Gets the reference of the element.
77 * \return the reference.
79 const std::string getReference()
84 * Sets the reference of the element.
85 * \param reference the reference to set.
87 void setReference(const std::string& reference)
89 m_reference = reference;
93 /** The name of the element. */
95 /** The reference of the element. */
96 std::string m_reference;
100 * \class GeometricElementList
101 * Generic class to manipulate a list of topologic element.
103 class GeometricElementList
107 * Default constructor.
109 GeometricElementList();
112 * Constructor with size.
113 * \param nb the size to set.
115 GeometricElementList(const int& nb);
120 virtual ~GeometricElementList() {}
123 * Gets the size of the list.
124 * \return the size of the list.
126 const int getSize() const { return m_count; }
129 * Sets the size of the list.
130 * \param nb the size to set.
131 * \warning the list will be cleared.
133 void setSize(const int& nb);
136 * Sets the name and the reference of an element.
137 * \param index the index of the element to set.
138 * \param name the name to set.
139 * \param reference the reference to set.
140 * \throw XAO_Exception if index is bigger than the size of the list.
142 void setElement(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
144 * Gets the name of an element.
145 * \param index the index of the element to set.
146 * \return the name of the element with the given index.
147 * \throw XAO_Exception if index is bigger than the size of the list.
149 const std::string getName(const int& index) throw (XAO_Exception);
151 * Sets the name of an element.
152 * \param index the index of the element.
153 * \param name the name to set.
154 * \throw XAO_Exception if index is bigger than the size of the list.
156 void setName(const int& index, const std::string& name) throw (XAO_Exception);
159 * Checks if an element has a name.
160 * @param index the index of the element.
161 * @return true if the element has a name, false otherwise.
163 const bool hasName(const int& index) throw (XAO_Exception);
166 * Gets the reference of an element.
167 * \param index the index of the element.
168 * \return the reference of the element.
169 * \throw XAO_Exception if index is bigger than the size of the list.
171 const std::string getReference(const int& index) throw (XAO_Exception);
173 * Sets the reference of an element.
174 * \param index the index of the element to set.
175 * \param reference the reference to set.
176 * \throw XAO_Exception if index is bigger than the size of the list.
178 void setReference(const int& index, const std::string& reference) throw (XAO_Exception);
181 * Gets the index of an element using its reference.
182 * \param reference the searched reference.
183 * \return the index of the element or -1 if no element found.
185 const int getIndexByReference(const std::string& reference) throw (XAO_Exception);
188 * Iterator on the element of the list.
190 typedef std::map<int, GeometricElement>::iterator iterator;
193 * Gets an iterator on the first element.
194 * @return an iterator on the first element.
196 iterator begin() { return m_elements.begin(); }
199 * Gets an iterator on the last element.
200 * @return an iterator on the last element.
202 iterator end() { return m_elements.end(); }
205 void checkElementIndex(const int& index) const throw (XAO_Exception);
209 std::map<int, GeometricElement> m_elements;
213 #endif /* __XAO_GEOMETRICELEMENT_HXX__ */