1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D
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.
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)
21 #ifndef __XAO_GEOMETRY_HXX__
22 #define __XAO_GEOMETRY_HXX__
26 #include "XAO_XaoUtils.hxx"
27 #include "XAO_Exception.hxx"
28 #include "XAO_GeometricElement.hxx"
34 * Base class for geometries.
41 * @param name the name of the Geometry.
43 Geometry(const std::string& name);
49 * @param format the format of the geometry.
50 * @return the created geometry.
52 static Geometry* createGeometry(const XAO::Format& format) throw (XAO_Exception);
57 * @name name the name of the geometry.
58 * @return the created geometry.
60 static Geometry* createGeometry(const XAO::Format& format, const std::string& name)
61 throw (XAO_Exception);
67 * Gets the name of the geometry.
68 * @return the name of the geometry.
70 const std::string getName()
75 * Sets the name of the geometry.
76 * @param name the name to set.
78 void setName(const std::string& name)
84 * Gets the format of the geometry.
85 * @return the format of the geometry.
87 virtual const XAO::Format getFormat() = 0;
89 virtual const std::string getShapeString() = 0;
90 virtual void setShapeString(const std::string& shape) = 0;
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(); }
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);
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); }
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); }
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); }
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);
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);
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);
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);
140 GeometricElementList::iterator begin(const XAO::Dimension& dim) throw (XAO_Exception);
141 GeometricElementList::iterator end(const XAO::Dimension& dim) throw (XAO_Exception);
144 * Verifies if the geometry is read only.
145 * @return true if the geometry is read only.
147 bool isReadOnly() { return m_readOnly; }
150 * Sets the geometry read only.
152 void setReadOnly() { m_readOnly = true; }
155 void checkReadOnly() throw (XAO_Exception);
159 GeometricElementList m_vertices;
160 GeometricElementList m_edges;
161 GeometricElementList m_faces;
162 GeometricElementList m_solids;