1 // Copyright (C) 2013-2024 CEA, EDF, 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_XAO_HXX__
22 #define __XAO_XAO_HXX__
28 #include "XAO_Exception.hxx"
29 #include "XAO_XaoUtils.hxx"
30 #include "XAO_Geometry.hxx"
33 #pragma warning(disable:4290) // Warning Exception ...
34 #pragma warning(disable:4251) // Warning dll-interface ...
48 * The Xao class describes the XAO format.
54 * Default constructor.
58 * Constructor with author and version.
59 * \param author the author of the file.
60 * \param version the version of the XAO format.
62 Xao(const std::string& author, const std::string& version);
69 * Gets the author of the file.
70 * \return the author of the file.
72 const std::string getAuthor() const
77 * Sets the author of the file.
78 * \param author the author to set.
80 void setAuthor(const std::string& author)
86 * Gets the version of the file.
87 * \return the version of the file.
89 const std::string getVersion() const
94 * Sets the version of the file.
95 * \param version the version to set.
97 void setVersion(const std::string& version)
108 * \return the geometry.
110 Geometry* getGeometry() const
116 * \param geometry the geometry to set.
118 void setGeometry(Geometry* geometry)
120 if (m_geometry != NULL)
121 throw XAO_Exception("Geometry already set.");
122 m_geometry = geometry;
123 m_geometry->setReadOnly();
131 * Gets the number of groups.
132 * \return the number of groups.
134 int countGroups() const;
137 * \param index the index of the wanted group.
140 Group* getGroup(int index) ;
143 * \param dim the dimension of the group.
144 * \param name the name of the group.
145 * \return the created group.
147 Group* addGroup(XAO::Dimension dim, const std::string& name = std::string("")) ;
150 * \param group the group to remove.
151 * \return true if the group has been removed, false otherwise.
153 bool removeGroup(Group* group);
160 * Gets the number of fields.
161 * \return the number of fields.
163 int countFields() const;
166 * Gets the type of a field.
167 * \param index the index of the wanted field.
168 * \return the type of the field.
170 XAO::Type getFieldType(int index) ;
174 * \param index the index of the wanted field.
177 Field* getField(int index) ;
179 BooleanField* getBooleanField(int index) ;
180 DoubleField* getDoubleField(int index) ;
181 IntegerField* getIntegerField(int index) ;
182 StringField* getStringField(int index) ;
186 * \param type the type of the field.
187 * \param dim the dimension of the field.
188 * \param nbComponents the number of components in the field.
189 * \param name the name of the field.
190 * \return the created field.
192 Field* addField(XAO::Type type, XAO::Dimension dim, int nbComponents,
193 const std::string& name = std::string(""))
196 BooleanField* addBooleanField(XAO::Dimension dim, int nbComponents,
197 const std::string& name = std::string("")) ;
198 IntegerField* addIntegerField(XAO::Dimension dim, int nbComponents,
199 const std::string& name = std::string("")) ;
200 DoubleField* addDoubleField(XAO::Dimension dim, int nbComponents,
201 const std::string& name = std::string("")) ;
202 StringField* addStringField(XAO::Dimension dim, int nbComponents,
203 const std::string& name = std::string("")) ;
207 * \param field the field to remove.
208 * \return true if the field has been removed, false otherwise.
210 bool removeField(Field* field);
216 * Exports this XAO object to a file.
217 * \param fileName the name of the file to create.
218 * \param shapeFileName if not empty, export the shape to this external file.
219 * \return true is the export is successful.
221 bool exportXAO(const std::string& fileName, const std::string& shapeFileName);
223 * Gets the XML corresponding to this XAO.
224 * \return the XML as a string.
226 const std::string getXML();
229 * Imports an XAO file into this object.
230 * \param fileName the name of the file to import.
231 * \return true if the import is successful.
233 bool importXAO(const std::string& fileName);
235 * Sets an XML describing an XAO format to this object.
236 * \param xml the XML to set.
237 * \return true if the import is successful.
239 bool setXML(const std::string& xml);
242 void checkGeometry() const ;
243 void checkGroupIndex(int index) const ;
244 void checkFieldIndex(int index) const ;
245 void checkGroupDimension(XAO::Dimension dim) const ;
248 /** The author of the file. */
249 std::string m_author;
250 /** The version of the file. */
251 std::string m_version;
253 Geometry* m_geometry;
254 /** The list of groups. */
255 std::list<Group*> m_groups;
256 /** The list of fields. */
257 std::list<Field*> m_fields;