1 // Copyright (C) 2013-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 #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(const XAO::Format& format)
36 return createGeometry(format, "");
39 Geometry* Geometry::createGeometry(const XAO::Format& format, const std::string& name)
42 if (format == XAO::BREP)
43 return new BrepGeometry(name);
45 throw XAO_Exception(MsgBuilder() << "Geometry format not supported: " << format);
52 void Geometry::checkReadOnly()
56 throw XAO_Exception("Geometry is read only.");
59 const int Geometry::countElements(const XAO::Dimension& dim) const
62 if (dim == XAO::VERTEX)
63 return countVertices();
68 if (dim == XAO::SOLID)
70 if (dim == XAO::WHOLE)
73 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
76 const std::string Geometry::getElementReference(const XAO::Dimension& dim, const int& index)
79 if (dim == XAO::VERTEX)
80 return getVertexReference(index);
82 return getEdgeReference(index);
84 return getFaceReference(index);
85 if (dim == XAO::SOLID)
86 return getSolidReference(index);
88 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
91 const int Geometry::getElementIndexByReference(const XAO::Dimension& dim, const std::string& reference)
94 if (dim == XAO::VERTEX)
95 return getVertexIndexByReference(reference);
97 return getEdgeIndexByReference(reference);
99 return getFaceIndexByReference(reference);
100 if (dim == XAO::SOLID)
101 return getSolidIndexByReference(reference);
103 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
106 GeometricElementList::iterator Geometry::begin(const XAO::Dimension& dim)
107 throw (XAO_Exception)
109 if (dim == XAO::VERTEX)
110 return m_vertices.begin();
111 if (dim == XAO::EDGE)
112 return m_edges.begin();
113 if (dim == XAO::FACE)
114 return m_faces.begin();
115 if (dim == XAO::SOLID)
116 return m_solids.begin();
118 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
121 GeometricElementList::iterator Geometry::end(const XAO::Dimension& dim)
122 throw (XAO_Exception)
124 if (dim == XAO::VERTEX)
125 return m_vertices.end();
126 if (dim == XAO::EDGE)
127 return m_edges.end();
128 if (dim == XAO::FACE)
129 return m_faces.end();
130 if (dim == XAO::SOLID)
131 return m_solids.end();
133 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
136 void Geometry::setCountVertices(const int& nb) throw (XAO_Exception)
139 m_vertices.setSize(nb);
141 void Geometry::setCountEdges(const int& nb) throw (XAO_Exception)
146 void Geometry::setCountFaces(const int& nb) throw (XAO_Exception)
151 void Geometry::setCountSolids(const int& nb) throw (XAO_Exception)
154 m_solids.setSize(nb);
157 void Geometry::setVertexReference(const int& index, const std::string& reference) throw (XAO_Exception)
160 m_vertices.setReference(index, reference);
162 void Geometry::setEdgeReference(const int& index, const std::string& reference) throw (XAO_Exception)
165 m_edges.setReference(index, reference);
167 void Geometry::setFaceReference(const int& index, const std::string& reference) throw (XAO_Exception)
170 m_faces.setReference(index, reference);
172 void Geometry::setSolidReference(const int& index, const std::string& reference) throw (XAO_Exception)
175 m_solids.setReference(index, reference);
178 void Geometry::setVertex(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception)
181 m_vertices.setElement(index, name, reference);
183 void Geometry::setEdge(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception)
186 m_edges.setElement(index, name, reference);
188 void Geometry::setFace(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception)
191 m_faces.setElement(index, name, reference);
193 void Geometry::setSolid(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception)
196 m_solids.setElement(index, name, reference);