#include <string>
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
#include "XAO_Field.hxx"
#include "XAO_BooleanStep.hxx"
//
// Author : Frederic Pons (OpenCascade)
-
#ifndef __XAO_BOOLEANSTEP_HXX__
#define __XAO_BOOLEANSTEP_HXX__
#include <vector>
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
#include "XAO_Step.hxx"
namespace XAO
#include <TopoDS_Shape.hxx>
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
#include "XAO_Geometry.hxx"
namespace XAO
#include <string>
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
#include "XAO_Field.hxx"
#include "XAO_DoubleStep.hxx"
//
// Author : Frederic Pons (OpenCascade)
-
#ifndef __XAO_DOUBLESTEP_HXX__
#define __XAO_DOUBLESTEP_HXX__
#include <vector>
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
#include "XAO_Step.hxx"
namespace XAO
-/*
- * XAO_Exception.hxx
- *
- * Created on: 12 sept. 2013
- * Author: salome
- */
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Frederic Pons (OpenCascade)
#ifndef __XAO_EXCEPTION_HXX__
#define __XAO_EXCEPTION_HXX__
namespace XAO
{
-
/**
* \class XAO_Exception
* Exception for XAO operations.
#include <string>
#include <vector>
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
#include "XAO_Step.hxx"
namespace XAO
Geometry::Geometry(const std::string& name)
: m_name(name)
{
+ m_readOnly = false;
}
Geometry* Geometry::createGeometry(const XAO::Format& format)
{
}
+void Geometry::checkReadOnly()
+throw (XAO_Exception)
+{
+ if (m_readOnly)
+ throw XAO_Exception("Geometry is read only.");
+}
+
const int Geometry::countElements(const XAO::Dimension& dim) const
throw (XAO_Exception)
{
throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
}
+
+void Geometry::setCountVertices(const int& nb) throw (XAO_Exception)
+{
+ checkReadOnly();
+ m_vertices.setSize(nb);
+}
+void Geometry::setCountEdges(const int& nb) throw (XAO_Exception)
+{
+ checkReadOnly();
+ m_edges.setSize(nb);
+}
+void Geometry::setCountFaces(const int& nb) throw (XAO_Exception)
+{
+ checkReadOnly();
+ m_faces.setSize(nb);
+}
+void Geometry::setCountSolids(const int& nb) throw (XAO_Exception)
+{
+ checkReadOnly();
+ m_solids.setSize(nb);
+}
+
+void Geometry::setVertexReference(const int& index, const std::string& reference) throw (XAO_Exception)
+{
+ checkReadOnly();
+ m_vertices.setReference(index, reference);
+}
+void Geometry::setEdgeReference(const int& index, const std::string& reference) throw (XAO_Exception)
+{
+ checkReadOnly();
+ m_edges.setReference(index, reference);
+}
+void Geometry::setFaceReference(const int& index, const std::string& reference) throw (XAO_Exception)
+{
+ checkReadOnly();
+ m_faces.setReference(index, reference);
+}
+void Geometry::setSolidReference(const int& index, const std::string& reference) throw (XAO_Exception)
+{
+ checkReadOnly();
+ m_solids.setReference(index, reference);
+}
+
+void Geometry::setVertex(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception)
+{
+ checkReadOnly();
+ m_vertices.setElement(index, name, reference);
+}
+void Geometry::setEdge(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception)
+{
+ checkReadOnly();
+ m_edges.setElement(index, name, reference);
+}
+void Geometry::setFace(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception)
+{
+ checkReadOnly();
+ m_faces.setElement(index, name, reference);
+}
+void Geometry::setSolid(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception)
+{
+ checkReadOnly();
+ m_solids.setElement(index, name, reference);
+}
#include <string>
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
+#include "XAO_Exception.hxx"
#include "XAO_GeometricElement.hxx"
namespace XAO
const int countFaces() const { return m_faces.getSize(); }
const int countSolids() const { return m_solids.getSize(); }
- void setCountVertices(const int& nb) { m_vertices.setSize(nb); }
- void setCountEdges(const int& nb) { m_edges.setSize(nb); }
- void setCountFaces(const int& nb) { m_faces.setSize(nb); }
- void setCountSolids(const int& nb) { m_solids.setSize(nb); }
+ void setCountVertices(const int& nb) throw (XAO_Exception);
+ void setCountEdges(const int& nb) throw (XAO_Exception);
+ void setCountFaces(const int& nb) throw (XAO_Exception);
+ void setCountSolids(const int& nb) throw (XAO_Exception);
const std::string getVertexName(const int& index) throw (XAO_Exception) { return m_vertices.getName(index); }
const std::string getEdgeName(const int& index) throw (XAO_Exception) { return m_edges.getName(index); }
const bool hasFaceName(const int& index) throw (XAO_Exception) { return m_faces.hasName(index); }
const bool hasSolidName(const int& index) throw (XAO_Exception) { return m_solids.hasName(index); }
- const std::string getVertexReference(const int& index) { return m_vertices.getReference(index); }
- const std::string getEdgeReference(const int& index) { return m_edges.getReference(index); }
- const std::string getFaceReference(const int& index) { return m_faces.getReference(index); }
- const std::string getSolidReference(const int& index) { return m_solids.getReference(index); }
+ const std::string getVertexReference(const int& index) throw (XAO_Exception) { return m_vertices.getReference(index); }
+ const std::string getEdgeReference(const int& index) throw (XAO_Exception) { return m_edges.getReference(index); }
+ const std::string getFaceReference(const int& index) throw (XAO_Exception) { return m_faces.getReference(index); }
+ const std::string getSolidReference(const int& index) throw (XAO_Exception) { return m_solids.getReference(index); }
const std::string getElementReference(const XAO::Dimension& dim, const int& index) throw (XAO_Exception);
- void setVertexReference(const int& index, const std::string& reference) { m_vertices.setReference(index, reference); }
- void setEdgeReference(const int& index, const std::string& reference) { m_edges.setReference(index, reference); }
- void setFaceReference(const int& index, const std::string& reference) { m_faces.setReference(index, reference); }
- void setSolidReference(const int& index, const std::string& reference) { m_solids.setReference(index, reference); }
+ void setVertexReference(const int& index, const std::string& reference) throw (XAO_Exception);
+ void setEdgeReference(const int& index, const std::string& reference) throw (XAO_Exception);
+ void setFaceReference(const int& index, const std::string& reference) throw (XAO_Exception);
+ void setSolidReference(const int& index, const std::string& reference) throw (XAO_Exception);
- void setVertex(const int& index, const std::string& name, const std::string& reference) { m_vertices.setElement(index, name, reference); }
- void setEdge(const int& index, const std::string& name, const std::string& reference) { m_edges.setElement(index, name, reference); }
- void setFace(const int& index, const std::string& name, const std::string& reference) { m_faces.setElement(index, name, reference); }
- void setSolid(const int& index, const std::string& name, const std::string& reference) { m_solids.setElement(index, name, reference); }
+ void setVertex(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
+ void setEdge(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
+ void setFace(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
+ void setSolid(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception);
const int getVertexIndexByReference(const std::string& reference) { return m_vertices.getIndexByReference(reference); }
const int getEdgeIndexByReference(const std::string& reference) { return m_edges.getIndexByReference(reference); }
GeometricElementList::iterator begin(const XAO::Dimension& dim) throw (XAO_Exception);
GeometricElementList::iterator end(const XAO::Dimension& dim) throw (XAO_Exception);
+ /**
+ * Verifies if the geometry is read only.
+ * @return true if the geometry is read only.
+ */
+ bool isReadOnly() { return m_readOnly; }
+
+ /**
+ * Sets the geometry read only.
+ */
+ void setReadOnly() { m_readOnly = true; }
+
+ protected:
+ void checkReadOnly() throw (XAO_Exception);
+
protected:
std::string m_name;
GeometricElementList m_vertices;
GeometricElementList m_edges;
GeometricElementList m_faces;
GeometricElementList m_solids;
+ bool m_readOnly;
};
}
#include <string>
#include <set>
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
namespace XAO
{
#include <string>
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
#include "XAO_Field.hxx"
#include "XAO_IntegerStep.hxx"
//
// Author : Frederic Pons (OpenCascade)
-
#ifndef __XAO_INTEGERSTEP_HXX__
#define __XAO_INTEGERSTEP_HXX__
#include <vector>
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
#include "XAO_Step.hxx"
namespace XAO
//
// Author : Frederic Pons (OpenCascade)
-
#ifndef __XAO_STEP_HXX__
#define __XAO_STEP_HXX__
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
namespace XAO
{
#include <string>
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
#include "XAO_Field.hxx"
#include "XAO_StringStep.hxx"
//
// Author : Frederic Pons (OpenCascade)
-
#ifndef __XAO_STRINGSTEP_HXX__
#define __XAO_STRINGSTEP_HXX__
#include <string>
#include <vector>
-#include "XAO_Xao.hxx"
+#include "XAO_XaoUtils.hxx"
#include "XAO_Step.hxx"
namespace XAO
#include <string>
#include <list>
#include "XAO_Exception.hxx"
+#include "XAO_XaoUtils.hxx"
+#include "XAO_Geometry.hxx"
namespace XAO
{
- /**
- * @enum Format
- */
- enum Format
- {
- BREP,
- STEP
- };
-
- /**
- * @enum Dimension
- */
- enum Dimension
- {
- VERTEX = 0,//!< VERTEX
- EDGE = 1, //!< EDGE
- FACE = 2, //!< FACE
- SOLID = 3, //!< SOLID
- WHOLE = -1 //!< WHOLE
- };
-
- /**
- * @enum Type
- */
- enum Type
- {
- BOOLEAN = 0,//!< BOOLEAN
- INTEGER = 1,//!< INTEGER
- DOUBLE = 2, //!< DOUBLE
- STRING = 3 //!< STRING
- };
-
- class Geometry;
class Group;
class Field;
* Sets the geometry.
* \param geometry the geometry to set.
*/
- void setGeometry(Geometry* geometry)
+ void setGeometry(Geometry* geometry) throw (XAO_Exception)
{
+ if (m_geometry != NULL)
+ throw XAO_Exception("Geometry already set.");
m_geometry = geometry;
+ m_geometry->setReadOnly();
}
//
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Frederic Pons (OpenCascade)
#include <libxml/parser.h>
+// Copyright (C) 2013 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Frederic Pons (OpenCascade)
#ifndef __XAO_XAOEXPORTER_HXX__
#define __XAO_XAOEXPORTER_HXX__
#include <string>
#include <exception>
-#include "XAO_Xao.hxx"
#include "XAO_Exception.hxx"
namespace XAO
{
+ /**
+ * @enum Format
+ */
+ enum Format
+ {
+ BREP,
+ STEP
+ };
+
+ /**
+ * @enum Dimension
+ */
+ enum Dimension
+ {
+ VERTEX = 0,//!< VERTEX
+ EDGE = 1, //!< EDGE
+ FACE = 2, //!< FACE
+ SOLID = 3, //!< SOLID
+ WHOLE = -1 //!< WHOLE
+ };
+
+ /**
+ * @enum Type
+ */
+ enum Type
+ {
+ BOOLEAN = 0,//!< BOOLEAN
+ INTEGER = 1,//!< INTEGER
+ DOUBLE = 2, //!< DOUBLE
+ STRING = 3 //!< STRING
+ };
+
/**
* \class XaoUtils
* Utilities class to convert types.
Xao xao("me", "1.0");
Geometry* geom = Geometry::createGeometry(XAO::BREP);
geom->setName("mygeom");
- xao.setGeometry(geom);
+ CPPUNIT_ASSERT_EQUAL(false, geom->isReadOnly());
// add elements
geom->setCountVertices(4);
geom->setCountSolids(1);
geom->setSolid(0, "s1", "10");
+ xao.setGeometry(geom);
+ CPPUNIT_ASSERT_EQUAL(true, geom->isReadOnly());
+
// groups
Group* group = xao.addGroup(XAO::SOLID);
group->setName("boite1");
void ImportExportTest::testGeometryError()
{
- Xao xao("me", "1.0");
Geometry* geom = Geometry::createGeometry(XAO::BREP);
geom->setName("mygeom");
- xao.setGeometry(geom);
-
geom->setCountVertices(2);
CPPUNIT_ASSERT_THROW(geom->setVertex(3, "v4", "4"), XAO_Exception);
+ delete geom;
}
void ImportExportTest::testImportXao()
checkImport(xao);
}
+void ImportExportTest::testImportXaoFromText()
+{
+ char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath("test.xao"));
+
+ Xao xao;
+ xao.setXML(txt);
+ checkImport(xao);
+}
+
void ImportExportTest::checkImport(Xao& xao)
{
CPPUNIT_ASSERT_EQUAL(std::string("me"), xao.getAuthor());
CPPUNIT_ASSERT_EQUAL(0, group->get(0));
CPPUNIT_ASSERT_EQUAL(1, group->get(1));
}
-
-void ImportExportTest::testImportXaoFromText()
-{
- char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath("test.xao"));
-
- Xao xao;
- xao.setXML(txt);
- checkImport(xao);
-}