1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, 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)
21 #ifndef __XAO_GEOMETRY_HXX__
22 #define __XAO_GEOMETRY_HXX__
27 #include "XAO_XaoUtils.hxx"
28 #include "XAO_Exception.hxx"
29 #include "XAO_GeometricElement.hxx"
32 #pragma warning(disable:4290) // Warning Exception ...
40 * Base class for geometries.
42 class XAO_EXPORT Geometry
47 * @param name the name of the Geometry.
49 Geometry(const std::string& name);
55 * @param format the format of the geometry.
56 * @return the created geometry.
58 static Geometry* createGeometry(const XAO::Format& format) throw (XAO_Exception);
63 * @name name the name of the geometry.
64 * @return the created geometry.
66 static Geometry* createGeometry(const XAO::Format& format, const std::string& name)
67 throw (XAO_Exception);
73 * Gets the name of the geometry.
74 * @return the name of the geometry.
76 const std::string getName()
81 * Sets the name of the geometry.
82 * @param name the name to set.
84 void setName(const std::string& name)
90 * Gets the format of the geometry.
91 * @return the format of the geometry.
93 virtual const XAO::Format getFormat() = 0;
95 virtual const std::string getShapeString() = 0;
96 virtual void setShapeString(const std::string& shape) = 0;
98 const int countElements(const XAO::Dimension& dim) const throw (XAO_Exception);
99 const int countVertices() const { return m_vertices.getSize(); }
100 const int countEdges() const { return m_edges.getSize(); }
101 const int countFaces() const { return m_faces.getSize(); }
102 const int countSolids() const { return m_solids.getSize(); }
104 void setCountVertices(const int& nb) throw (XAO_Exception);
105 void setCountEdges(const int& nb) throw (XAO_Exception);
106 void setCountFaces(const int& nb) throw (XAO_Exception);
107 void setCountSolids(const int& nb) throw (XAO_Exception);
109 const std::string getVertexName(const int& index) throw (XAO_Exception) { return m_vertices.getName(index); }
110 const std::string getEdgeName(const int& index) throw (XAO_Exception) { return m_edges.getName(index); }
111 const std::string getFaceName(const int& index) throw (XAO_Exception) { return m_faces.getName(index); }
112 const std::string getSolidName(const int& index) throw (XAO_Exception) { return m_solids.getName(index); }
114 void setVertexName(const int& index, const std::string& name) throw (XAO_Exception) { m_vertices.setName(index, name); }
115 void setEdgeName(const int& index, const std::string& name) throw (XAO_Exception) { m_edges.setName(index, name); }
116 void setFaceName(const int& index, const std::string& name) throw (XAO_Exception) { m_faces.setName(index, name); }
117 void setSolidName(const int& index, const std::string& name) throw (XAO_Exception) { m_solids.setName(index, name); }
119 const bool hasVertexName(const int& index) throw (XAO_Exception) { return m_vertices.hasName(index); }
120 const bool hasEdgeName(const int& index) throw (XAO_Exception) { return m_edges.hasName(index); }
121 const bool hasFaceName(const int& index) throw (XAO_Exception) { return m_faces.hasName(index); }
122 const bool hasSolidName(const int& index) throw (XAO_Exception) { return m_solids.hasName(index); }
124 const std::string getVertexReference(const int& index) throw (XAO_Exception) { return m_vertices.getReference(index); }
125 const std::string getEdgeReference(const int& index) throw (XAO_Exception) { return m_edges.getReference(index); }
126 const std::string getFaceReference(const int& index) throw (XAO_Exception) { return m_faces.getReference(index); }
127 const std::string getSolidReference(const int& index) throw (XAO_Exception) { return m_solids.getReference(index); }
128 const std::string getElementReference(const XAO::Dimension& dim, const int& index) throw (XAO_Exception);
130 void setVertexReference(const int& index, const std::string& reference) throw (XAO_Exception);
131 void setEdgeReference(const int& index, const std::string& reference) throw (XAO_Exception);
132 void setFaceReference(const int& index, const std::string& reference) throw (XAO_Exception);
133 void setSolidReference(const int& index, const std::string& reference) throw (XAO_Exception);
135 void setVertex(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
136 void setEdge(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
137 void setFace(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
138 void setSolid(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
140 const int getVertexIndexByReference(const std::string& reference) { return m_vertices.getIndexByReference(reference); }
141 const int getEdgeIndexByReference(const std::string& reference) { return m_edges.getIndexByReference(reference); }
142 const int getFaceIndexByReference(const std::string& reference) { return m_faces.getIndexByReference(reference); }
143 const int getSolidIndexByReference(const std::string& reference) { return m_solids.getIndexByReference(reference); }
144 const int getElementIndexByReference(const XAO::Dimension& dim, const std::string& reference) throw (XAO_Exception);
146 GeometricElementList::iterator begin(const XAO::Dimension& dim) throw (XAO_Exception);
147 GeometricElementList::iterator end(const XAO::Dimension& dim) throw (XAO_Exception);
150 * Verifies if the geometry is read only.
151 * @return true if the geometry is read only.
153 bool isReadOnly() { return m_readOnly; }
156 * Sets the geometry read only.
158 void setReadOnly() { m_readOnly = true; }
161 void checkReadOnly() throw (XAO_Exception);
165 GeometricElementList m_vertices;
166 GeometricElementList m_edges;
167 GeometricElementList m_faces;
168 GeometricElementList m_solids;