1 // Copyright (C) 2013 CEA/DEN, EDF R&D
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.
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)
71 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
74 const std::string Geometry::getElementReference(const XAO::Dimension& dim, const int& index)
77 if (dim == XAO::VERTEX)
78 return getVertexReference(index);
80 return getEdgeReference(index);
82 return getFaceReference(index);
83 if (dim == XAO::SOLID)
84 return getSolidReference(index);
86 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
89 const int Geometry::getElementIndexByReference(const XAO::Dimension& dim, const std::string& reference)
92 if (dim == XAO::VERTEX)
93 return getVertexIndexByReference(reference);
95 return getEdgeIndexByReference(reference);
97 return getFaceIndexByReference(reference);
98 if (dim == XAO::SOLID)
99 return getSolidIndexByReference(reference);
101 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
104 GeometricElementList::iterator Geometry::begin(const XAO::Dimension& dim)
105 throw (XAO_Exception)
107 if (dim == XAO::VERTEX)
108 return m_vertices.begin();
109 if (dim == XAO::EDGE)
110 return m_edges.begin();
111 if (dim == XAO::FACE)
112 return m_faces.begin();
113 if (dim == XAO::SOLID)
114 return m_solids.begin();
116 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
119 GeometricElementList::iterator Geometry::end(const XAO::Dimension& dim)
120 throw (XAO_Exception)
122 if (dim == XAO::VERTEX)
123 return m_vertices.end();
124 if (dim == XAO::EDGE)
125 return m_edges.end();
126 if (dim == XAO::FACE)
127 return m_faces.end();
128 if (dim == XAO::SOLID)
129 return m_solids.end();
131 throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
134 void Geometry::setCountVertices(const int& nb) throw (XAO_Exception)
137 m_vertices.setSize(nb);
139 void Geometry::setCountEdges(const int& nb) throw (XAO_Exception)
144 void Geometry::setCountFaces(const int& nb) throw (XAO_Exception)
149 void Geometry::setCountSolids(const int& nb) throw (XAO_Exception)
152 m_solids.setSize(nb);
155 void Geometry::setVertexReference(const int& index, const std::string& reference) throw (XAO_Exception)
158 m_vertices.setReference(index, reference);
160 void Geometry::setEdgeReference(const int& index, const std::string& reference) throw (XAO_Exception)
163 m_edges.setReference(index, reference);
165 void Geometry::setFaceReference(const int& index, const std::string& reference) throw (XAO_Exception)
168 m_faces.setReference(index, reference);
170 void Geometry::setSolidReference(const int& index, const std::string& reference) throw (XAO_Exception)
173 m_solids.setReference(index, reference);
176 void Geometry::setVertex(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception)
179 m_vertices.setElement(index, name, reference);
181 void Geometry::setEdge(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception)
184 m_edges.setElement(index, name, reference);
186 void Geometry::setFace(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception)
189 m_faces.setElement(index, name, reference);
191 void Geometry::setSolid(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception)
194 m_solids.setElement(index, name, reference);