1 // Copyright (C) 2013-2024 CEA, EDF, 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 #include "XAO_XaoUtils.hxx"
22 #include "XAO_Geometry.hxx"
23 #include "XAO_BrepGeometry.hxx"
27 Geometry::Geometry(const std::string& name)
33 Geometry* Geometry::createGeometry(XAO::Format format)
35 return createGeometry(format, "");
38 Geometry* Geometry::createGeometry(XAO::Format format, const std::string& name)
40 if (format == XAO::BREP)
41 return new BrepGeometry(name);
43 throw XAO_Exception(MsgBuilder() << "Geometry format not supported: " << format);
50 void Geometry::checkReadOnly()
53 throw XAO_Exception("Geometry is read only.");
56 int Geometry::countElements(XAO::Dimension dim) const
58 if (dim == XAO::VERTEX)
59 return countVertices();
64 if (dim == XAO::SOLID)
66 if (dim == XAO::WHOLE)
69 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
72 const std::string Geometry::getElementReference(XAO::Dimension dim, int index)
74 if (dim == XAO::VERTEX)
75 return getVertexReference(index);
77 return getEdgeReference(index);
79 return getFaceReference(index);
80 if (dim == XAO::SOLID)
81 return getSolidReference(index);
83 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
86 int Geometry::getElementIndexByReference(XAO::Dimension dim, const std::string& reference)
88 if (dim == XAO::VERTEX)
89 return getVertexIndexByReference(reference);
91 return getEdgeIndexByReference(reference);
93 return getFaceIndexByReference(reference);
94 if (dim == XAO::SOLID)
95 return getSolidIndexByReference(reference);
97 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
100 GeometricElementList::iterator Geometry::begin(XAO::Dimension dim)
102 if (dim == XAO::VERTEX)
103 return m_vertices.begin();
104 if (dim == XAO::EDGE)
105 return m_edges.begin();
106 if (dim == XAO::FACE)
107 return m_faces.begin();
108 if (dim == XAO::SOLID)
109 return m_solids.begin();
111 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
114 GeometricElementList::iterator Geometry::end(XAO::Dimension dim)
116 if (dim == XAO::VERTEX)
117 return m_vertices.end();
118 if (dim == XAO::EDGE)
119 return m_edges.end();
120 if (dim == XAO::FACE)
121 return m_faces.end();
122 if (dim == XAO::SOLID)
123 return m_solids.end();
125 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
128 void Geometry::setCountVertices(int nb)
131 m_vertices.setSize(nb);
133 void Geometry::setCountEdges(int nb)
138 void Geometry::setCountFaces(int nb)
143 void Geometry::setCountSolids(int nb)
146 m_solids.setSize(nb);
149 void Geometry::setVertexReference(int index, const std::string& reference)
152 m_vertices.setReference(index, reference);
154 void Geometry::setEdgeReference(int index, const std::string& reference)
157 m_edges.setReference(index, reference);
159 void Geometry::setFaceReference(int index, const std::string& reference)
162 m_faces.setReference(index, reference);
164 void Geometry::setSolidReference(int index, const std::string& reference)
167 m_solids.setReference(index, reference);
170 void Geometry::setVertex(int index, const std::string& name, const std::string& reference)
173 m_vertices.setElement(index, name, reference);
175 void Geometry::setEdge(int index, const std::string& name, const std::string& reference)
178 m_edges.setElement(index, name, reference);
180 void Geometry::setFace(int index, const std::string& name, const std::string& reference)
183 m_faces.setElement(index, name, reference);
185 void Geometry::setSolid(int index, const std::string& name, const std::string& reference)
188 m_solids.setElement(index, name, reference);