From 94561d0210320ae152a7384c3ad3409d5aa080b9 Mon Sep 17 00:00:00 2001 From: fps Date: Fri, 30 Aug 2013 14:13:47 +0000 Subject: [PATCH] add BrepGeometry --- .../GEOMImpl_IImportExportOperations.cxx | 2 +- src/XAO/BooleanField.cxx | 5 + src/XAO/BooleanField.hxx | 1 + src/XAO/BooleanStep.cxx | 2 +- src/XAO/BrepGeometry.cxx | 242 ++++++++++++ src/XAO/BrepGeometry.hxx | 89 +++++ src/XAO/DoubleField.cxx | 5 + src/XAO/DoubleField.hxx | 1 + src/XAO/Field.cxx | 17 + src/XAO/Field.hxx | 27 +- src/XAO/Geometry.cxx | 86 ++-- src/XAO/Geometry.hxx | 67 +++- src/XAO/Group.cxx | 6 +- src/XAO/Group.hxx | 5 + src/XAO/IntegerField.cxx | 5 + src/XAO/IntegerField.hxx | 3 +- src/XAO/Makefile.am | 2 + src/XAO/Step.cxx | 30 +- src/XAO/Step.hxx | 51 ++- src/XAO/StringField.cxx | 5 + src/XAO/StringField.hxx | 1 + src/XAO/Xao.hxx | 20 +- src/XAO/XaoExporter.cxx | 337 ++++++++++------ src/XAO/XaoExporter.hxx | 10 + src/XAO/XaoUtils.cxx | 54 ++- src/XAO/XaoUtils.hxx | 19 +- src/XAO/tests/BrepGeometryTest.cxx | 50 +++ src/XAO/tests/BrepGeometryTest.hxx | 25 ++ src/XAO/tests/FieldTest.cxx | 4 +- src/XAO/tests/ImportExportTest.cxx | 59 +-- src/XAO/tests/Makefile.am | 1 + src/XAO/tests/TestUtils.hxx | 43 ++ src/XAO/tests/XAOTests.cxx | 2 + src/XAO/tests/data/Box_1.brep | 366 ++++++++++++++++++ src/XAO/tests/data/test.xao | 25 ++ 35 files changed, 1415 insertions(+), 252 deletions(-) create mode 100644 src/XAO/BrepGeometry.cxx create mode 100644 src/XAO/BrepGeometry.hxx create mode 100644 src/XAO/tests/BrepGeometryTest.cxx create mode 100644 src/XAO/tests/BrepGeometryTest.hxx create mode 100644 src/XAO/tests/TestUtils.hxx create mode 100644 src/XAO/tests/data/Box_1.brep diff --git a/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx b/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx index 03eb3003f..c724fed90 100644 --- a/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx @@ -176,7 +176,7 @@ bool GEOMImpl_IImportExportOperations::ExportXAO(Handle(GEOM_Object) shape, XAO::Xao* xaoObject = new XAO::Xao(); xaoObject->setAuthor(author); - XAO::Geometry* geometry = new XAO::Geometry(); + XAO::Geometry* geometry = XAO::Geometry::createGeometry(XAO::BREP); TopoDS_Shape topoShape = shape->GetValue(); exportFunction->SetValue(topoShape); geometry->setShape(topoShape); diff --git a/src/XAO/BooleanField.cxx b/src/XAO/BooleanField.cxx index 5bfdd9cc6..8f77a6e66 100644 --- a/src/XAO/BooleanField.cxx +++ b/src/XAO/BooleanField.cxx @@ -35,6 +35,11 @@ BooleanField::BooleanField(const std::string& name, const XAO::Dimension& dimens { } +Step* BooleanField::addNewStep(const int& step) +{ + return addStep(step); +} + BooleanStep* BooleanField::addStep(const int& step) { BooleanStep* bstep = new BooleanStep(step, m_nbElements, m_nbComponents); diff --git a/src/XAO/BooleanField.hxx b/src/XAO/BooleanField.hxx index 05ca4cc9a..950e2be5b 100644 --- a/src/XAO/BooleanField.hxx +++ b/src/XAO/BooleanField.hxx @@ -39,6 +39,7 @@ namespace XAO virtual const XAO::Type getType() { return XAO::BOOLEAN; } + virtual Step* addNewStep(const int& step); BooleanStep* addStep(const int& step); BooleanStep* addStep(const int& step, const int& stamp); BooleanStep* getStep(const int& index); diff --git a/src/XAO/BooleanStep.cxx b/src/XAO/BooleanStep.cxx index b1b127610..f83ea67bf 100644 --- a/src/XAO/BooleanStep.cxx +++ b/src/XAO/BooleanStep.cxx @@ -135,7 +135,7 @@ void BooleanStep::setElements(const int& element, const std::vector& eleme void BooleanStep::setComponents(const int& component, const std::vector& components) { - checkElement(component); + checkComponent(component); if (components.size() != m_nbElements) throw SALOME_Exception("bad size"); // TODO diff --git a/src/XAO/BrepGeometry.cxx b/src/XAO/BrepGeometry.cxx new file mode 100644 index 000000000..6160365c6 --- /dev/null +++ b/src/XAO/BrepGeometry.cxx @@ -0,0 +1,242 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "BrepGeometry.hxx" +#include "XaoUtils.hxx" + +using namespace XAO; + +BrepGeometry::BrepGeometry() : Geometry("") +{ +} + +BrepGeometry::BrepGeometry(const std::string& name) : Geometry(name) +{ +} + +void BrepGeometry::getEdgeVertices(const int& edge, int& vertexA, int& vertexB) +{ + throw SALOME_Exception("Not impolemented"); +} + +const int BrepGeometry::countFacesWires(const int& face) +{ + throw SALOME_Exception("Not impolemented"); +} + +std::vector BrepGeometry::getFacesWires(const int& face) +{ + throw SALOME_Exception("Not impolemented"); +} + +const int BrepGeometry::countSolidShells(const int& solid) +{ + throw SALOME_Exception("Not impolemented"); +} + +std::vector BrepGeometry::getSolidShells(const int& solid) +{ + throw SALOME_Exception("Not impolemented"); +} + +void BrepGeometry::getVertexXYZ(const int& vertex, int& xCoord, int& yCoord, int& zCoord) +{ + // TODO + TopTools_MapOfShape mapShape; + TopTools_ListOfShape listShape; + + TopExp_Explorer exp(m_shape, TopAbs_ShapeEnum(TopAbs_VERTEX)); + for (; exp.More(); exp.Next()) + { + if (mapShape.Add(exp.Current())) + listShape.Append(exp.Current()); + } + + if (listShape.IsEmpty()) + return; + + TopTools_IndexedMapOfShape indices; + TopExp::MapShapes(m_shape, indices); + + std::list indexList; + TopTools_ListIteratorOfListOfShape itSub(listShape); + for (int index = 1; itSub.More(); itSub.Next(), ++index) + { + TopoDS_Shape value = itSub.Value(); + indexList.push_back(indices.FindIndex(value)); + } + + std::list::iterator it = indexList.begin(); +// switch (shapeType) +// { +// case TopAbs_VERTEX: +// { +// } +// case TopAbs_EDGE: +// { +// m_edges.setSize(indexList.size()); +// for (int i = 0; it != indexList.end(); it++, i++) +// m_edges.setReference(i, XaoUtils::intToString((*it))); +// break; +// } +// case TopAbs_FACE: +// { +// m_faces.setSize(indexList.size()); +// for (int i = 0; it != indexList.end(); it++, i++) +// m_faces.setReference(i, XaoUtils::intToString((*it))); +// break; +// } +// case TopAbs_SOLID: +// { +// m_solids.setSize(indexList.size()); +// for (int i = 0; it != indexList.end(); it++, i++) +// m_solids.setReference(i, XaoUtils::intToString((*it))); +// break; +// } +// } +} + +const double BrepGeometry::getEdgleLength(const int& edge) +{ + throw SALOME_Exception("Not impolemented"); +} + +const double BrepGeometry::getFaceArea(const int& face) +{ + throw SALOME_Exception("Not impolemented"); +} + +const double BrepGeometry::getSolidVolume(const int& solid) +{ + throw SALOME_Exception("Not impolemented"); +} + +const int BrepGeometry::getVertexID(const int& vertex) +{ + return XaoUtils::stringToInt(getVertexReference(vertex)); +} + +const int BrepGeometry::getEdgeID(const int& edge) +{ + return XaoUtils::stringToInt(getEdgeReference(edge)); +} + +const int BrepGeometry::getFaceID(const int& face) +{ + return XaoUtils::stringToInt(getFaceReference(face)); +} + +const int BrepGeometry::getSolidID(const int& solid) +{ + return XaoUtils::stringToInt(getSolidReference(solid)); +} + +void BrepGeometry::setVertexID(const int& vertex, const int& id) +{ + throw SALOME_Exception("Not impolemented"); +} + +void BrepGeometry::setEdgeID(const int& edge, const int& id) +{ + throw SALOME_Exception("Not impolemented"); +} + +void BrepGeometry::setFaceID(const int& face, const int& id) +{ + throw SALOME_Exception("Not impolemented"); +} + +void BrepGeometry::setSolidID(const int& solid, const int& id) +{ + throw SALOME_Exception("Not impolemented"); +} + +const int BrepGeometry::findVertex(const int& id) +{ + return getVertexIndexByReference(XaoUtils::intToString(id)); +} + +const int BrepGeometry::findEdge(const int& id) +{ + return getEdgeIndexByReference(XaoUtils::intToString(id)); +} + +const int BrepGeometry::findFace(const int& id) +{ + return getFaceIndexByReference(XaoUtils::intToString(id)); +} + +const int BrepGeometry::findSolid(const int& id) +{ + return getSolidIndexByReference(XaoUtils::intToString(id)); +} + +const std::string BrepGeometry::findVertexName(const int& id) +{ + return getVertexName(findVertex(id)); +} + +const std::string BrepGeometry::findEdgeName(const int& id) +{ + return getEdgeName(findEdge(id)); +} + +const std::string BrepGeometry::findFaceName(const int& id) +{ + return getFaceName(findFace(id)); +} + +const std::string BrepGeometry::findSolidName(const int& id) +{ + return getSolidName(findSolid(id)); +} + +void BrepGeometry::changeVertexName(const int& id, const std::string& name) +{ + setVertexName(findVertex(id), name); +} + +void BrepGeometry::changeEdgeName(const int& id, const std::string& name) +{ + setEdgeName(findEdge(id), name); +} + +void BrepGeometry::changeFaceName(const int& id, const std::string& name) +{ + setFaceName(findFace(id), name); +} + +void BrepGeometry::changeSolidName(const int& id, const std::string& name) +{ + setSolidName(findSolid(id), name); +} + diff --git a/src/XAO/BrepGeometry.hxx b/src/XAO/BrepGeometry.hxx new file mode 100644 index 000000000..052fbcba6 --- /dev/null +++ b/src/XAO/BrepGeometry.hxx @@ -0,0 +1,89 @@ +// 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_BREPGEOMETRY_HXX__ +#define __XAO_BREPGEOMETRY_HXX__ + +#include +#include + +#include +#include + +#include "Xao.hxx" +#include "Geometry.hxx" + +namespace XAO +{ + class BrepGeometry : public Geometry + { + public: + BrepGeometry(); + BrepGeometry(const std::string& name); + + virtual const XAO::Format getFormat() { return XAO::BREP; } + + /** + * Gives the two extrimities of an edge. + * @param edge + * @param vertexA + * @param vertexB + */ + void getEdgeVertices(const int& edge, int& vertexA, int& vertexB); + + const int countFacesWires(const int& face); + std::vector getFacesWires(const int& face); + + const int countSolidShells(const int& solid); + std::vector getSolidShells(const int& solid); + + void getVertexXYZ(const int& vertex, int& xCoord, int& yCoord, int& zCoord); + const double getEdgleLength(const int& edge); + const double getFaceArea(const int& face); + const double getSolidVolume(const int& solid); + + const int getVertexID(const int& vertex); + const int getEdgeID(const int& edge); + const int getFaceID(const int& face); + const int getSolidID(const int& solid); + + void setVertexID(const int& vertex, const int& id); + void setEdgeID(const int& edge, const int& id); + void setFaceID(const int& face, const int& id); + void setSolidID(const int& solid, const int& id); + + const int findVertex(const int& id); + const int findEdge(const int& id); + const int findFace(const int& id); + const int findSolid(const int& id); + + const std::string findVertexName(const int& id); + const std::string findEdgeName(const int& id); + const std::string findFaceName(const int& id); + const std::string findSolidName(const int& id); + + void changeVertexName(const int& id, const std::string& name); + void changeEdgeName(const int& id, const std::string& name); + void changeFaceName(const int& id, const std::string& name); + void changeSolidName(const int& id, const std::string& name); + }; +} + +#endif // __XAO_BREPGEOMETRY_HXX__ diff --git a/src/XAO/DoubleField.cxx b/src/XAO/DoubleField.cxx index 6295a0ede..d5bcdb5b8 100644 --- a/src/XAO/DoubleField.cxx +++ b/src/XAO/DoubleField.cxx @@ -35,6 +35,11 @@ DoubleField::DoubleField(const std::string& name, const XAO::Dimension& dimensio { } +Step* DoubleField::addNewStep(const int& step) +{ + return addStep(step); +} + DoubleStep* DoubleField::addStep(const int& step) { DoubleStep* bstep = new DoubleStep(step, m_nbElements, m_nbComponents); diff --git a/src/XAO/DoubleField.hxx b/src/XAO/DoubleField.hxx index 8dcb0aa4b..20d3b77c0 100644 --- a/src/XAO/DoubleField.hxx +++ b/src/XAO/DoubleField.hxx @@ -40,6 +40,7 @@ namespace XAO virtual const XAO::Type getType() { return XAO::DOUBLE; } + virtual Step* addNewStep(const int& step); DoubleStep* addStep(const int& step); DoubleStep* addStep(const int& step, const int& stamp); DoubleStep* getStep(const int& index); diff --git a/src/XAO/Field.cxx b/src/XAO/Field.cxx index 0e19d9e26..86a414709 100644 --- a/src/XAO/Field.cxx +++ b/src/XAO/Field.cxx @@ -19,6 +19,7 @@ // Author : Frederic Pons (OpenCascade) #include +#include #include #include "Xao.hxx" #include "Field.hxx" @@ -42,6 +43,12 @@ Field::Field(const std::string& name, const XAO::Dimension& dimension, m_components.push_back(""); } +Field::~Field() +{ + for (int i = 0; i < m_steps.size(); ++i) + delete m_steps[i]; +} + Field* Field::createField(const XAO::Type& type, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents) { @@ -97,3 +104,13 @@ bool Field::removeStep(Step* step) return false; } + +void Field::checkStep(const int& step) +{ + if (step >= m_steps.size() || step < 0) + { + std::ostringstream str; + str << "Step index is out of range [0, " << m_steps.size() << "] : " << step; + throw SALOME_Exception(str.str().c_str()); + } +} diff --git a/src/XAO/Field.hxx b/src/XAO/Field.hxx index 042d416cb..5991fcf4e 100644 --- a/src/XAO/Field.hxx +++ b/src/XAO/Field.hxx @@ -40,6 +40,13 @@ namespace XAO class Field { protected: + /** + * Constructor. + * @param name the name of the field. + * @param dimension the dimension ot the field. + * @param nbElements the number of elements. + * @param nbComponents the number of components. + */ Field(const std::string& name, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents); @@ -49,7 +56,7 @@ namespace XAO static Field* createField(const XAO::Type& type, const std::string& name, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents); - virtual ~Field() {}; + virtual ~Field(); /** * Gets the Type of the field. @@ -131,6 +138,13 @@ namespace XAO */ void setComponentName(const int& componentIndex, const std::string& name); + /** + * Adds a new step of the same type than the field. + * @param step the index of the step. + * @return the new create step. + */ + virtual Step* addNewStep(const int& step) = 0; + /** * Remove a step. * @param step the step to remove. @@ -138,11 +152,22 @@ namespace XAO */ bool removeStep(Step* step); + /** + * Returns the first step. + * @return an iterator on the first step. + */ stepIterator begin() { return m_steps.begin(); } + + /** + * Returns the last step. + * @return an iterator on the last step. + */ stepIterator end() { return m_steps.end(); } private: + /** Ensures that component is valid (< m_nbComponents). */ void checkComponent(const int& component); + void checkStep(const int& step); protected: /** The name of the Field. */ diff --git a/src/XAO/Geometry.cxx b/src/XAO/Geometry.cxx index 9ff77167e..9088edfc0 100644 --- a/src/XAO/Geometry.cxx +++ b/src/XAO/Geometry.cxx @@ -18,8 +18,6 @@ // // Author : Nathalie Gore (OpenCascade) -#include "XaoUtils.hxx" -#include "Geometry.hxx" #include #include @@ -45,11 +43,27 @@ #include +#include "XaoUtils.hxx" +#include "Geometry.hxx" +#include "BrepGeometry.hxx" + using namespace XAO; -Geometry::Geometry() +Geometry::Geometry(const std::string& name) + : m_name(name) +{ +} + +Geometry* Geometry::createGeometry(const XAO::Format& format) +{ + return createGeometry(format,""); +} + +Geometry* Geometry::createGeometry(const XAO::Format& format, const std::string& name) { - m_format = "BREP"; + if (format == XAO::BREP) + return new BrepGeometry(name); + throw SALOME_Exception("Geometry format not supported."); } Geometry::~Geometry() @@ -67,7 +81,7 @@ void Geometry::setShape(const TopoDS_Shape& shape) initListIds(TopAbs_SOLID); } -void Geometry::setShape(const char* brep) +void Geometry::setBREP(const char* brep) { std::istringstream streamBrep(brep); BRep_Builder builder; @@ -123,28 +137,28 @@ void Geometry::initListIds(const Standard_Integer shapeType) { m_vertices.setSize(indexList.size()); for (int i = 0; it != indexList.end(); it++, i++) - m_vertices.setReference(i, XaoUtils::intToString((*it)).c_str()); + m_vertices.setReference(i, XaoUtils::intToString((*it))); break; } case TopAbs_EDGE: { m_edges.setSize(indexList.size()); for (int i = 0; it != indexList.end(); it++, i++) - m_edges.setReference(i, XaoUtils::intToString((*it)).c_str()); + m_edges.setReference(i, XaoUtils::intToString((*it))); break; } case TopAbs_FACE: { m_faces.setSize(indexList.size()); for (int i = 0; it != indexList.end(); it++, i++) - m_faces.setReference(i, XaoUtils::intToString((*it)).c_str()); + m_faces.setReference(i, XaoUtils::intToString((*it))); break; } case TopAbs_SOLID: { m_solids.setSize(indexList.size()); for (int i = 0; it != indexList.end(); it++, i++) - m_solids.setReference(i, XaoUtils::intToString((*it)).c_str()); + m_solids.setReference(i, XaoUtils::intToString((*it))); break; } } @@ -152,74 +166,70 @@ void Geometry::initListIds(const Standard_Integer shapeType) const int Geometry::countElements(const XAO::Dimension& dim) { - if (dim == VERTEX) + if (dim == XAO::VERTEX) return countVertices(); - if (dim == EDGE) + if (dim == XAO::EDGE) return countEdges(); - if (dim == FACE) + if (dim == XAO::FACE) return countFaces(); - if (dim == SOLID) + if (dim == XAO::SOLID) return countSolids(); - throw SALOME_Exception("Unknown dimension"); + throw SALOME_Exception("Unknown dimension"); // TODO } const std::string Geometry::getElementReference(const XAO::Dimension& dim, const int& index) { - if (dim == VERTEX) + if (dim == XAO::VERTEX) return getVertexReference(index); - if (dim == EDGE) + if (dim == XAO::EDGE) return getEdgeReference(index); - if (dim == FACE) + if (dim == XAO::FACE) return getFaceReference(index); - if (dim == SOLID) + if (dim == XAO::SOLID) return getSolidReference(index); - std::cout << "getElementReference: unknown dimension" << std::endl; - throw SALOME_Exception("Unknown dimension"); + throw SALOME_Exception("Unknown dimension"); // TODO } const int Geometry::getElementIndexByReference(const XAO::Dimension& dim, const std::string& reference) { - if (dim == VERTEX) + if (dim == XAO::VERTEX) return getVertexIndexByReference(reference); - if (dim == EDGE) + if (dim == XAO::EDGE) return getEdgeIndexByReference(reference); - if (dim == FACE) + if (dim == XAO::FACE) return getFaceIndexByReference(reference); - if (dim == SOLID) + if (dim == XAO::SOLID) return getSolidIndexByReference(reference); - std::cout << "getElementIndexByReference: unknown dimension" << std::endl; - throw SALOME_Exception("Unknown dimension"); + throw SALOME_Exception("Unknown dimension"); // TODO } GeometricElementList::iterator Geometry::begin(const XAO::Dimension& dim) { - if (dim == VERTEX) + if (dim == XAO::VERTEX) return m_vertices.begin(); - if (dim == EDGE) + if (dim == XAO::EDGE) return m_edges.begin(); - if (dim == FACE) + if (dim == XAO::FACE) return m_faces.begin(); - if (dim == SOLID) + if (dim == XAO::SOLID) return m_solids.begin(); - std::cout << "begin: unknown dimension" << std::endl; - throw SALOME_Exception("Unknown dimension"); + throw SALOME_Exception("Unknown dimension"); // TODO } GeometricElementList::iterator Geometry::end(const XAO::Dimension& dim) { - if (dim == VERTEX) + if (dim == XAO::VERTEX) return m_vertices.end(); - if (dim == EDGE) + if (dim == XAO::EDGE) return m_edges.end(); - if (dim == FACE) + if (dim == XAO::FACE) return m_faces.end(); - if (dim == SOLID) + if (dim == XAO::SOLID) return m_solids.end(); - std::cout << "begin: unknown dimension" << std::endl; - throw SALOME_Exception("Unknown dimension"); + throw SALOME_Exception("Unknown dimension"); // TODO } diff --git a/src/XAO/Geometry.hxx b/src/XAO/Geometry.hxx index e4e55ec33..9d95f6c7d 100644 --- a/src/XAO/Geometry.hxx +++ b/src/XAO/Geometry.hxx @@ -33,36 +33,67 @@ namespace XAO { class Geometry { + protected: + Geometry(const std::string& name); + public: - Geometry(); + /** + * Creates a geometry. + * @param format the format of the geometry. + * @return the created geometry. + */ + static Geometry* createGeometry(const XAO::Format& format); + + /** + * Constructor. + * Creates a geometry. + * @name name the name of the geometry. + * @return the created geometry. + */ + static Geometry* createGeometry(const XAO::Format& format, const std::string& name); + + /** Destructor. */ ~Geometry(); + /** + * Gets the name of the geometry. + * @return the name of the geometry. + */ const std::string getName() { return m_name; } + /** + * Sets the name of the geometry. + * @param name the name to set. + */ void setName(const std::string& name) { m_name = name; } - const std::string getFormat() - { - return m_format; - } - void setFormat(const std::string& format) - { - m_format = format; - } + /** + * Gets the format of the geometry. + * @return the format of the geometry. + */ + virtual const XAO::Format getFormat() = 0; + /** + * Gets the shape of the geometry. + * @return the shape of the geometry. + */ TopoDS_Shape getShape() { return m_shape; } + /** + * Sets the shape of the geometry. + * @param shape the shape to set. + */ void setShape(const TopoDS_Shape& shape); const char* getBREP(); - void setShape(const char* brep); + void setBREP(const char* brep); const int countElements(const XAO::Dimension& dim); const int countVertices() { return m_vertices.getSize(); } @@ -75,11 +106,6 @@ namespace XAO void setCountFaces(const int& nb) { m_faces.setSize(nb); } void setCountSolids(const int& nb) { m_solids.setSize(nb); } - 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); } - const std::string getVertexName(const int& index) { return m_vertices.getName(index); } const std::string getEdgeName(const int& index) { return m_edges.getName(index); } const std::string getFaceName(const int& index) { return m_faces.getName(index); } @@ -106,6 +132,11 @@ namespace XAO 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 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); } + const int getVertexIndexByReference(const std::string& reference) { return m_vertices.getIndexByReference(reference); } const int getEdgeIndexByReference(const std::string& reference) { return m_edges.getIndexByReference(reference); } const int getFaceIndexByReference(const std::string& reference) { return m_faces.getIndexByReference(reference); } @@ -118,10 +149,10 @@ namespace XAO private: void initListIds(const Standard_Integer shapeType); - private: - TopoDS_Shape m_shape; + + protected: std::string m_name; - std::string m_format; + TopoDS_Shape m_shape; GeometricElementList m_vertices; GeometricElementList m_edges; GeometricElementList m_faces; diff --git a/src/XAO/Group.cxx b/src/XAO/Group.cxx index ccd2e4287..0bd18cffd 100644 --- a/src/XAO/Group.cxx +++ b/src/XAO/Group.cxx @@ -49,10 +49,10 @@ Group::~Group() void Group::checkElement(const int& element) { - if (element >= m_nbElements) + if (element >= m_nbElements || element < 0) { std::ostringstream str; - str << "IndexOutOfRange element: " << element << " >= " << m_nbElements; - throw SALOME_Exception(str.str().c_str()); // TODO + str << "IndexOutOfRange element: " << element << " >= " << m_nbElements; // TODO + throw SALOME_Exception(str.str().c_str()); } } diff --git a/src/XAO/Group.hxx b/src/XAO/Group.hxx index 6ebf66422..c9066f09c 100644 --- a/src/XAO/Group.hxx +++ b/src/XAO/Group.hxx @@ -105,6 +105,11 @@ namespace XAO private: void initGroup(const std::string& name, const XAO::Dimension& dim, const int& nbElements); + /** + * Ensures that the given element is valid. + * @param element + * @throw SALOME_Exception if element is bigger than the number of elements. + */ void checkElement(const int& element); private: diff --git a/src/XAO/IntegerField.cxx b/src/XAO/IntegerField.cxx index 642031ba5..47bc51f32 100644 --- a/src/XAO/IntegerField.cxx +++ b/src/XAO/IntegerField.cxx @@ -35,6 +35,11 @@ IntegerField::IntegerField(const std::string& name, const XAO::Dimension& dimens { } +Step* IntegerField::addNewStep(const int& step) +{ + return addStep(step); +} + IntegerStep* IntegerField::addStep(const int& step) { IntegerStep* bstep = new IntegerStep(step, m_nbElements, m_nbComponents); diff --git a/src/XAO/IntegerField.hxx b/src/XAO/IntegerField.hxx index 2948295e6..699adda79 100644 --- a/src/XAO/IntegerField.hxx +++ b/src/XAO/IntegerField.hxx @@ -40,9 +40,10 @@ namespace XAO virtual const XAO::Type getType() { return XAO::INTEGER; } + virtual Step* addNewStep(const int& step); IntegerStep* addStep(const int& step); IntegerStep* addStep(const int& step, const int& stamp); - IntegerStep* getStep(const int& index); + IntegerStep* getStep(const int& step); }; } diff --git a/src/XAO/Makefile.am b/src/XAO/Makefile.am index c681dd255..8607d1735 100644 --- a/src/XAO/Makefile.am +++ b/src/XAO/Makefile.am @@ -31,6 +31,7 @@ salomeinclude_HEADERS = \ GeometricElement.hxx \ Xao.hxx \ Geometry.hxx \ + BrepGeometry.hxx \ Group.hxx \ Field.hxx \ BooleanField.hxx \ @@ -50,6 +51,7 @@ dist_libXAO_la_SOURCES = \ GeometricElement.cxx \ Xao.cxx \ Geometry.cxx \ + BrepGeometry.cxx \ Group.cxx \ Field.cxx \ BooleanField.cxx \ diff --git a/src/XAO/Step.cxx b/src/XAO/Step.cxx index 17ef7a318..ea1dd81ce 100644 --- a/src/XAO/Step.cxx +++ b/src/XAO/Step.cxx @@ -18,6 +18,9 @@ // // Author : Frederic Pons (OpenCascade) +#include +#include + #include "Xao.hxx" #include "Step.hxx" #include "BooleanStep.hxx" @@ -25,20 +28,9 @@ #include "DoubleStep.hxx" #include "StringStep.hxx" -#include using namespace XAO; -Step* Step::createStep(const XAO::Type& type, const int& nbElements, const int& nbComponents) -{ - return createStep(type, 0, 0, nbElements, nbComponents); -} - -Step* Step::createStep(const XAO::Type& type, const int& step, const int& nbElements, const int& nbComponents) -{ - return createStep(type, step, 0, nbElements, nbComponents); -} - Step* Step::createStep(const XAO::Type& type, const int& step, const int& stamp, const int& nbElements, const int& nbComponents) { if (type == XAO::BOOLEAN) @@ -55,12 +47,20 @@ Step* Step::createStep(const XAO::Type& type, const int& step, const int& stamp, void Step::checkElement(const int& element) { - if (element >= m_nbElements) - throw SALOME_Exception("IndexOutOfRange element"); // TODO + if (element >= m_nbElements || element < 0) + { + std::ostringstream str; + str << "Element index is out of range [0, " << m_nbElements-1 << "] : " << element; + throw SALOME_Exception(str.str().c_str()); + } } void Step::checkComponent(const int& component) { - if (component >= m_nbComponents) - throw SALOME_Exception("IndexOutOfRange component"); // TODO + if (component >= m_nbComponents || component < 0) + { + std::ostringstream str; + str << "Component index is out of range [0, " << m_nbComponents-1 << "] : " << component; + throw SALOME_Exception(str.str().c_str()); + } } diff --git a/src/XAO/Step.hxx b/src/XAO/Step.hxx index b889c8de5..157ffea87 100644 --- a/src/XAO/Step.hxx +++ b/src/XAO/Step.hxx @@ -29,13 +29,30 @@ namespace XAO class Step { protected: + /** Default constructor. */ Step() {} public: - static Step* createStep(const XAO::Type& type, const int& nbElements, const int& nbComponents); - static Step* createStep(const XAO::Type& type, const int& step, const int& nbElements, const int& nbComponents); + /** + * Creates a step. + * @param type the type of the values for the step. + * @param step the index of the step. + * @param stamp the stamp of the step. + * @param nbElements the number of elements in the step. + * @param nbComponents the number of components in the step. + * @return + */ static Step* createStep(const XAO::Type& type, const int& step, const int& stamp, const int& nbElements, const int& nbComponents); + /** + * Destructor. + */ + virtual ~Step() {} + + /** + * Gets the type of the step. + * @return + */ virtual const XAO::Type getType() = 0; /** @@ -62,13 +79,39 @@ namespace XAO */ void setStamp(const int& stamp) { m_stamp = stamp; } + /** + * Gets the number of components of the step. + * @return the number of components. + */ const int countComponents() { return m_nbComponents; } + /** + * Gets the number of elements for the step. + * @return the number of elements. + */ const int countElements() { return m_nbElements; } + /** + * Gets the number of values for the step. + * @return the number of values. + */ const int countValues() { return m_nbElements * m_nbComponents; } + /** + * Gets a value as a string. + * @param element the index of the element. + * @param component the index of the component. + * @return the value as a string. + */ virtual const std::string getStringValue(const int& element, const int& component) = 0; + + /** + * Sets a value as a string + * @param element the index of the element. + * @param component the index of the component. + * @param value the string value. + * @throw SALOME_Exception if the value is not valid. + */ virtual void setStringValue(const int& element, const int& component, const std::string& value) = 0; protected: @@ -76,9 +119,13 @@ namespace XAO void checkComponent(const int& component); protected: + /** the index of the step. */ int m_step; + /** The stamp of the step. */ int m_stamp; + /** The number of components. */ int m_nbComponents; + /** The number of elements. */ int m_nbElements; }; } diff --git a/src/XAO/StringField.cxx b/src/XAO/StringField.cxx index 3f061c2f7..3b34ed96e 100644 --- a/src/XAO/StringField.cxx +++ b/src/XAO/StringField.cxx @@ -35,6 +35,11 @@ StringField::StringField(const std::string& name, const XAO::Dimension& dimensio { } +Step* StringField::addNewStep(const int& step) +{ + return addStep(step); +} + StringStep* StringField::addStep(const int& step) { StringStep* bstep = new StringStep(step, m_nbElements, m_nbComponents); diff --git a/src/XAO/StringField.hxx b/src/XAO/StringField.hxx index 939d7a707..8618aafd8 100644 --- a/src/XAO/StringField.hxx +++ b/src/XAO/StringField.hxx @@ -40,6 +40,7 @@ namespace XAO virtual const XAO::Type getType() { return XAO::STRING; } + virtual Step* addNewStep(const int& step); StringStep* addStep(const int& step); StringStep* addStep(const int& step, const int& stamp); StringStep* getStep(const int& index); diff --git a/src/XAO/Xao.hxx b/src/XAO/Xao.hxx index 6da54ef73..c3bfce02f 100644 --- a/src/XAO/Xao.hxx +++ b/src/XAO/Xao.hxx @@ -27,6 +27,15 @@ namespace XAO { + /** + * @enum CAD + */ + enum Format + { + BREP, + STEP + }; + /** * @enum Dimension */ @@ -39,12 +48,15 @@ namespace XAO WHOLE = -1 //!< WHOLE }; + /** + * @enum Type + */ enum Type { - BOOLEAN = 0, - INTEGER = 1, - DOUBLE = 2, - STRING = 3 + BOOLEAN = 0,//!< BOOLEAN + INTEGER = 1,//!< INTEGER + DOUBLE = 2, //!< DOUBLE + STRING = 3 //!< STRING }; class Geometry; diff --git a/src/XAO/XaoExporter.cxx b/src/XAO/XaoExporter.cxx index 459433415..64f269f84 100644 --- a/src/XAO/XaoExporter.cxx +++ b/src/XAO/XaoExporter.cxx @@ -1,4 +1,5 @@ +#include #include #include @@ -68,6 +69,57 @@ namespace XAO using namespace XAO; +std::string XaoExporter::readStringProp(xmlNodePtr node, const xmlChar* attribute, + const bool& required, const std::string& defaultValue, + const std::string& exception /*= std::string() */) +{ + xmlChar* strAttr = xmlGetProp(node, attribute); + if (strAttr == NULL) + { + if (required) + { + if (exception.size() > 0) + throw SALOME_Exception(exception.c_str()); + + std::ostringstream str; + str << "Line " << node->line << ": "; + str << "Property " << (char*)attribute << " is required."; + throw SALOME_Exception(str.str().c_str()); + } + + return defaultValue; + } + + std::string res = (char*)strAttr; + xmlFree(strAttr); + return res; +} + +int XaoExporter::readIntegerProp(xmlNodePtr node, const xmlChar* attribute, + const bool& required, const int& defaultValue, + const std::string& exception /*= std::string() */) +{ + xmlChar* strAttr = xmlGetProp(node, attribute); + if (strAttr == NULL) + { + if (required) + { + if (exception.size() > 0) + throw SALOME_Exception(exception.c_str()); + + std::ostringstream str; + str << "Property " << (char*)attribute << " is required."; + throw SALOME_Exception(str.str().c_str()); + } + + return defaultValue; + } + + int res = XaoUtils::stringToInt((char*)strAttr); + xmlFree(strAttr); + return res; +} + const bool XaoExporter::saveToFile(Xao* xaoObject, const std::string& fileName) { xmlDocPtr doc = exportXMLDoc(xaoObject); @@ -123,8 +175,6 @@ void XaoExporter::exportGeometricElements(Geometry* xaoGeometry, GeometricElement elt = it->second; xmlNodePtr vertex = xmlNewChild(vertices, 0, eltTag, 0); xmlNewProp(vertex, C_ATTR_ELT_INDEX, BAD_CAST XaoUtils::intToString(index).c_str()); - //xmlNewProp(vertex, C_ATTR_ELT_NAME, BAD_CAST xaoGeometry->getVertexName(i)); - //xmlNewProp(vertex, C_ATTR_ELT_REFERENCE, BAD_CAST xaoGeometry->getVertexReference(i)); xmlNewProp(vertex, C_ATTR_ELT_NAME, BAD_CAST elt.getName().c_str()); xmlNewProp(vertex, C_ATTR_ELT_REFERENCE, BAD_CAST elt.getReference().c_str()); } @@ -137,7 +187,7 @@ void XaoExporter::exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePt xmlNewProp(geometry, C_ATTR_GEOMETRY_NAME, BAD_CAST xaoGeometry->getName().c_str()); xmlNodePtr shape = xmlNewChild(geometry, 0, C_TAG_SHAPE, 0); - xmlNewProp(shape, C_ATTR_SHAPE_FORMAT, BAD_CAST xaoGeometry->getFormat().c_str()); + xmlNewProp(shape, C_ATTR_SHAPE_FORMAT, BAD_CAST XaoUtils::shapeFormatToString(xaoGeometry->getFormat()).c_str()); const char* brep = xaoGeometry->getBREP(); xmlNodePtr cdata = xmlNewCDataBlock(doc, BAD_CAST brep, strlen(brep)); xmlAddChild(shape, cdata); @@ -200,7 +250,6 @@ void XaoExporter::exportFields(Xao* xaoObject, xmlNodePtr xao) int nbSteps = field->countSteps(); xmlNodePtr nodeSteps = xmlNewChild(nodeField, 0, C_TAG_STEPS, 0); xmlNewProp(nodeSteps, C_ATTR_COUNT, BAD_CAST XaoUtils::intToString(nbSteps).c_str()); - //for (int j = 0; j < nbSteps; j++) for (stepIterator itStep = field->begin(); itStep != field->end(); itStep++) { Step* step = *itStep; @@ -274,19 +323,12 @@ void XaoExporter::parseXMLDoc(xmlDocPtr doc, Xao* xaoObject) void XaoExporter::parseXaoNode(xmlDocPtr doc, xmlNodePtr xaoNode, Xao* xaoObject) { - xmlChar* version = xmlGetProp(xaoNode, C_ATTR_XAO_VERSION); - if (version != NULL) - { - xaoObject->setVersion((char*)version); - xmlFree(version); - } + std::string version = readStringProp(xaoNode, C_ATTR_XAO_VERSION, false, ""); + if (version != "") + xaoObject->setAuthor(version); - xmlChar* author = xmlGetProp(xaoNode, C_ATTR_XAO_AUTHOR); - if (author != NULL) - { - xaoObject->setAuthor((char*)author); - xmlFree(author); - } + std::string author = readStringProp(xaoNode, C_ATTR_XAO_AUTHOR, false, ""); + xaoObject->setAuthor(author); for (xmlNodePtr node = xaoNode->children; node; node = node->next) { @@ -294,45 +336,50 @@ void XaoExporter::parseXaoNode(xmlDocPtr doc, xmlNodePtr xaoNode, Xao* xaoObject parseGeometryNode(doc, node, xaoObject); else if (xmlStrcmp(node->name, C_TAG_GROUPS) == 0) parseGroupsNode(node, xaoObject); + else if (xmlStrcmp(node->name, C_TAG_FIELDS) == 0) + parseFieldsNode(node, xaoObject); } } void XaoExporter::parseGeometryNode(xmlDocPtr doc, xmlNodePtr geometryNode, Xao* xaoObject) { - Geometry* geometry = new Geometry(); - - xmlChar* name = xmlGetProp(geometryNode, C_ATTR_GEOMETRY_NAME); - if (name != NULL) - { - geometry->setName((char*)name); - xmlFree(name); - } - + // get the shape and topo nodes + xmlNodePtr shapeNode = NULL; + xmlNodePtr topoNode = NULL; for (xmlNodePtr node = geometryNode->children; node; node = node->next) { if (xmlStrcmp(node->name, C_TAG_SHAPE) == 0) - parseShapeNode(doc, node, geometry); + shapeNode = node; else if (xmlStrcmp(node->name, C_TAG_TOPOLOGY) == 0) - parseTopologyNode(node, geometry); + topoNode = node; } + std::string name = readStringProp(geometryNode, C_ATTR_GEOMETRY_NAME, false, ""); + std::string strFormat = readStringProp(shapeNode, C_ATTR_SHAPE_FORMAT, true, ""); + XAO::Format shapeFormat = XaoUtils::stringToShapeFormat(strFormat); + Geometry* geometry = Geometry::createGeometry(shapeFormat, name); + + parseShapeNode(doc, shapeNode, geometry); + parseTopologyNode(topoNode, geometry); + xaoObject->setGeometry(geometry); } void XaoExporter::parseShapeNode(xmlDocPtr doc, xmlNodePtr shapeNode, Geometry* geometry) { - xmlChar* shapeType = xmlGetProp(shapeNode, C_ATTR_SHAPE_FORMAT); - if (xmlStrcmp(shapeType, (xmlChar*)"BREP") == 0) + if (geometry->getFormat() == XAO::BREP) { xmlChar* data = xmlNodeGetContent(shapeNode->children); if (data == NULL) throw SALOME_Exception("Missing BREP"); - geometry->setShape((char*)data); + geometry->setBREP((char*)data); xmlFree(data); } else { - throw SALOME_Exception("Shape format not supported"); + std::ostringstream str; + str << "Shape format not supported: " << XaoUtils::shapeFormatToString(geometry->getFormat()); + throw SALOME_Exception(str.str().c_str()); } } @@ -353,120 +400,72 @@ void XaoExporter::parseTopologyNode(xmlNodePtr topologyNode, Geometry* geometry) void XaoExporter::parseVerticesNode(xmlNodePtr verticesNode, Geometry* geometry) { - xmlChar* count = xmlGetProp(verticesNode, C_ATTR_COUNT); - if (count == NULL) - throw SALOME_Exception("No count attribute for vertices"); - - geometry->setCountVertices(atoi((char*)count)); - xmlFree(count); + int count = readIntegerProp(verticesNode, C_ATTR_COUNT, true, -1); + geometry->setCountVertices(count); for (xmlNodePtr node = verticesNode->children; node; node = node->next) { if (xmlStrcmp(node->name, C_TAG_VERTEX) == 0) { - xmlChar* index = xmlGetProp(node, C_ATTR_ELT_INDEX); - if (index == NULL) - throw SALOME_Exception("Bad index for vertex"); - - xmlChar* name = xmlGetProp(node, C_ATTR_ELT_NAME); - if (name == NULL) - name = (xmlChar*)""; + int index = readIntegerProp(node, C_ATTR_ELT_INDEX, true, -1); + std::string name = readStringProp(node, C_ATTR_ELT_NAME, false, ""); + std::string reference = readStringProp(node, C_ATTR_ELT_REFERENCE, true, ""); - xmlChar* reference = xmlGetProp(node, C_ATTR_ELT_REFERENCE); - if (reference == NULL) - throw SALOME_Exception("Bad reference for vertex"); - - geometry->setVertex(atoi((char*)index), (char*)name, (char*)reference); + geometry->setVertex(index, name, reference); } } } void XaoExporter::parseEdgesNode(xmlNodePtr edgesNode, Geometry* geometry) { - xmlChar* count = xmlGetProp(edgesNode, C_ATTR_COUNT); - if (count == NULL) - throw SALOME_Exception("No count attribute for edges"); - - geometry->setCountEdges(atoi((char*)count)); - xmlFree(count); + int count = readIntegerProp(edgesNode, C_ATTR_COUNT, true, -1); + geometry->setCountEdges(count); for (xmlNodePtr node = edgesNode->children; node; node = node->next) { if (xmlStrcmp(node->name, C_TAG_EDGE) == 0) { - xmlChar* index = xmlGetProp(node, C_ATTR_ELT_INDEX); - if (index == NULL) - throw SALOME_Exception("Bad index for edge"); + int index = readIntegerProp(node, C_ATTR_ELT_INDEX, true, -1); + std::string name = readStringProp(node, C_ATTR_ELT_NAME, false, ""); + std::string reference = readStringProp(node, C_ATTR_ELT_REFERENCE, true, ""); - xmlChar* name = xmlGetProp(node, C_ATTR_ELT_NAME); - if (name == NULL) - name = (xmlChar*)""; - - xmlChar* reference = xmlGetProp(node, C_ATTR_ELT_REFERENCE); - if (reference == NULL) - throw SALOME_Exception("Bad reference for edge"); - - geometry->setEdge(atoi((char*)index), (char*)name, (char*)reference); + geometry->setEdge(index, name, reference); } } } void XaoExporter::parseFacesNode(xmlNodePtr facesNode, Geometry* geometry) { - xmlChar* count = xmlGetProp(facesNode, C_ATTR_COUNT); - if (count == NULL) - throw SALOME_Exception("No count attribute for faces"); - - geometry->setCountFaces(atoi((char*)count)); - xmlFree(count); + int count = readIntegerProp(facesNode, C_ATTR_COUNT, true, -1); + geometry->setCountFaces(count); for (xmlNodePtr node = facesNode->children; node; node = node->next) { if (xmlStrcmp(node->name, C_TAG_FACE) == 0) { - xmlChar* index = xmlGetProp(node, C_ATTR_ELT_INDEX); - if (index == NULL) - throw SALOME_Exception("Bad index for face"); + int index = readIntegerProp(node, C_ATTR_ELT_INDEX, true, -1); + std::string name = readStringProp(node, C_ATTR_ELT_NAME, false, ""); + std::string reference = readStringProp(node, C_ATTR_ELT_REFERENCE, true, ""); - xmlChar* name = xmlGetProp(node, C_ATTR_ELT_NAME); - if (name == NULL) - name = (xmlChar*)""; - - xmlChar* reference = xmlGetProp(node, C_ATTR_ELT_REFERENCE); - if (reference == NULL) - throw SALOME_Exception("Bad reference for face"); - - geometry->setFace(atoi((char*)index), (char*)name, (char*)reference); + geometry->setFace(index, name, reference); } } } void XaoExporter::parseSolidsNode(xmlNodePtr solidsNode, Geometry* geometry) { - xmlChar* count = xmlGetProp(solidsNode, C_ATTR_COUNT); - if (count == NULL) - throw SALOME_Exception("No count attribute for solids"); - - geometry->setCountSolids(atoi((char*)count)); - xmlFree(count); + int count = readIntegerProp(solidsNode, C_ATTR_COUNT, true, -1); + geometry->setCountSolids(count); for (xmlNodePtr node = solidsNode->children; node; node = node->next) { if (xmlStrcmp(node->name, C_TAG_SOLID) == 0) { - xmlChar* index = xmlGetProp(node, C_ATTR_ELT_INDEX); - if (index == NULL) - throw SALOME_Exception("Bad index for solid"); + int index = readIntegerProp(node, C_ATTR_ELT_INDEX, true, -1); + std::string name = readStringProp(node, C_ATTR_ELT_NAME, false, ""); + std::string reference = readStringProp(node, C_ATTR_ELT_REFERENCE, true, ""); - xmlChar* name = xmlGetProp(node, C_ATTR_ELT_NAME); - if (name == NULL) - name = (xmlChar*)""; - - xmlChar* reference = xmlGetProp(node, C_ATTR_ELT_REFERENCE); - if (reference == NULL) - throw SALOME_Exception("Bad reference for solid"); - - geometry->setSolid(atoi((char*)index), (char*)name, (char*)reference); + geometry->setSolid(index, name, reference); } } } @@ -484,28 +483,130 @@ void XaoExporter::parseGroupsNode(xmlNodePtr groupsNode, Xao* xaoObject) void XaoExporter::parseGroupNode(xmlNodePtr groupNode, Xao* xaoObject) { - xmlChar* dimension = xmlGetProp(groupNode, C_ATTR_GROUP_DIM); - if (dimension == NULL) - throw SALOME_Exception("Bad dimension for group"); - - XAO::Dimension dim = XaoUtils::stringToDimension((char*)dimension); + std::string strDimension = readStringProp(groupNode, C_ATTR_GROUP_DIM, true, ""); + XAO::Dimension dim = XaoUtils::stringToDimension(strDimension); Group* group = xaoObject->addGroup(dim); - xmlFree(dimension); - xmlChar* name = xmlGetProp(groupNode, C_ATTR_GROUP_NAME); - if (name == NULL) name = (xmlChar*)""; - group->setName((char*)name); - xmlFree(name); + std::string name = readStringProp(groupNode, C_ATTR_GROUP_NAME, false, ""); + group->setName(name); for (xmlNodePtr node = groupNode->children; node; node = node->next) { if (xmlStrcmp(node->name, C_TAG_ELEMENT) == 0) { - xmlChar* index = xmlGetProp(node, C_ATTR_ELEMENT_INDEX); - if (index == NULL) - throw SALOME_Exception("Bad index for group element"); - group->addElement(atoi((char*)index)); - xmlFree(index); + int index = readIntegerProp(node, C_ATTR_ELEMENT_INDEX, true, -1); + group->addElement(index); + } + } +} + +void XaoExporter::parseFieldsNode(xmlNodePtr fieldsNode, Xao* xaoObject) +{ + for (xmlNodePtr node = fieldsNode->children; node; node = node->next) + { + if (xmlStrcmp(node->name, C_TAG_FIELD) == 0) + { + parseFieldNode(node, xaoObject); + } + } +} + +void XaoExporter::parseFieldNode(xmlNodePtr fieldNode, Xao* xaoObject) +{ + std::string strDimension = readStringProp(fieldNode, C_ATTR_FIELD_DIMENSION, true, ""); + XAO::Dimension dim = XaoUtils::stringToDimension(strDimension); + + std::string strType = readStringProp(fieldNode, C_ATTR_FIELD_TYPE, true, ""); + XAO::Type type = XaoUtils::stringToFieldType(strType); + + // we need to get the number of components first to create the field + xmlNodePtr componentsNode = NULL; + xmlNodePtr stepsNode = NULL; + + for (xmlNodePtr node = fieldNode->children; node; node = node->next) + { + if (xmlStrcmp(node->name, C_TAG_COMPONENTS) == 0) + componentsNode = node; + else if (xmlStrcmp(node->name, C_TAG_STEPS) == 0) + stepsNode = node; + } + + // ensure that the components node is defined + if (componentsNode == NULL) + throw SALOME_Exception("No components defined for field"); // TODO + + // create the field + int nbComponents = readIntegerProp(componentsNode, C_ATTR_COUNT, true, -1); + Field* field = xaoObject->addField(type, dim, nbComponents); + + // parse the components + for (xmlNodePtr compNode = componentsNode->children; compNode; compNode = compNode->next) + { + std::string compName= readStringProp(compNode, C_ATTR_COMPONENT_NAME, false, ""); + if (compName.size() > 0) + { + int col = readIntegerProp(compNode, C_ATTR_COMPONENT_COLUMN, true, -1); + field->setComponentName(col, compName); + } + } + + // set the name + std::string name = readStringProp(fieldNode, C_ATTR_FIELD_NAME, false, ""); + if (name.size() > 0) field->setName(name); + + // read the steps + if (stepsNode != 0) + { + for (xmlNodePtr stepNode = stepsNode->children; stepNode; stepNode = stepNode->next) + { + if (xmlStrcmp(stepNode->name, C_TAG_STEP) == 0) + { + parseStepNode(stepNode, field); + } + } + } +} + +void XaoExporter::parseStepNode(xmlNodePtr stepNode, Field* field) +{ + int stepNumber = readIntegerProp(stepNode, C_ATTR_STEP_NUMBER, true, -1); + Step* step = field->addNewStep(stepNumber); + + int stepStamp = readIntegerProp(stepNode, C_ATTR_STEP_STAMP, false, -1); + if (stepStamp != -1) + { + step->setStamp(stepStamp); + } + + for (xmlNodePtr eltNode = stepNode->children; eltNode; eltNode = eltNode->next) + { + if (xmlStrcmp(eltNode->name, C_TAG_ELEMENT) == 0) + { + parseStepElementNode(eltNode, step); + } + } +} + +void XaoExporter::parseStepElementNode(xmlNodePtr eltNode, Step* step) +{ + int index = readIntegerProp(eltNode, C_ATTR_ELT_INDEX, true, -1); + + for (xmlNodePtr valNode = eltNode->children; valNode; valNode = valNode->next) + { + if (xmlStrcmp(valNode->name, C_TAG_VALUE) == 0) + { + int component = readIntegerProp(valNode, C_ATTR_VALUE_COMPONENT, true, -1); + xmlChar* data = xmlNodeGetContent(valNode->children); + + if (data == NULL) + { + std::ostringstream str; + str << "Line " << valNode->line << ": no content for value."; + throw SALOME_Exception(str.str().c_str()); + } + + std::string value = (char*)data; + step->setStringValue(index, component, value); } } } diff --git a/src/XAO/XaoExporter.hxx b/src/XAO/XaoExporter.hxx index 693fdcbee..ef8245228 100644 --- a/src/XAO/XaoExporter.hxx +++ b/src/XAO/XaoExporter.hxx @@ -40,6 +40,16 @@ namespace XAO static void parseSolidsNode(xmlNodePtr solidsNode, Geometry* geometry); static void parseGroupsNode(xmlNodePtr groupsNode, Xao* xaoObject); static void parseGroupNode(xmlNodePtr groupNode, Xao* xaoObject); + + static void parseFieldsNode(xmlNodePtr fieldsNode, Xao* xaoObject); + static void parseFieldNode(xmlNodePtr fieldNode, Xao* xaoObject); + static void parseStepNode(xmlNodePtr stepNode, Field* field); + static void parseStepElementNode(xmlNodePtr eltNode, Step* step); + + static std::string readStringProp(xmlNodePtr node, const xmlChar* attribute, + const bool& required, const std::string& defaultValue, const std::string& exception = std::string("")); + static int readIntegerProp(xmlNodePtr node, const xmlChar* attribute, + const bool& required, const int& defaultValue, const std::string& exception = std::string("")); }; } diff --git a/src/XAO/XaoUtils.cxx b/src/XAO/XaoUtils.cxx index 8b2983080..5d957dfb5 100644 --- a/src/XAO/XaoUtils.cxx +++ b/src/XAO/XaoUtils.cxx @@ -65,15 +65,15 @@ const double XaoUtils::stringToDouble(const std::string& value) const std::string XaoUtils::dimensionToString(const XAO::Dimension& dimension) { - if (dimension == VERTEX) + if (dimension == XAO::VERTEX) return "vertex"; - if (dimension == EDGE) + if (dimension == XAO::EDGE) return "edge"; - if (dimension == FACE) + if (dimension == XAO::FACE) return "face"; - if (dimension == SOLID) + if (dimension == XAO::SOLID) return "solid"; - if (dimension == WHOLE) + if (dimension == XAO::WHOLE) return "whole"; throw SALOME_Exception("Bad dimension"); } @@ -81,27 +81,27 @@ const std::string XaoUtils::dimensionToString(const XAO::Dimension& dimension) const XAO::Dimension XaoUtils::stringToDimension(const std::string& dimension) { if (dimension == "vertex") - return VERTEX; + return XAO::VERTEX; if (dimension == "edge") - return EDGE; + return XAO::EDGE; if (dimension == "face") - return FACE; + return XAO::FACE; if (dimension == "solid") - return SOLID; + return XAO::SOLID; if (dimension == "whole") - return WHOLE; + return XAO::WHOLE; throw SALOME_Exception("Bad dimension"); } const std::string XaoUtils::fieldTypeToString(const XAO::Type& type) { - if (type == BOOLEAN) + if (type ==XAO:: BOOLEAN) return "boolean"; - if (type == INTEGER) + if (type == XAO::INTEGER) return "integer"; - if (type == DOUBLE) + if (type == XAO::DOUBLE) return "double"; - if (type == STRING) + if (type == XAO::STRING) return "string"; throw SALOME_Exception("Bad type"); } @@ -109,12 +109,30 @@ const std::string XaoUtils::fieldTypeToString(const XAO::Type& type) const XAO::Type XaoUtils::stringToFieldType(const std::string& type) { if (type == "boolean") - return BOOLEAN; + return XAO::BOOLEAN; if (type == "integer") - return INTEGER; + return XAO::INTEGER; if (type == "double") - return DOUBLE; + return XAO::DOUBLE; if (type == "string") - return STRING; + return XAO::STRING; throw SALOME_Exception("Bad type"); } + +const std::string XaoUtils::shapeFormatToString(const XAO::Format& format) +{ + if (format == XAO::BREP) + return "BREP"; + if (format == XAO::STEP) + return "STEP"; + throw SALOME_Exception("Bad format"); +} + +const XAO::Format XaoUtils::stringToShapeFormat(const std::string& format) +{ + if (format == "BREP") + return XAO::BREP; + if (format == "STEP") + return XAO::STEP; + throw SALOME_Exception("Bad format"); +} diff --git a/src/XAO/XaoUtils.hxx b/src/XAO/XaoUtils.hxx index 8185de118..6bc2ff0e5 100644 --- a/src/XAO/XaoUtils.hxx +++ b/src/XAO/XaoUtils.hxx @@ -38,7 +38,6 @@ namespace XAO * \param value the integer to convert. * \return the string. */ - //static const char* intToString(const int value); static const std::string intToString(const int& value); static const int stringToInt(const std::string& value); @@ -76,7 +75,23 @@ namespace XAO * \throw SALOME_Exception */ static const XAO::Type stringToFieldType(const std::string& type); - }; + + /** + * Converts a Format to string. + * \param format the Format to convert. + * \return the Format as a string. + * \throw SALOME_Exception + */ + static const std::string shapeFormatToString(const XAO::Format& format); + + /** + * Converts a string into a Format. + * \param format the Format as a string. + * \return the converted Format. + * \throw SALOME_Exception + */ + static const XAO::Format stringToShapeFormat(const std::string& format); +}; } diff --git a/src/XAO/tests/BrepGeometryTest.cxx b/src/XAO/tests/BrepGeometryTest.cxx new file mode 100644 index 000000000..f0517a070 --- /dev/null +++ b/src/XAO/tests/BrepGeometryTest.cxx @@ -0,0 +1,50 @@ +#include +#include + +#include "TestUtils.hxx" +#include "BrepGeometryTest.hxx" +#include "../Xao.hxx" +#include "../BrepGeometry.hxx" + +using namespace XAO; + +void BrepGeometryTest::setUp() +{ +} + +void BrepGeometryTest::tearDown() +{ +} + +void BrepGeometryTest::cleanUp() +{ +} + +void readBrep(Geometry* geom, const std::string& fileName) +{ + char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath(fileName)); + geom->setBREP(txt); +} + +void BrepGeometryTest::testGetIDs() +{ + BrepGeometry* geom = new BrepGeometry("box"); + readBrep(geom, "Box_1.brep"); + + int vertices[8] = { 6,7,9,11,16,17,19,21 }; + for (int i = 0; i < 8; ++i) + CPPUNIT_ASSERT(geom->getVertexID(i) == vertices[i]); + + int edges[12] = { 5,8,10,12,15,18,20,22,25,26,29,30 }; + for (int i = 0; i < 12; ++i) + CPPUNIT_ASSERT(geom->getEdgeID(i) == edges[i]); + + int faces[6] = { 3,13,23,27,31,33 }; + for (int i = 0; i < 6; ++i) + CPPUNIT_ASSERT(geom->getFaceID(i) == faces[i]); + + CPPUNIT_ASSERT(geom->getSolidID(0) == 1); +} + + + diff --git a/src/XAO/tests/BrepGeometryTest.hxx b/src/XAO/tests/BrepGeometryTest.hxx new file mode 100644 index 000000000..e2e15fde5 --- /dev/null +++ b/src/XAO/tests/BrepGeometryTest.hxx @@ -0,0 +1,25 @@ +#ifndef __XAO_BREPGEOMETRY_TEST_HXX__ +#define __XAO_BREPGEOMETRY_TEST_HXX__ + +#include + +#include "../Xao.hxx" + +namespace XAO +{ + class BrepGeometryTest: public CppUnit::TestFixture + { + CPPUNIT_TEST_SUITE(BrepGeometryTest); + CPPUNIT_TEST(testGetIDs); + CPPUNIT_TEST_SUITE_END(); + + public: + void setUp(); + void tearDown(); + void cleanUp(); + + void testGetIDs(); + }; +} + +#endif // __XAO_BREPGEOMETRY_TEST_HXX__ diff --git a/src/XAO/tests/FieldTest.cxx b/src/XAO/tests/FieldTest.cxx index 96880a797..5ea847775 100644 --- a/src/XAO/tests/FieldTest.cxx +++ b/src/XAO/tests/FieldTest.cxx @@ -67,7 +67,7 @@ void FieldTest::testStringField() void FieldTest::testStep(XAO::Type type) { - Step* step = Step::createStep(type, 5, 3); + Step* step = Step::createStep(type, 0, 0, 5, 3); CPPUNIT_ASSERT(step->getType() == type); CPPUNIT_ASSERT(step->getStep() == 0); @@ -105,7 +105,7 @@ void FieldTest::testIntegerStepValues() int nbComponents = 3; int nbElements = 5; - IntegerStep* istep = (IntegerStep*)Step::createStep(XAO::INTEGER, nbElements, nbComponents); + IntegerStep* istep = (IntegerStep*)Step::createStep(XAO::INTEGER, 0, 0, nbElements, nbComponents); for (int i = 0; i < istep->countElements(); ++i) { for (int j = 0; j < istep->countComponents(); ++j) diff --git a/src/XAO/tests/ImportExportTest.cxx b/src/XAO/tests/ImportExportTest.cxx index f2990042d..3d0fcce33 100644 --- a/src/XAO/tests/ImportExportTest.cxx +++ b/src/XAO/tests/ImportExportTest.cxx @@ -18,21 +18,18 @@ // // Author : Frederic Pons (OpenCascade) -#include #include +#include "TestUtils.hxx"; #include "ImportExportTest.hxx" #include "../Geometry.hxx" #include "../Group.hxx" +#include "../Field.hxx" +#include "../IntegerField.hxx" +#include "../IntegerStep.hxx" using namespace XAO; -std::string getTestFile(std::string fileName) -{ - std::string dataDir = getenv("GEOM_SRC_DIR"); - dataDir += "/src/XAO/tests/data/" + fileName; - return dataDir; -} void ImportExportTest::setUp() { @@ -57,7 +54,7 @@ void ImportExportTest::testExportNoGeometry() void ImportExportTest::testExportGeometry() { Xao xao("me", "1.0"); - Geometry* geom = new Geometry(); + Geometry* geom = Geometry::createGeometry(XAO::BREP); geom->setName("mygeom"); xao.setGeometry(geom); @@ -90,6 +87,20 @@ void ImportExportTest::testExportGeometry() group->addElement(0); group->addElement(1); + // fields + IntegerField* field = (IntegerField*)xao.addField(XAO::INTEGER, "color", XAO::FACE, 2); + for (int stepIndex = 0; stepIndex < 10; ++stepIndex) + { + IntegerStep* istep = field->addStep(stepIndex, 100*stepIndex); + for (int eltIndex = 0; eltIndex < istep->countElements(); ++eltIndex) + { + for (int compIndex = 0; compIndex < istep->countComponents(); ++compIndex) + { + istep->setValue(eltIndex, compIndex, istep->getStamp() + eltIndex*10 + compIndex); + } + } + } + bool res = xao.exportXAO("mygeom.xao"); CPPUNIT_ASSERT(res); @@ -100,7 +111,7 @@ void ImportExportTest::testExportGeometry() void ImportExportTest::testGeometryError() { Xao xao("me", "1.0"); - Geometry* geom = new Geometry(); + Geometry* geom = Geometry::createGeometry(XAO::BREP); geom->setName("mygeom"); xao.setGeometry(geom); @@ -110,22 +121,13 @@ void ImportExportTest::testGeometryError() void ImportExportTest::testImportXao() { - //std::cout << std::endl; Xao xao; - xao.importXAO(getTestFile("test.xao").c_str()); + xao.importXAO(TestUtils::getTestFilePath("test.xao")); checkImport(xao); } void ImportExportTest::checkImport(Xao& xao) { -// std::string zz = "toto"; -// std::cout << "?? " << (zz == "toto" ? "yes" : "no" ) << std::endl; -// -// std::cout << std::endl << "Author = " << xao.getAuthor() -// << " : " << (xao.getAuthor() == "me" ? "yes" : "no") << std::endl; -// std::cout << " : " << ("me" == xao.getAuthor() ? "yes" : "no") << std::endl; -// std::cout << " : " << (xao.getAuthor().compare("me") ? "yes" : "no") << std::endl; - CPPUNIT_ASSERT(xao.getAuthor() == "me"); CPPUNIT_ASSERT(xao.getVersion() == "1.0"); @@ -177,15 +179,16 @@ void ImportExportTest::checkImport(Xao& xao) void ImportExportTest::testImportXaoFromText() { - std::ifstream rstr; - int length; - rstr.open(getTestFile("test.xao").c_str()); - rstr.seekg(0, rstr.end); // go to the end - length = rstr.tellg(); // report location (this is the length) - rstr.seekg(0, rstr.beg); // go back to the beginning - char* txt = new char[length]; // allocate memory for a buffer of appropriate dimension - rstr.read(txt, length); // read the whole file into the buffer - rstr.close(); +// std::ifstream rstr; +// int length; +// rstr.open(TestUtils::getTestFilePath("test.xao").c_str()); +// rstr.seekg(0, rstr.end); // go to the end +// length = rstr.tellg(); // report location (this is the length) +// rstr.seekg(0, rstr.beg); // go back to the beginning +// char* txt = new char[length]; // allocate memory for a buffer of appropriate dimension +// rstr.read(txt, length); // read the whole file into the buffer +// rstr.close(); + char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath("test.xao")); Xao xao; xao.setXML(txt); diff --git a/src/XAO/tests/Makefile.am b/src/XAO/tests/Makefile.am index 19d677123..27200e999 100755 --- a/src/XAO/tests/Makefile.am +++ b/src/XAO/tests/Makefile.am @@ -41,6 +41,7 @@ TestXAO_LDFLAGS = \ dist_TestXAO_SOURCES = \ FieldTest.cxx \ ImportExportTest.cxx \ + BrepGeometryTest.cxx \ XAOTests.cxx UNIT_TEST_PROG = TestXAO diff --git a/src/XAO/tests/TestUtils.hxx b/src/XAO/tests/TestUtils.hxx new file mode 100644 index 000000000..2d95aa5f4 --- /dev/null +++ b/src/XAO/tests/TestUtils.hxx @@ -0,0 +1,43 @@ +/* + * TestUtils.hxx + * + * Created on: 30 août 2013 + * Author: salome + */ + +#ifndef __XAO_TESTUTILS_HXX__ +#define __XAO_TESTUTILS_HXX__ + +#include +#include "../Xao.hxx" + +namespace XAO +{ + class TestUtils + { + public: + static std::string getTestFilePath(const std::string& fileName) + { + std::string dataDir = getenv("GEOM_SRC_DIR"); + dataDir += "/src/XAO/tests/data/" + fileName; + return dataDir; + } + + static char* readTextFile(const std::string& filePath) + { + std::ifstream rstr; + int length; + rstr.open(filePath.c_str()); + rstr.seekg(0, rstr.end); // go to the end + length = rstr.tellg(); // report location (this is the length) + rstr.seekg(0, rstr.beg); // go back to the beginning + char* txt = new char[length]; // allocate memory for a buffer of appropriate dimension + rstr.read(txt, length); // read the whole file into the buffer + rstr.close(); + + return txt; + } + }; +} + +#endif /* __XAO_TESTUTILS_HXX__ */ diff --git a/src/XAO/tests/XAOTests.cxx b/src/XAO/tests/XAOTests.cxx index a95cf5d0b..1d2ed63ca 100644 --- a/src/XAO/tests/XAOTests.cxx +++ b/src/XAO/tests/XAOTests.cxx @@ -1,7 +1,9 @@ #include "FieldTest.hxx" #include "ImportExportTest.hxx" +#include "BrepGeometryTest.hxx" CPPUNIT_TEST_SUITE_REGISTRATION(XAO::FieldTest); CPPUNIT_TEST_SUITE_REGISTRATION(XAO::ImportExportTest); +CPPUNIT_TEST_SUITE_REGISTRATION(XAO::BrepGeometryTest); #include "MainTest.hxx" diff --git a/src/XAO/tests/data/Box_1.brep b/src/XAO/tests/data/Box_1.brep new file mode 100644 index 000000000..1ebae6393 --- /dev/null +++ b/src/XAO/tests/data/Box_1.brep @@ -0,0 +1,366 @@ +DBRep_DrawableShape + +CASCADE Topology V1, (c) Matra-Datavision +Locations 0 +Curve2ds 24 +1 0 0 1 0 +1 0 0 1 0 +1 200 0 0 -1 +1 0 0 0 1 +1 0 -200 1 0 +1 0 0 1 0 +1 0 0 0 -1 +1 0 0 0 1 +1 0 0 1 0 +1 0 200 1 0 +1 200 0 0 -1 +1 200 0 0 1 +1 0 -200 1 0 +1 0 200 1 0 +1 0 0 0 -1 +1 200 0 0 1 +1 0 0 0 1 +1 0 0 1 0 +1 200 0 0 1 +1 0 0 1 0 +1 0 0 0 1 +1 0 200 1 0 +1 200 0 0 1 +1 0 200 1 0 +Curves 12 +1 0 0 0 0 0 1 +1 0 0 200 -0 1 0 +1 0 200 0 0 0 1 +1 0 0 0 -0 1 0 +1 200 0 0 0 0 1 +1 200 0 200 0 1 0 +1 200 200 0 0 0 1 +1 200 0 0 -0 1 0 +1 0 0 0 1 0 -0 +1 0 0 200 1 0 -0 +1 0 200 0 1 0 -0 +1 0 200 200 1 0 -0 +Polygon3D 0 +PolygonOnTriangulations 24 +2 1 2 +p 0.8000000008 1 0 200 +2 1 4 +p 0.8000000008 1 0 200 +2 2 3 +p 0.8000000008 1 0 200 +2 1 2 +p 0.8000000008 1 0 200 +2 4 3 +p 0.8000000008 1 0 200 +2 1 4 +p 0.8000000008 1 0 200 +2 1 4 +p 0.8000000008 1 0 200 +2 1 2 +p 0.8000000008 1 0 200 +2 1 2 +p 0.8000000008 1 0 200 +2 2 3 +p 0.8000000008 1 0 200 +2 2 3 +p 0.8000000008 1 0 200 +2 4 3 +p 0.8000000008 1 0 200 +2 4 3 +p 0.8000000008 1 0 200 +2 2 3 +p 0.8000000008 1 0 200 +2 1 4 +p 0.8000000008 1 0 200 +2 4 3 +p 0.8000000008 1 0 200 +2 1 2 +p 0.8000000008 1 0 200 +2 1 4 +p 0.8000000008 1 0 200 +2 4 3 +p 0.8000000008 1 0 200 +2 1 4 +p 0.8000000008 1 0 200 +2 1 2 +p 0.8000000008 1 0 200 +2 2 3 +p 0.8000000008 1 0 200 +2 4 3 +p 0.8000000008 1 0 200 +2 2 3 +p 0.8000000008 1 0 200 +Surfaces 6 +1 0 0 0 1 0 -0 0 0 1 0 -1 0 +1 0 0 0 -0 1 0 0 0 1 1 0 -0 +1 0 0 200 0 0 1 1 0 -0 -0 1 0 +1 0 200 0 -0 1 0 0 0 1 1 0 -0 +1 0 0 0 0 0 1 1 0 -0 -0 1 0 +1 200 0 0 1 0 -0 0 0 1 0 -1 0 +Triangulations 6 +4 2 1 0 +0 0 0 0 0 200 0 200 200 0 200 0 0 0 200 0 200 -200 0 -200 2 4 3 2 1 4 +4 2 1 0 +0 0 0 200 0 0 200 0 200 0 0 200 0 0 0 200 200 200 200 0 3 2 1 3 1 4 +4 2 1 0 +0 0 200 0 200 200 200 200 200 200 0 200 0 0 0 200 200 200 200 0 3 2 1 3 1 4 +4 2 1 0 +0 200 0 200 200 0 200 200 200 0 200 200 0 0 0 200 200 200 200 0 3 2 1 3 1 4 +4 2 1 0 +0 0 0 0 200 0 200 200 0 200 0 0 0 0 0 200 200 200 200 0 3 2 1 3 1 4 +4 2 1 0 +200 0 0 200 0 200 200 200 200 200 200 0 0 0 200 0 200 -200 0 -200 2 4 3 2 1 4 + +TShapes 34 +Ve +1e-07 +0 0 200 +0 0 + +0101101 +* +Ve +1e-07 +0 0 0 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 1 0 0 200 +2 1 1 0 0 200 +2 2 2 0 0 200 +6 1 1 0 +6 2 2 0 +0 + +0101000 +-34 0 +33 0 * +Ve +1e-07 +0 200 200 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 2 0 0 200 +2 3 1 0 0 200 +2 4 3 0 0 200 +6 3 1 0 +6 4 3 0 +0 + +0101000 +-31 0 +34 0 * +Ve +1e-07 +0 200 0 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 3 0 0 200 +2 5 1 0 0 200 +2 6 4 0 0 200 +6 5 1 0 +6 6 4 0 +0 + +0101000 +-31 0 +29 0 * +Ed + 1e-07 1 1 0 +1 4 0 0 200 +2 7 1 0 0 200 +2 8 5 0 0 200 +6 7 1 0 +6 8 5 0 +0 + +0101000 +-29 0 +33 0 * +Wi + +0101000 +-32 0 -30 0 +28 0 +27 0 * +Fa +0 1e-07 1 0 +2 1 +0101000 ++26 0 * +Ve +1e-07 +200 0 200 +0 0 + +0101101 +* +Ve +1e-07 +200 0 0 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 5 0 0 200 +2 9 6 0 0 200 +2 10 2 0 0 200 +6 9 6 0 +6 10 2 0 +0 + +0101000 +-24 0 +23 0 * +Ve +1e-07 +200 200 200 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 6 0 0 200 +2 11 6 0 0 200 +2 12 3 0 0 200 +6 11 6 0 +6 12 3 0 +0 + +0101000 +-21 0 +24 0 * +Ve +1e-07 +200 200 0 +0 0 + +0101101 +* +Ed + 1e-07 1 1 0 +1 7 0 0 200 +2 13 6 0 0 200 +2 14 4 0 0 200 +6 13 6 0 +6 14 4 0 +0 + +0101000 +-21 0 +19 0 * +Ed + 1e-07 1 1 0 +1 8 0 0 200 +2 15 6 0 0 200 +2 16 5 0 0 200 +6 15 6 0 +6 16 5 0 +0 + +0101000 +-19 0 +23 0 * +Wi + +0101000 +-22 0 -20 0 +18 0 +17 0 * +Fa +0 1e-07 6 0 +2 6 +0101000 ++16 0 * +Ed + 1e-07 1 1 0 +1 9 0 0 200 +2 17 2 0 0 200 +2 18 5 0 0 200 +6 17 2 0 +6 18 5 0 +0 + +0101000 +-23 0 +33 0 * +Ed + 1e-07 1 1 0 +1 10 0 0 200 +2 19 2 0 0 200 +2 20 3 0 0 200 +6 19 2 0 +6 20 3 0 +0 + +0101000 +-24 0 +34 0 * +Wi + +0101000 +-14 0 -22 0 +13 0 +32 0 * +Fa +0 1e-07 2 0 +2 2 +0101000 ++12 0 * +Ed + 1e-07 1 1 0 +1 11 0 0 200 +2 21 4 0 0 200 +2 22 5 0 0 200 +6 21 4 0 +6 22 5 0 +0 + +0101000 +-19 0 +29 0 * +Ed + 1e-07 1 1 0 +1 12 0 0 200 +2 23 4 0 0 200 +2 24 3 0 0 200 +6 23 4 0 +6 24 3 0 +0 + +0101000 +-21 0 +31 0 * +Wi + +0101000 +-10 0 -18 0 +9 0 +28 0 * +Fa +0 1e-07 4 0 +2 4 +0101000 ++8 0 * +Wi + +0101000 +-27 0 -10 0 +17 0 +14 0 * +Fa +0 1e-07 5 0 +2 5 +0101000 ++6 0 * +Wi + +0101000 +-30 0 -9 0 +20 0 +13 0 * +Fa +0 1e-07 3 0 +2 3 +0101000 ++4 0 * +Sh + +0101100 +-25 0 +15 0 -11 0 +7 0 -5 0 +3 0 * +So + +1100000 ++2 0 * + ++1 0 \ No newline at end of file diff --git a/src/XAO/tests/data/test.xao b/src/XAO/tests/data/test.xao index bb0e06949..81f3fda47 100644 --- a/src/XAO/tests/data/test.xao +++ b/src/XAO/tests/data/test.xao @@ -317,4 +317,29 @@ So + + + + + + + + + + + 100 + 110 + 120 + + + + + 255 + 0 + 0 + + + + + -- 2.39.2