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 : 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 bool GeometricElement::hasName()
45 return !m_name.empty();
48 GeometricElementList::GeometricElementList()
53 GeometricElementList::GeometricElementList(int count)
58 void GeometricElementList::setSize(int nb)
62 for (int i = 0; i < nb; ++i)
64 m_elements[i] = GeometricElement();
68 void GeometricElementList::checkElementIndex(int index) const
70 if (m_count >= 0 && index < m_count)
73 throw XAO_Exception(MsgBuilder() << "Index of element is out of range [0, "
74 << m_count-1 << "]: " << index);
77 void GeometricElementList::setElement(int index, const std::string& name, const std::string& reference)
79 checkElementIndex(index);
80 m_elements[index].setName(name);
81 m_elements[index].setReference(reference);
84 const std::string GeometricElementList::getName(int index)
86 checkElementIndex(index);
87 return m_elements[index].getName();
90 void GeometricElementList::setName(int index, const std::string& name)
92 checkElementIndex(index);
93 m_elements[index].setName(name);
96 bool GeometricElementList::hasName(int index)
98 checkElementIndex(index);
99 return m_elements[index].hasName();
102 const std::string GeometricElementList::getReference(int index)
104 checkElementIndex(index);
105 return m_elements[index].getReference();
108 void GeometricElementList::setReference(int index, const std::string& name)
110 checkElementIndex(index);
111 m_elements[index].setReference(name);
114 int GeometricElementList::getIndexByReference(const std::string& ref)
116 for (int index = 0; index < m_count; ++index)
118 if (ref == m_elements[index].getReference())
122 throw XAO_Exception(MsgBuilder() << "Reference not found: " << ref);