]> SALOME platform Git repositories - modules/geom.git/blob - src/XAO/XAO_Geometry.hxx
Salome HOME
0022307: implement workaround for OCC bug 0024263
[modules/geom.git] / src / XAO / XAO_Geometry.hxx
1 // Copyright (C) 2007-2012  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 : Nathalie Gore (OpenCascade)
20
21 #ifndef __XAO_GEOMETRY_HXX__
22 #define __XAO_GEOMETRY_HXX__
23
24 #include <string>
25
26 #include "XAO_XaoUtils.hxx"
27 #include "XAO_Exception.hxx"
28 #include "XAO_GeometricElement.hxx"
29
30 namespace XAO
31 {
32     /**
33      * @class Geometry
34      * Base class for geometries.
35      */
36     class Geometry
37     {
38     protected:
39         /**
40          * Constructor.
41          * @param name the name of the Geometry.
42          */
43         Geometry(const std::string& name);
44
45     public:
46
47         /**
48          * Creates a geometry.
49          * @param format the format of the geometry.
50          * @return the created geometry.
51          */
52         static Geometry* createGeometry(const XAO::Format& format) throw (XAO_Exception);
53
54         /**
55          * Constructor.
56          * Creates a geometry.
57          * @name name the name of the geometry.
58          * @return the created geometry.
59          */
60         static Geometry* createGeometry(const XAO::Format& format, const std::string& name)
61         throw (XAO_Exception);
62
63         /** Destructor. */
64         virtual ~Geometry();
65
66         /**
67          * Gets the name of the geometry.
68          * @return the name of the geometry.
69          */
70         const std::string getName()
71         {
72             return m_name;
73         }
74         /**
75          * Sets the name of the geometry.
76          * @param name the name to set.
77          */
78         void setName(const std::string& name)
79         {
80             m_name = name;
81         }
82
83         /**
84          * Gets the format of the geometry.
85          * @return the format of the geometry.
86          */
87         virtual const XAO::Format getFormat() = 0;
88
89         virtual const std::string getShapeString() = 0;
90         virtual void setShapeString(const std::string& shape) = 0;
91
92         const int countElements(const XAO::Dimension& dim) const throw (XAO_Exception);
93         const int countVertices() const { return m_vertices.getSize(); }
94         const int countEdges() const { return m_edges.getSize(); }
95         const int countFaces() const { return m_faces.getSize(); }
96         const int countSolids() const { return m_solids.getSize(); }
97
98         void setCountVertices(const int& nb) throw (XAO_Exception);
99         void setCountEdges(const int& nb) throw (XAO_Exception);
100         void setCountFaces(const int& nb) throw (XAO_Exception);
101         void setCountSolids(const int& nb) throw (XAO_Exception);
102
103         const std::string getVertexName(const int& index) throw (XAO_Exception) { return m_vertices.getName(index); }
104         const std::string getEdgeName(const int& index) throw (XAO_Exception) { return m_edges.getName(index); }
105         const std::string getFaceName(const int& index) throw (XAO_Exception) { return m_faces.getName(index); }
106         const std::string getSolidName(const int& index) throw (XAO_Exception) { return m_solids.getName(index); }
107
108         void setVertexName(const int& index, const std::string& name) throw (XAO_Exception) { m_vertices.setName(index, name); }
109         void setEdgeName(const int& index, const std::string& name) throw (XAO_Exception) { m_edges.setName(index, name); }
110         void setFaceName(const int& index, const std::string& name) throw (XAO_Exception) { m_faces.setName(index, name); }
111         void setSolidName(const int& index, const std::string& name) throw (XAO_Exception) { m_solids.setName(index, name); }
112
113         const bool hasVertexName(const int& index) throw (XAO_Exception) { return m_vertices.hasName(index); }
114         const bool hasEdgeName(const int& index) throw (XAO_Exception) { return m_edges.hasName(index); }
115         const bool hasFaceName(const int& index) throw (XAO_Exception) { return m_faces.hasName(index); }
116         const bool hasSolidName(const int& index) throw (XAO_Exception) { return m_solids.hasName(index); }
117
118         const std::string getVertexReference(const int& index) throw (XAO_Exception) { return m_vertices.getReference(index); }
119         const std::string getEdgeReference(const int& index) throw (XAO_Exception) { return m_edges.getReference(index); }
120         const std::string getFaceReference(const int& index) throw (XAO_Exception) { return m_faces.getReference(index); }
121         const std::string getSolidReference(const int& index) throw (XAO_Exception) { return m_solids.getReference(index); }
122         const std::string getElementReference(const XAO::Dimension& dim, const int& index) throw (XAO_Exception);
123
124         void setVertexReference(const int& index, const std::string& reference) throw (XAO_Exception);
125         void setEdgeReference(const int& index, const std::string& reference) throw (XAO_Exception);
126         void setFaceReference(const int& index, const std::string& reference) throw (XAO_Exception);
127         void setSolidReference(const int& index, const std::string& reference) throw (XAO_Exception);
128
129         void setVertex(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
130         void setEdge(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
131         void setFace(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
132         void setSolid(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
133
134         const int getVertexIndexByReference(const std::string& reference) { return m_vertices.getIndexByReference(reference); }
135         const int getEdgeIndexByReference(const std::string& reference) { return m_edges.getIndexByReference(reference); }
136         const int getFaceIndexByReference(const std::string& reference) { return m_faces.getIndexByReference(reference); }
137         const int getSolidIndexByReference(const std::string& reference) { return m_solids.getIndexByReference(reference); }
138         const int getElementIndexByReference(const XAO::Dimension& dim, const std::string& reference) throw (XAO_Exception);
139
140         GeometricElementList::iterator begin(const XAO::Dimension& dim) throw (XAO_Exception);
141         GeometricElementList::iterator end(const XAO::Dimension& dim) throw (XAO_Exception);
142
143         /**
144          * Verifies if the geometry is read only.
145          * @return true if the geometry is read only.
146          */
147         bool isReadOnly() { return m_readOnly; }
148
149         /**
150          * Sets the geometry read only.
151          */
152         void setReadOnly() { m_readOnly = true; }
153
154     protected:
155         void checkReadOnly() throw (XAO_Exception);
156
157     protected:
158         std::string m_name;
159         GeometricElementList m_vertices;
160         GeometricElementList m_edges;
161         GeometricElementList m_faces;
162         GeometricElementList m_solids;
163         bool m_readOnly;
164
165     };
166 }
167
168 #endif