1 // Copyright (C) 2007-2019 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;
97 virtual void writeShapeFile(const std::string& fileName) = 0;
98 virtual void readShapeFile(const std::string& fileName) = 0;
100 const int countElements(const XAO::Dimension& dim) const throw (XAO_Exception);
101 const int countVertices() const { return m_vertices.getSize(); }
102 const int countEdges() const { return m_edges.getSize(); }
103 const int countFaces() const { return m_faces.getSize(); }
104 const int countSolids() const { return m_solids.getSize(); }
106 void setCountVertices(const int& nb) throw (XAO_Exception);
107 void setCountEdges(const int& nb) throw (XAO_Exception);
108 void setCountFaces(const int& nb) throw (XAO_Exception);
109 void setCountSolids(const int& nb) throw (XAO_Exception);
111 const std::string getVertexName(const int& index) throw (XAO_Exception) { return m_vertices.getName(index); }
112 const std::string getEdgeName(const int& index) throw (XAO_Exception) { return m_edges.getName(index); }
113 const std::string getFaceName(const int& index) throw (XAO_Exception) { return m_faces.getName(index); }
114 const std::string getSolidName(const int& index) throw (XAO_Exception) { return m_solids.getName(index); }
116 void setVertexName(const int& index, const std::string& name) throw (XAO_Exception) { m_vertices.setName(index, name); }
117 void setEdgeName(const int& index, const std::string& name) throw (XAO_Exception) { m_edges.setName(index, name); }
118 void setFaceName(const int& index, const std::string& name) throw (XAO_Exception) { m_faces.setName(index, name); }
119 void setSolidName(const int& index, const std::string& name) throw (XAO_Exception) { m_solids.setName(index, name); }
121 const bool hasVertexName(const int& index) throw (XAO_Exception) { return m_vertices.hasName(index); }
122 const bool hasEdgeName(const int& index) throw (XAO_Exception) { return m_edges.hasName(index); }
123 const bool hasFaceName(const int& index) throw (XAO_Exception) { return m_faces.hasName(index); }
124 const bool hasSolidName(const int& index) throw (XAO_Exception) { return m_solids.hasName(index); }
126 const std::string getVertexReference(const int& index) throw (XAO_Exception) { return m_vertices.getReference(index); }
127 const std::string getEdgeReference(const int& index) throw (XAO_Exception) { return m_edges.getReference(index); }
128 const std::string getFaceReference(const int& index) throw (XAO_Exception) { return m_faces.getReference(index); }
129 const std::string getSolidReference(const int& index) throw (XAO_Exception) { return m_solids.getReference(index); }
130 const std::string getElementReference(const XAO::Dimension& dim, const int& index) throw (XAO_Exception);
132 void setVertexReference(const int& index, const std::string& reference) throw (XAO_Exception);
133 void setEdgeReference(const int& index, const std::string& reference) throw (XAO_Exception);
134 void setFaceReference(const int& index, const std::string& reference) throw (XAO_Exception);
135 void setSolidReference(const int& index, const std::string& reference) throw (XAO_Exception);
137 void setVertex(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
138 void setEdge(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
139 void setFace(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
140 void setSolid(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
142 const int getVertexIndexByReference(const std::string& reference) { return m_vertices.getIndexByReference(reference); }
143 const int getEdgeIndexByReference(const std::string& reference) { return m_edges.getIndexByReference(reference); }
144 const int getFaceIndexByReference(const std::string& reference) { return m_faces.getIndexByReference(reference); }
145 const int getSolidIndexByReference(const std::string& reference) { return m_solids.getIndexByReference(reference); }
146 const int getElementIndexByReference(const XAO::Dimension& dim, const std::string& reference) throw (XAO_Exception);
148 GeometricElementList::iterator begin(const XAO::Dimension& dim) throw (XAO_Exception);
149 GeometricElementList::iterator end(const XAO::Dimension& dim) throw (XAO_Exception);
152 * Verifies if the geometry is read only.
153 * @return true if the geometry is read only.
155 bool isReadOnly() { return m_readOnly; }
158 * Sets the geometry read only.
160 void setReadOnly() { m_readOnly = true; }
163 void checkReadOnly() throw (XAO_Exception);
167 GeometricElementList m_vertices;
168 GeometricElementList m_edges;
169 GeometricElementList m_faces;
170 GeometricElementList m_solids;