1 // Copyright (C) 2007-2023 CEA, EDF
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(XAO::Format format) ;
63 * @name name the name of the geometry.
64 * @return the created geometry.
66 static Geometry* createGeometry(XAO::Format format, const std::string& name);
72 * Gets the name of the geometry.
73 * @return the name of the geometry.
75 const std::string getName()
80 * Sets the name of the geometry.
81 * @param name the name to set.
83 void setName(const std::string& name)
89 * Gets the format of the geometry.
90 * @return the format of the geometry.
92 virtual XAO::Format getFormat() = 0;
94 virtual const std::string getShapeString() = 0;
95 virtual void setShapeString(const std::string& shape) = 0;
96 virtual void writeShapeFile(const std::string& fileName) = 0;
97 virtual void readShapeFile(const std::string& fileName) = 0;
99 int countElements(XAO::Dimension dim) const ;
100 int countVertices() const { return m_vertices.getSize(); }
101 int countEdges() const { return m_edges.getSize(); }
102 int countFaces() const { return m_faces.getSize(); }
103 int countSolids() const { return m_solids.getSize(); }
105 void setCountVertices(int nb);
106 void setCountEdges(int nb);
107 void setCountFaces(int nb);
108 void setCountSolids(int nb);
110 const std::string getVertexName(int index) { return m_vertices.getName(index); }
111 const std::string getEdgeName(int index) { return m_edges.getName(index); }
112 const std::string getFaceName(int index) { return m_faces.getName(index); }
113 const std::string getSolidName(int index) { return m_solids.getName(index); }
115 void setVertexName(int index, const std::string& name) { m_vertices.setName(index, name); }
116 void setEdgeName(int index, const std::string& name) { m_edges.setName(index, name); }
117 void setFaceName(int index, const std::string& name) { m_faces.setName(index, name); }
118 void setSolidName(int index, const std::string& name) { m_solids.setName(index, name); }
120 bool hasVertexName(int index) { return m_vertices.hasName(index); }
121 bool hasEdgeName(int index) { return m_edges.hasName(index); }
122 bool hasFaceName(int index) { return m_faces.hasName(index); }
123 bool hasSolidName(int index) { return m_solids.hasName(index); }
125 const std::string getVertexReference(int index) { return m_vertices.getReference(index); }
126 const std::string getEdgeReference(int index) { return m_edges.getReference(index); }
127 const std::string getFaceReference(int index) { return m_faces.getReference(index); }
128 const std::string getSolidReference(int index) { return m_solids.getReference(index); }
129 const std::string getElementReference(XAO::Dimension dim, int index) ;
131 void setVertexReference(int index, const std::string& reference) ;
132 void setEdgeReference(int index, const std::string& reference) ;
133 void setFaceReference(int index, const std::string& reference) ;
134 void setSolidReference(int index, const std::string& reference) ;
136 void setVertex(int index, const std::string& name, const std::string& reference) ;
137 void setEdge(int index, const std::string& name, const std::string& reference) ;
138 void setFace(int index, const std::string& name, const std::string& reference) ;
139 void setSolid(int index, const std::string& name, const std::string& reference) ;
141 int getVertexIndexByReference(const std::string& reference) { return m_vertices.getIndexByReference(reference); }
142 int getEdgeIndexByReference(const std::string& reference) { return m_edges.getIndexByReference(reference); }
143 int getFaceIndexByReference(const std::string& reference) { return m_faces.getIndexByReference(reference); }
144 int getSolidIndexByReference(const std::string& reference) { return m_solids.getIndexByReference(reference); }
145 int getElementIndexByReference(XAO::Dimension dim, const std::string& reference) ;
147 GeometricElementList::iterator begin(XAO::Dimension dim) ;
148 GeometricElementList::iterator end(XAO::Dimension dim) ;
151 * Verifies if the geometry is read only.
152 * @return true if the geometry is read only.
154 bool isReadOnly() { return m_readOnly; }
157 * Sets the geometry read only.
159 void setReadOnly() { m_readOnly = true; }
162 void checkReadOnly() ;
166 GeometricElementList m_vertices;
167 GeometricElementList m_edges;
168 GeometricElementList m_faces;
169 GeometricElementList m_solids;