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 : Frederic Pons (OpenCascade)
21 #include "XAO_GeometricElement.hxx"
22 #include "XAO_XaoUtils.hxx"
27 GeometricElement::GeometricElement()
33 GeometricElement::GeometricElement(const std::string& name, const std::string& reference)
36 m_reference = reference;
39 GeometricElement::~GeometricElement()
43 const bool GeometricElement::hasName()
45 return !m_name.empty();
48 GeometricElementList::GeometricElementList()
53 GeometricElementList::GeometricElementList(const int& count)
58 void GeometricElementList::setSize(const int& nb)
62 for (int i = 0; i < nb; ++i)
64 m_elements[i] = GeometricElement();
68 void GeometricElementList::checkElementIndex(const int& index) const
71 if (m_count >= 0 && index < m_count)
74 throw XAO_Exception(MsgBuilder() << "Index of element is out of range [0, "
75 << m_count-1 << "]: " << index);
78 void GeometricElementList::setElement(const int& index, const std::string& name, const std::string& reference)
81 checkElementIndex(index);
82 m_elements[index].setName(name);
83 m_elements[index].setReference(reference);
86 const std::string GeometricElementList::getName(const int& index)
89 checkElementIndex(index);
90 return m_elements[index].getName();
93 void GeometricElementList::setName(const int& index, const std::string& name)
96 checkElementIndex(index);
97 m_elements[index].setName(name);
100 const bool GeometricElementList::hasName(const int& index)
101 throw (XAO_Exception)
103 checkElementIndex(index);
104 return m_elements[index].hasName();
107 const std::string GeometricElementList::getReference(const int& index)
108 throw (XAO_Exception)
110 checkElementIndex(index);
111 return m_elements[index].getReference();
114 void GeometricElementList::setReference(const int& index, const std::string& name)
115 throw (XAO_Exception)
117 checkElementIndex(index);
118 m_elements[index].setReference(name);
121 const int GeometricElementList::getIndexByReference(const std::string& ref)
122 throw (XAO_Exception)
124 for (int index = 0; index < m_count; ++index)
126 if (ref == m_elements[index].getReference())
130 throw XAO_Exception(MsgBuilder() << "Reference not found: " << ref);