]> SALOME platform Git repositories - modules/geom.git/blob - src/XAO/XAO_XaoExporter.hxx
Salome HOME
Merge from BR_V7_main_Field branch (02/09/2013)
[modules/geom.git] / src / XAO / XAO_XaoExporter.hxx
1 // Copyright (C) 2013  CEA/DEN, EDF R&D
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.
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 : Frederic Pons (OpenCascade)
20
21 #ifndef __XAO_XAOEXPORTER_HXX__
22 #define __XAO_XAOEXPORTER_HXX__
23
24 #include <libxml/parser.h>
25
26 #include "XAO_Xao.hxx"
27 #include "XAO_Geometry.hxx"
28 #include "XAO_Group.hxx"
29 #include "XAO_Field.hxx"
30
31 namespace XAO
32 {
33     /**
34      * @class XaoExporter
35      * Util class for import/export XAO.
36      */
37     class XaoExporter
38     {
39     public:
40         /**
41          * Saves the XAO object to a file.
42          * @param xaoObject the object to export.
43          * @param fileName the path of the file to create.
44          * @return true if the export was successful, false otherwise.
45          */
46         static const bool saveToFile(Xao* xaoObject, const std::string& fileName)
47         throw (XAO_Exception);
48
49         /**
50          * Saves the XAO object to a XML string.
51          * @param xaoObject the object to export.
52          * @return the XML string.
53          */
54         static const std::string saveToXml(Xao* xaoObject)
55         throw (XAO_Exception);
56
57         /**
58          * Reads a XAO object from a file.
59          * @param fileName the path of the file to read.
60          * @param xaoObject the XAO object.
61          * @return true if the XAO object was read successful, false otherwise.
62          */
63         static const bool readFromFile(const std::string& fileName, Xao* xaoObject)
64         throw (XAO_Exception);
65
66         /**
67          * Reads a XAO object from an XML string.
68          * @param xml the XML string.
69          * @param xaoObject the XAO object.
70          * @return true if the XAO object was read successful, false otherwise.
71          */
72         static const bool setXML(const std::string& xml, Xao* xaoObject)
73         throw (XAO_Exception);
74
75     private:
76         static xmlDocPtr exportXMLDoc(Xao* xaoObject);
77         static void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao);
78         static void exportGeometricElements(Geometry* xaoGeometry, xmlNodePtr topology,
79                 XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag);
80         static void exportGroups(Xao* xaoObject, xmlNodePtr xao);
81         static void exportFields(Xao* xaoObject, xmlNodePtr xao);
82         static void exportStep(Step* step, Field* field, xmlNodePtr nodeSteps);
83
84         static void parseXMLDoc(xmlDocPtr doc, Xao* xaoObject);
85         static void parseXaoNode(xmlDocPtr doc, xmlNodePtr xaoNode, Xao* xaoObject);
86         static void parseGeometryNode(xmlDocPtr doc, xmlNodePtr geometryNode, Xao* xaoObject);
87         static void parseShapeNode(xmlDocPtr doc, xmlNodePtr shapeNode, Geometry* geometry);
88         static void parseTopologyNode(xmlNodePtr topologyNode, Geometry* geometry);
89         static void parseVerticesNode(xmlNodePtr verticesNode, Geometry* geometry);
90         static void parseEdgesNode(xmlNodePtr edgesNode, Geometry* geometry);
91         static void parseFacesNode(xmlNodePtr facesNode, Geometry* geometry);
92         static void parseSolidsNode(xmlNodePtr solidsNode, Geometry* geometry);
93         static void parseGroupsNode(xmlNodePtr groupsNode, Xao* xaoObject);
94         static void parseGroupNode(xmlNodePtr groupNode, Xao* xaoObject);
95
96         static void parseFieldsNode(xmlNodePtr fieldsNode, Xao* xaoObject);
97         static void parseFieldNode(xmlNodePtr fieldNode, Xao* xaoObject);
98         static void parseStepNode(xmlNodePtr stepNode, Field* field);
99         static void parseStepElementNode(xmlNodePtr eltNode, Step* step);
100
101         static std::string readStringProp(xmlNodePtr node, const xmlChar* attribute,
102                 const bool& required, const std::string& defaultValue, const std::string& exception = std::string(""));
103         static int readIntegerProp(xmlNodePtr node, const xmlChar* attribute,
104                 const bool& required, const int& defaultValue, const std::string& exception = std::string(""));
105     };
106 }
107
108
109 #endif /* __XAO_XAOEXPORTER_HXX__ */