1 // Copyright (C) 2013-2019 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 : Frederic Pons (OpenCascade)
21 #ifndef __XAO_GEOMETRICELEMENT_HXX__
22 #define __XAO_GEOMETRICELEMENT_HXX__
28 #include "XAO_Exception.hxx"
31 #pragma warning(disable:4290) // Warning Exception ...
32 #pragma warning(disable:4251) // Warning dll-interface ...
39 * \class GeometricElement
40 * Generic class to manipulate a topologic element (vertex, edge, face or solid).
42 class XAO_EXPORT GeometricElement
46 * Default constructor.
50 * Constructor with name and reference.
51 * \param name the name of the element.
52 * \param reference the reference of the element.
54 GeometricElement(const std::string& name, const std::string& reference);
58 virtual ~GeometricElement();
61 * Gets the name of the element.
64 const std::string getName()
69 * Sets the name of the element
70 * \param name the name to set.
72 void setName(const std::string& name)
78 * Checks if the element has a name.
79 * @return true if the element has a name, false otherwise.
84 * Gets the reference of the element.
85 * \return the reference.
87 const std::string getReference()
92 * Sets the reference of the element.
93 * \param reference the reference to set.
95 void setReference(const std::string& reference)
97 m_reference = reference;
101 /** The name of the element. */
103 /** The reference of the element. */
104 std::string m_reference;
108 * \class GeometricElementList
109 * Generic class to manipulate a list of topologic element.
111 class XAO_EXPORT GeometricElementList
115 * Default constructor.
117 GeometricElementList();
120 * Constructor with size.
121 * \param nb the size to set.
123 GeometricElementList(const int& nb);
128 virtual ~GeometricElementList() {}
131 * Gets the size of the list.
132 * \return the size of the list.
134 const int getSize() const { return m_count; }
137 * Sets the size of the list.
138 * \param nb the size to set.
139 * \warning the list will be cleared.
141 void setSize(const int& nb);
144 * Sets the name and the reference of an element.
145 * \param index the index of the element to set.
146 * \param name the name to set.
147 * \param reference the reference to set.
148 * \throw XAO_Exception if index is bigger than the size of the list.
150 void setElement(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
152 * Gets the name of an element.
153 * \param index the index of the element to set.
154 * \return the name of the element with the given index.
155 * \throw XAO_Exception if index is bigger than the size of the list.
157 const std::string getName(const int& index) throw (XAO_Exception);
159 * Sets the name of an element.
160 * \param index the index of the element.
161 * \param name the name to set.
162 * \throw XAO_Exception if index is bigger than the size of the list.
164 void setName(const int& index, const std::string& name) throw (XAO_Exception);
167 * Checks if an element has a name.
168 * @param index the index of the element.
169 * @return true if the element has a name, false otherwise.
171 const bool hasName(const int& index) throw (XAO_Exception);
174 * Gets the reference of an element.
175 * \param index the index of the element.
176 * \return the reference of the element.
177 * \throw XAO_Exception if index is bigger than the size of the list.
179 const std::string getReference(const int& index) throw (XAO_Exception);
181 * Sets the reference of an element.
182 * \param index the index of the element to set.
183 * \param reference the reference to set.
184 * \throw XAO_Exception if index is bigger than the size of the list.
186 void setReference(const int& index, const std::string& reference) throw (XAO_Exception);
189 * Gets the index of an element using its reference.
190 * \param reference the searched reference.
191 * \return the index of the element or -1 if no element found.
193 const int getIndexByReference(const std::string& reference) throw (XAO_Exception);
196 * Iterator on the element of the list.
198 typedef std::map<int, GeometricElement>::iterator iterator;
201 * Gets an iterator on the first element.
202 * @return an iterator on the first element.
204 iterator begin() { return m_elements.begin(); }
207 * Gets an iterator on the last element.
208 * @return an iterator on the last element.
210 iterator end() { return m_elements.end(); }
213 void checkElementIndex(const int& index) const throw (XAO_Exception);
217 std::map<int, GeometricElement> m_elements;
221 #endif /* __XAO_GEOMETRICELEMENT_HXX__ */