Version: 9.13.0
XAO_Xao.hxx
Go to the documentation of this file.
1 // Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Nathalie Gore (OpenCascade), Frederic Pons (OpenCascade)
20 
21 #ifndef __XAO_XAO_HXX__
22 #define __XAO_XAO_HXX__
23 
24 #include <string>
25 #include <list>
26 
27 #include "XAO.hxx"
28 #include "XAO_Exception.hxx"
29 #include "XAO_XaoUtils.hxx"
30 #include "XAO_Geometry.hxx"
31 
32 #ifdef WIN32
33 #pragma warning(disable:4290) // Warning Exception ...
34 #pragma warning(disable:4251) // Warning dll-interface ...
35 #endif
36 
37 namespace XAO
38 {
39  class Group;
40  class Field;
41  class IntegerField;
42  class DoubleField;
43  class BooleanField;
44  class StringField;
45 
51  {
52  public:
56  Xao();
62  Xao(const std::string& author, const std::string& version);
66  virtual ~Xao();
67 
72  const std::string getAuthor() const
73  {
74  return m_author;
75  }
80  void setAuthor(const std::string& author)
81  {
82  m_author = author;
83  }
84 
89  const std::string getVersion() const
90  {
91  return m_version;
92  }
97  void setVersion(const std::string& version)
98  {
99  m_version = version;
100  }
101 
102  //
103  // Geometry
104  //
105 
111  {
112  return m_geometry;
113  }
118  void setGeometry(Geometry* geometry)
119  {
120  if (m_geometry != NULL)
121  throw XAO_Exception("Geometry already set.");
122  m_geometry = geometry;
123  m_geometry->setReadOnly();
124  }
125 
126  //
127  // Groups
128  //
129 
134  int countGroups() const;
140  Group* getGroup(int index) ;
147  Group* addGroup(XAO::Dimension dim, const std::string& name = std::string("")) ;
153  bool removeGroup(Group* group);
154 
155  //
156  // Fields
157  //
158 
163  int countFields() const;
164 
170  XAO::Type getFieldType(int index) ;
171 
177  Field* getField(int index) ;
178 
179  BooleanField* getBooleanField(int index) ;
180  DoubleField* getDoubleField(int index) ;
181  IntegerField* getIntegerField(int index) ;
182  StringField* getStringField(int index) ;
183 
192  Field* addField(XAO::Type type, XAO::Dimension dim, int nbComponents,
193  const std::string& name = std::string(""))
194  ;
195 
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("")) ;
204 
210  bool removeField(Field* field);
211 
212  //
213  // Import / Export
214  //
221  bool exportXAO(const std::string& fileName, const std::string& shapeFileName);
226  const std::string getXML();
227 
233  bool importXAO(const std::string& fileName);
239  bool setXML(const std::string& xml);
240 
241  private:
242  void checkGeometry() const ;
243  void checkGroupIndex(int index) const ;
244  void checkFieldIndex(int index) const ;
245  void checkGroupDimension(XAO::Dimension dim) const ;
246 
247  private:
249  std::string m_author;
251  std::string m_version;
255  std::list<Group*> m_groups;
257  std::list<Field*> m_fields;
258  };
259 
260 }
261 
262 #endif
#define XAO_EXPORT
Definition: XAO.hxx:31
Represents a field with boolean values.
Definition: XAO_BooleanField.hxx:43
Represents a field with double values.
Definition: XAO_DoubleField.hxx:43
A geometrical Field.
Definition: XAO_Field.hxx:46
Base class for geometries.
Definition: XAO_Geometry.hxx:43
void setReadOnly()
Sets the geometry read only.
Definition: XAO_Geometry.hxx:159
Class to represent a Geometrical Group.
Definition: XAO_Group.hxx:39
Represents a field with integer values.
Definition: XAO_IntegerField.hxx:43
Represents a field with string values.
Definition: XAO_StringField.hxx:42
Exception for XAO operations.
Definition: XAO_Exception.hxx:34
The Xao class describes the XAO format.
Definition: XAO_Xao.hxx:51
std::list< Field * > m_fields
The list of fields.
Definition: XAO_Xao.hxx:257
std::list< Group * > m_groups
The list of groups.
Definition: XAO_Xao.hxx:255
std::string m_version
The version of the file.
Definition: XAO_Xao.hxx:251
Geometry * m_geometry
The geometry.
Definition: XAO_Xao.hxx:253
std::string m_author
The author of the file.
Definition: XAO_Xao.hxx:249
Geometry * getGeometry() const
Gets the geometry.
Definition: XAO_Xao.hxx:110
const std::string getVersion() const
Gets the version of the file.
Definition: XAO_Xao.hxx:89
const std::string getAuthor() const
Gets the author of the file.
Definition: XAO_Xao.hxx:72
void setGeometry(Geometry *geometry)
Sets the geometry.
Definition: XAO_Xao.hxx:118
void setAuthor(const std::string &author)
Sets the author of the file.
Definition: XAO_Xao.hxx:80
void setVersion(const std::string &version)
Sets the version of the file.
Definition: XAO_Xao.hxx:97
Definition: BrepGeometryTest.hxx:26
Dimension
Definition: XAO_XaoUtils.hxx:50
Type
Definition: XAO_XaoUtils.hxx:62