From 390054003fa39e7fa27df88a09d76420be313799 Mon Sep 17 00:00:00 2001 From: fps Date: Tue, 17 Sep 2013 11:12:14 +0000 Subject: [PATCH] move optional name parameter to the end --- .../GEOMImpl_IImportExportOperations.cxx | 2 +- src/XAO/XAO_BooleanField.cxx | 6 +-- src/XAO/XAO_BooleanField.hxx | 4 +- src/XAO/XAO_BrepGeometry.cxx | 4 +- src/XAO/XAO_BrepGeometry.hxx | 16 ++++++- src/XAO/XAO_DoubleField.cxx | 4 +- src/XAO/XAO_DoubleField.hxx | 4 +- src/XAO/XAO_Exception.hxx | 12 ++++++ src/XAO/XAO_Field.cxx | 25 ++++------- src/XAO/XAO_Field.hxx | 25 ++++------- src/XAO/XAO_GeometricElement.cxx | 3 +- src/XAO/XAO_Geometry.hxx | 7 ++-- src/XAO/XAO_Group.cxx | 14 +------ src/XAO/XAO_Group.hxx | 21 ++-------- src/XAO/XAO_IntegerField.cxx | 4 +- src/XAO/XAO_IntegerField.hxx | 4 +- src/XAO/XAO_Step.cxx | 4 +- src/XAO/XAO_StringField.cxx | 4 +- src/XAO/XAO_StringField.hxx | 4 +- src/XAO/XAO_Xao.cxx | 42 +++++++++++-------- src/XAO/XAO_Xao.hxx | 22 +++------- src/XAO/XAO_XaoExporter.cxx | 4 +- src/XAO/XAO_XaoUtils.hxx | 2 + src/XAO/tests/BrepGeometryTest.cxx | 2 +- src/XAO/tests/GeometryTest.cxx | 2 +- src/XAO/tests/ImportExportTest.cxx | 2 +- src/XAO/tests/XaoTest.cxx | 15 +++++-- 27 files changed, 121 insertions(+), 137 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx b/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx index b02967dc9..dc49a7dfb 100644 --- a/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx @@ -154,7 +154,7 @@ void GEOMImpl_IImportExportOperations::exportGroups(std::listGetType(currGroup); XAO::Dimension dim = shapeEnumToDimension(shapeGroup); - XAO::Group* group = xaoObject->addGroup(currGroup->GetName(), dim); + XAO::Group* group = xaoObject->addGroup(dim, currGroup->GetName()); switch (shapeGroup) { diff --git a/src/XAO/XAO_BooleanField.cxx b/src/XAO/XAO_BooleanField.cxx index 4454e01d6..c0d1532c9 100644 --- a/src/XAO/XAO_BooleanField.cxx +++ b/src/XAO/XAO_BooleanField.cxx @@ -24,9 +24,9 @@ using namespace XAO; -BooleanField::BooleanField(const std::string& name, const XAO::Dimension& dimension, - const int& nbElements, const int& nbComponents) - : Field(name, dimension, nbElements, nbComponents) +BooleanField::BooleanField(const XAO::Dimension& dimension, + const int& nbElements, const int& nbComponents, const std::string& name) + : Field(dimension, nbElements, nbComponents, name) { } diff --git a/src/XAO/XAO_BooleanField.hxx b/src/XAO/XAO_BooleanField.hxx index 9a971e0aa..9860c4643 100644 --- a/src/XAO/XAO_BooleanField.hxx +++ b/src/XAO/XAO_BooleanField.hxx @@ -38,12 +38,12 @@ namespace XAO public: /** * Constructor. - * @param name the name of the field. * @param dimension the dimension of the field. * @param nbElements the number of elements. * @param nbComponents the number of components. + * @param name the name of the field. */ - BooleanField(const std::string& name, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents); + BooleanField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name); virtual const XAO::Type getType() { return XAO::BOOLEAN; } diff --git a/src/XAO/XAO_BrepGeometry.cxx b/src/XAO/XAO_BrepGeometry.cxx index 6eb315daa..042f935f9 100644 --- a/src/XAO/XAO_BrepGeometry.cxx +++ b/src/XAO/XAO_BrepGeometry.cxx @@ -49,7 +49,7 @@ BrepGeometry::BrepGeometry(const std::string& name) : Geometry(name) { } -const std::string BrepGeometry::getShape() +const std::string BrepGeometry::getShapeString() { std::ostringstream streamShape; BRepTools::Write(m_shape, streamShape); @@ -59,7 +59,7 @@ const std::string BrepGeometry::getShape() return res; } -void BrepGeometry::setShape(const std::string& shape) +void BrepGeometry::setShapeString(const std::string& shape) { std::istringstream streamBrep(shape.c_str()); BRep_Builder builder; diff --git a/src/XAO/XAO_BrepGeometry.hxx b/src/XAO/XAO_BrepGeometry.hxx index 217faf8c7..a457b3a77 100644 --- a/src/XAO/XAO_BrepGeometry.hxx +++ b/src/XAO/XAO_BrepGeometry.hxx @@ -49,6 +49,8 @@ namespace XAO */ BrepGeometry(const std::string& name); + virtual ~BrepGeometry() {} + /** * Gets the format of the geometry. * @return the format of the geometry. @@ -59,13 +61,23 @@ namespace XAO * Gets the shape as a string. * @return the shape as a string. */ - virtual const std::string getShape(); + virtual const std::string getShapeString(); /** * Sets the shape from a string. * @param shape the shape as a string. */ - virtual void setShape(const std::string& shape); + virtual void setShapeString(const std::string& shape); + +#ifdef SWIG + %pythoncode %{ + def setShape(self, shape): + if shape is not None and 'GetShapeStream' in dir(shape): + self.setShapeString(shape.GetShapeStream()) + else: + raise XAO_Exception("Cannot set shape") + %} +#endif /** * Gets the shape as a TopoDS_Shape. diff --git a/src/XAO/XAO_DoubleField.cxx b/src/XAO/XAO_DoubleField.cxx index a8f96ad72..b07ebabca 100644 --- a/src/XAO/XAO_DoubleField.cxx +++ b/src/XAO/XAO_DoubleField.cxx @@ -24,8 +24,8 @@ using namespace XAO; -DoubleField::DoubleField(const std::string& name, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents) - : Field(name, dimension, nbElements, nbComponents) +DoubleField::DoubleField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name) + : Field(dimension, nbElements, nbComponents, name) { } diff --git a/src/XAO/XAO_DoubleField.hxx b/src/XAO/XAO_DoubleField.hxx index 2ea44cf27..b622de51a 100644 --- a/src/XAO/XAO_DoubleField.hxx +++ b/src/XAO/XAO_DoubleField.hxx @@ -38,12 +38,12 @@ namespace XAO public: /** * Constructor. - * @param name the name of the field. * @param dimension the dimension of the field. * @param nbElements the number of elements. * @param nbComponents the number of components. + * @param name the name of the field. */ - DoubleField(const std::string& name, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents); + DoubleField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponentsconst, const std::string& name); virtual const XAO::Type getType() { return XAO::DOUBLE; } diff --git a/src/XAO/XAO_Exception.hxx b/src/XAO/XAO_Exception.hxx index 17f2699ab..dce64a967 100644 --- a/src/XAO/XAO_Exception.hxx +++ b/src/XAO/XAO_Exception.hxx @@ -38,6 +38,8 @@ namespace XAO { } + virtual ~XAO_Exception() throw() {}; + /** * Returns the error message. * @return the error message. @@ -47,6 +49,16 @@ namespace XAO return m_message; } +#ifdef SWIG + %extend + { + std::string __str__() const + { + return std::string(self->what()); + } + } +#endif + private: const char* m_message; }; diff --git a/src/XAO/XAO_Field.cxx b/src/XAO/XAO_Field.cxx index 3a0c171d1..a38105b0e 100644 --- a/src/XAO/XAO_Field.cxx +++ b/src/XAO/XAO_Field.cxx @@ -33,8 +33,8 @@ using namespace XAO; // ------------------------------------------------------- -Field::Field(const std::string& name, const XAO::Dimension& dimension, - const int& nbElements, const int& nbComponents) +Field::Field(const XAO::Dimension& dimension, + const int& nbElements, const int& nbComponents, const std::string& name) : m_name(name), m_dimension(dimension), m_nbElements(nbElements), m_nbComponents(nbComponents) { m_components.reserve(nbComponents); @@ -49,24 +49,17 @@ Field::~Field() } Field* Field::createField(const XAO::Type& type, const XAO::Dimension& dimension, - const int& nbElements, const int& nbComponents) -throw (XAO_Exception) -{ - return createField(type, "", dimension, nbElements, nbComponents); -} - -Field* Field::createField(const XAO::Type& type, const std::string& name, const XAO::Dimension& dimension, - const int& nbElements, const int& nbComponents) + const int& nbElements, const int& nbComponents, const std::string& name) throw (XAO_Exception) { if (type == XAO::BOOLEAN) - return new BooleanField(name, dimension, nbElements, nbComponents); + return new BooleanField(dimension, nbElements, nbComponents, name); if (type == XAO::INTEGER) - return new IntegerField(name, dimension, nbElements, nbComponents); + return new IntegerField(dimension, nbElements, nbComponents, name); if (type == XAO::DOUBLE) - return new DoubleField(name, dimension, nbElements, nbComponents); + return new DoubleField(dimension, nbElements, nbComponents, name); if (type == XAO::STRING) - return new StringField(name, dimension, nbElements, nbComponents); + return new StringField(dimension, nbElements, nbComponents, name); throw XAO_Exception(MsgBuilder() << "Bad Type: " << type); } @@ -121,7 +114,7 @@ throw (XAO_Exception) return; throw XAO_Exception(MsgBuilder() << "Step index is out of range [0, " - << m_nbComponents << "]: " << component); + << m_nbComponents-1 << "]: " << component); } void Field::checkStepIndex(const int& step) @@ -131,5 +124,5 @@ throw (XAO_Exception) return; throw XAO_Exception(MsgBuilder() << "Step index is out of range [0, " - << m_steps.size() << "]: " << step); + << m_steps.size()-1 << "]: " << step); } diff --git a/src/XAO/XAO_Field.hxx b/src/XAO/XAO_Field.hxx index d36987569..88e5f66ee 100644 --- a/src/XAO/XAO_Field.hxx +++ b/src/XAO/XAO_Field.hxx @@ -40,39 +40,28 @@ namespace XAO 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. + * @param name the name of the field. */ - Field(const std::string& name, const XAO::Dimension& dimension, - const int& nbElements, const int& nbComponents); + Field(const XAO::Dimension& dimension, + const int& nbElements, const int& nbComponents, const std::string& name); public: - /** - * Creates a Field of the given type. - * @param type the type of the field to create. - * @param dimension the dimension. - * @param nbElements the number of geometrical elements. - * @param nbComponents the number of components. - * @return the created field. - */ - static Field* createField(const XAO::Type& type, const XAO::Dimension& dimension, - const int& nbElements, const int& nbComponents) - throw (XAO_Exception); - /** /** * Creates a Field of the given type. * @param type the type of the field to create. - * @name the name of the field. * @param dimension the dimension. * @param nbElements the number of geometrical elements. * @param nbComponents the number of components. + * @name the name of the field. * @return the created field. */ - static Field* createField(const XAO::Type& type, const std::string& name, const XAO::Dimension& dimension, - const int& nbElements, const int& nbComponents) + static Field* createField(const XAO::Type& type, const XAO::Dimension& dimension, + const int& nbElements, const int& nbComponents, + const std::string& name = std::string("")) throw (XAO_Exception); /** diff --git a/src/XAO/XAO_GeometricElement.cxx b/src/XAO/XAO_GeometricElement.cxx index 6a77f534e..4e3de3096 100644 --- a/src/XAO/XAO_GeometricElement.cxx +++ b/src/XAO/XAO_GeometricElement.cxx @@ -71,7 +71,8 @@ throw (XAO_Exception) if (m_count >= 0 && index < m_count) return; - throw XAO_Exception(MsgBuilder() << "Index of element is out of range [0, " << m_count<< "]: " << index); + throw XAO_Exception(MsgBuilder() << "Index of element is out of range [0, " + << m_count-1 << "]: " << index); } void GeometricElementList::setElement(const int& index, const std::string& name, const std::string& reference) diff --git a/src/XAO/XAO_Geometry.hxx b/src/XAO/XAO_Geometry.hxx index 4cfc080ef..12ca3101a 100644 --- a/src/XAO/XAO_Geometry.hxx +++ b/src/XAO/XAO_Geometry.hxx @@ -43,6 +43,7 @@ namespace XAO Geometry(const std::string& name); public: + /** * Creates a geometry. * @param format the format of the geometry. @@ -60,7 +61,7 @@ namespace XAO throw (XAO_Exception); /** Destructor. */ - ~Geometry(); + virtual ~Geometry(); /** * Gets the name of the geometry. @@ -85,8 +86,8 @@ namespace XAO */ virtual const XAO::Format getFormat() = 0; - virtual const std::string getShape() = 0; - virtual void setShape(const std::string& shape) = 0; + virtual const std::string getShapeString() = 0; + virtual void setShapeString(const std::string& shape) = 0; const int countElements(const XAO::Dimension& dim) const throw (XAO_Exception); const int countVertices() const { return m_vertices.getSize(); } diff --git a/src/XAO/XAO_Group.cxx b/src/XAO/XAO_Group.cxx index 91ac36f89..50bdb272e 100644 --- a/src/XAO/XAO_Group.cxx +++ b/src/XAO/XAO_Group.cxx @@ -24,19 +24,7 @@ using namespace XAO; -Group::Group(const XAO::Dimension& dim, const int& nbElements) -throw (XAO_Exception) -{ - initGroup("", dim, nbElements); -} - -Group::Group(const std::string& name, const XAO::Dimension& dim, const int& nbElements) -throw (XAO_Exception) -{ - initGroup(name, dim, nbElements); -} - -void Group::initGroup(const std::string& name, const XAO::Dimension& dim, const int& nbElements) +Group::Group(const XAO::Dimension& dim, const int& nbElements, const std::string& name) throw (XAO_Exception) { if (dim == XAO::WHOLE) diff --git a/src/XAO/XAO_Group.hxx b/src/XAO/XAO_Group.hxx index 0625600d5..a5857f25e 100644 --- a/src/XAO/XAO_Group.hxx +++ b/src/XAO/XAO_Group.hxx @@ -39,16 +39,10 @@ namespace XAO * Constructor. * @param dim the dimension of the group. * @param nbElements the number of geometrical elements for the dimension in the geometry. + * @param the name of the group. */ - Group(const XAO::Dimension& dim, const int& nbElements) throw (XAO_Exception); - - /** - * Constructor. - * @name the name of the group. - * @param dim the dimension of the group. - * @param nbElements the number of geometrical elements for the dimension in the geometry. - */ - Group(const std::string& name, const XAO::Dimension& dim, const int& nbelements) throw (XAO_Exception); + Group(const XAO::Dimension& dim, const int& nbelements, const std::string& name = std::string("")) + throw (XAO_Exception); /** * Destructor. @@ -138,15 +132,6 @@ namespace XAO std::set::iterator end() { return m_elements.end(); } private: - /** - * Initialize the groups. - * @param name the name of the group. - * @param dim the dimension of the group. - * @param nbElements the number of elements in the geometry for the dimension. - */ - void initGroup(const std::string& name, const XAO::Dimension& dim, const int& nbElements) - throw (XAO_Exception); - /** * Ensures that the given element is valid. * @param element diff --git a/src/XAO/XAO_IntegerField.cxx b/src/XAO/XAO_IntegerField.cxx index b7ac73c48..2fc46ff5d 100644 --- a/src/XAO/XAO_IntegerField.cxx +++ b/src/XAO/XAO_IntegerField.cxx @@ -24,8 +24,8 @@ using namespace XAO; -IntegerField::IntegerField(const std::string& name, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents) - : Field(name, dimension, nbElements, nbComponents) +IntegerField::IntegerField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name) + : Field(dimension, nbElements, nbComponents, name) { } diff --git a/src/XAO/XAO_IntegerField.hxx b/src/XAO/XAO_IntegerField.hxx index e801c25bd..9e33cb364 100644 --- a/src/XAO/XAO_IntegerField.hxx +++ b/src/XAO/XAO_IntegerField.hxx @@ -38,12 +38,12 @@ namespace XAO public: /** * Constructor. - * @param name the name of the field. * @param dimension the dimension of the field. * @param nbElements the number of elements. * @param nbComponents the number of components. + * @param name the name of the field. */ - IntegerField(const std::string& name, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents); + IntegerField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name); virtual const XAO::Type getType() { return XAO::INTEGER; } diff --git a/src/XAO/XAO_Step.cxx b/src/XAO/XAO_Step.cxx index 1ea713627..26d8a4d06 100644 --- a/src/XAO/XAO_Step.cxx +++ b/src/XAO/XAO_Step.cxx @@ -35,7 +35,7 @@ throw (XAO_Exception) return; throw XAO_Exception(MsgBuilder() << "Element index is out of range [0, " - << m_nbElements-1 << "]: " << element); + << m_nbElements-1 << "]: " << element); } void Step::checkComponentIndex(const int& component) @@ -45,7 +45,7 @@ throw (XAO_Exception) return; throw XAO_Exception(MsgBuilder() << "Component index is out of range [0, " - << m_nbComponents-1 << "]: " << component); + << m_nbComponents-1 << "]: " << component); } void Step::checkNbElements(const int& nbElements) diff --git a/src/XAO/XAO_StringField.cxx b/src/XAO/XAO_StringField.cxx index 07e8c708e..b7b5aba6a 100644 --- a/src/XAO/XAO_StringField.cxx +++ b/src/XAO/XAO_StringField.cxx @@ -24,8 +24,8 @@ using namespace XAO; -StringField::StringField(const std::string& name, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents) - : Field(name, dimension, nbElements, nbComponents) +StringField::StringField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name) + : Field(dimension, nbElements, nbComponents, name) { } diff --git a/src/XAO/XAO_StringField.hxx b/src/XAO/XAO_StringField.hxx index 489f23459..b9adb690e 100644 --- a/src/XAO/XAO_StringField.hxx +++ b/src/XAO/XAO_StringField.hxx @@ -38,12 +38,12 @@ namespace XAO public: /** * Constructor. - * @param name the name of the field. * @param dimension the dimension of the field. * @param nbElements the number of elements. * @param nbComponents the number of components. + * @param name the name of the field. */ - StringField(const std::string& name, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents); + StringField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name); virtual const XAO::Type getType() { return XAO::STRING; } diff --git a/src/XAO/XAO_Xao.cxx b/src/XAO/XAO_Xao.cxx index 61621db0b..2bff2edf7 100644 --- a/src/XAO/XAO_Xao.cxx +++ b/src/XAO/XAO_Xao.cxx @@ -18,11 +18,13 @@ // // Author : Nathalie Gore (OpenCascade), Frederic Pons (OpenCascade) +#include #include "XAO_XaoUtils.hxx" #include "XAO_Xao.hxx" #include "XAO_Geometry.hxx" #include "XAO_Group.hxx" #include "XAO_Field.hxx" +#include "XAO_IntegerField.hxx" #include "XAO_XaoExporter.hxx" using namespace XAO; @@ -82,19 +84,13 @@ throw (XAO_Exception) return NULL; } -Group* Xao::addGroup(const XAO::Dimension& dim) -throw (XAO_Exception) -{ - return addGroup("", dim); -} - -Group* Xao::addGroup(const std::string& name, const XAO::Dimension& dim) +Group* Xao::addGroup(const XAO::Dimension& dim, const std::string& name) throw (XAO_Exception) { checkGeometry(); checkGroupDimension(dim); - Group* group = new Group(name, dim, m_geometry->countElements(dim)); + Group* group = new Group(dim, m_geometry->countElements(dim), name); m_groups.push_back(group); return group; } @@ -103,7 +99,15 @@ bool Xao::removeGroup(Group* group) { int nb = countGroups(); m_groups.remove(group); - return (nb-1 == countGroups()); + + bool res = (nb-1 == countGroups()); + if (res) + { + delete group; + group = NULL; + } + + return res; } const int Xao::countFields() const @@ -126,18 +130,12 @@ throw (XAO_Exception) return NULL; } -Field* Xao::addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents) -throw (XAO_Exception) -{ - return addField(type, "", dim, nbComponents); -} - -Field* Xao::addField(const XAO::Type& type, const std::string& name, const XAO::Dimension& dim, const int& nbComponents) +Field* Xao::addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents, const std::string& name) throw (XAO_Exception) { checkGeometry(); int nbElts = m_geometry->countElements(dim); - Field* field = Field::createField(type, name, dim, nbElts, nbComponents); + Field* field = Field::createField(type, dim, nbElts, nbComponents, name); m_fields.push_back(field); return field; } @@ -146,7 +144,15 @@ bool Xao::removeField(Field* field) { int nb = countFields(); m_fields.remove(field); - return (nb-1 == countFields()); + + bool res = (nb-1 == countFields()); + if (res) + { + delete field; + field = NULL; + } + + return res; } const bool Xao::exportXAO(const std::string& fileName) diff --git a/src/XAO/XAO_Xao.hxx b/src/XAO/XAO_Xao.hxx index a6685bc30..241cf4cd7 100644 --- a/src/XAO/XAO_Xao.hxx +++ b/src/XAO/XAO_Xao.hxx @@ -130,16 +130,10 @@ namespace XAO /** * Adds a group. * \param dim the dimension of the group. - * \return the created group. - */ - Group* addGroup(const XAO::Dimension& dim) throw (XAO_Exception); - /** - * Adds a group. * \param name the name of the group. - * \param dim the dimension of the group. * \return the created group. */ - Group* addGroup(const std::string& name, const XAO::Dimension& dim) throw (XAO_Exception); + Group* addGroup(const XAO::Dimension& dim, const std::string& name = std::string("")) throw (XAO_Exception); /** * Removes a group. * \param group the group to remove. @@ -162,25 +156,19 @@ namespace XAO * \return the field. */ Field* getField(const int& index) throw (XAO_Exception); + /** * Adds a field. * \param type the type of the field. * \param dim the dimension of the field. * \param nbComponents the number of components in the field. - * \return the created field. - */ - Field* addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents) - throw (XAO_Exception); - /** - * Adds a field. - * \param type the type of the field. * \param name the name of the field. - * \param dim the dimension of the field. - * \param nbComponents the number of components in the field. * \return the created field. */ - Field* addField(const XAO::Type& type, const std::string& name, const XAO::Dimension& dim, const int& nbComponents) + Field* addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents, + const std::string& name = std::string("")) throw (XAO_Exception); + /** * Removes a field. * \param field the field to remove. diff --git a/src/XAO/XAO_XaoExporter.cxx b/src/XAO/XAO_XaoExporter.cxx index cd68ec5c9..414f118ce 100644 --- a/src/XAO/XAO_XaoExporter.cxx +++ b/src/XAO/XAO_XaoExporter.cxx @@ -200,7 +200,7 @@ void XaoExporter::exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePt xmlNodePtr shape = xmlNewChild(geometry, 0, C_TAG_SHAPE, 0); xmlNewProp(shape, C_ATTR_SHAPE_FORMAT, BAD_CAST XaoUtils::shapeFormatToString(xaoGeometry->getFormat()).c_str()); - std::string txtShape = xaoGeometry->getShape(); + std::string txtShape = xaoGeometry->getShapeString(); xmlNodePtr cdata = xmlNewCDataBlock(doc, BAD_CAST txtShape.c_str(), txtShape.size()); xmlAddChild(shape, cdata); @@ -386,7 +386,7 @@ void XaoExporter::parseShapeNode(xmlDocPtr doc, xmlNodePtr shapeNode, Geometry* xmlChar* data = xmlNodeGetContent(shapeNode->children); if (data == NULL) throw XAO_Exception("Missing BREP"); - geometry->setShape((char*)data); + geometry->setShapeString((char*)data); xmlFree(data); } else diff --git a/src/XAO/XAO_XaoUtils.hxx b/src/XAO/XAO_XaoUtils.hxx index 5718db52b..cc82e0d2d 100644 --- a/src/XAO/XAO_XaoUtils.hxx +++ b/src/XAO/XAO_XaoUtils.hxx @@ -174,6 +174,7 @@ namespace XAO /** Destructor. */ ~MsgBuilder() {}; +#ifndef SWIG /** Stream operator. */ template MsgBuilder& operator <<(const T& t) @@ -186,6 +187,7 @@ namespace XAO * Conversion operator to char*. */ operator const char*() const { return m_stream.str().c_str(); } +#endif private : std::stringstream m_stream; diff --git a/src/XAO/tests/BrepGeometryTest.cxx b/src/XAO/tests/BrepGeometryTest.cxx index 97761379a..096676aad 100644 --- a/src/XAO/tests/BrepGeometryTest.cxx +++ b/src/XAO/tests/BrepGeometryTest.cxx @@ -23,7 +23,7 @@ void BrepGeometryTest::cleanUp() void readBrep(Geometry* geom, const std::string& fileName) { char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath(fileName)); - geom->setShape(txt); + geom->setShapeString(txt); } void BrepGeometryTest::testGetIDs() diff --git a/src/XAO/tests/GeometryTest.cxx b/src/XAO/tests/GeometryTest.cxx index 9f27039c7..aa68e353b 100644 --- a/src/XAO/tests/GeometryTest.cxx +++ b/src/XAO/tests/GeometryTest.cxx @@ -117,7 +117,7 @@ void GeometryTest::testSetElement() CPPUNIT_ASSERT_THROW(geom->setVertexName(0, "aa"), XAO_Exception); char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath("Box_1.brep")); - geom->setShape(txt); + geom->setShapeString(txt); CPPUNIT_ASSERT_EQUAL(false, geom->hasVertexName(0)); geom->setVertexName(0, "va"); diff --git a/src/XAO/tests/ImportExportTest.cxx b/src/XAO/tests/ImportExportTest.cxx index b84f04eac..3a7945af5 100644 --- a/src/XAO/tests/ImportExportTest.cxx +++ b/src/XAO/tests/ImportExportTest.cxx @@ -90,7 +90,7 @@ void ImportExportTest::testExportGeometry() group->add(1); // fields - IntegerField* field = (IntegerField*)xao.addField(XAO::INTEGER, "color", XAO::FACE, 2); + IntegerField* field = (IntegerField*)xao.addField(XAO::INTEGER, XAO::FACE, 2, "color"); for (int stepIndex = 0; stepIndex < 10; ++stepIndex) { IntegerStep* istep = field->addStep(stepIndex, 100*stepIndex); diff --git a/src/XAO/tests/XaoTest.cxx b/src/XAO/tests/XaoTest.cxx index 40cf5a090..6d1ed0a83 100644 --- a/src/XAO/tests/XaoTest.cxx +++ b/src/XAO/tests/XaoTest.cxx @@ -33,15 +33,19 @@ void XaoTest::testGroups() CPPUNIT_ASSERT_EQUAL(XAO::FACE, gr->getDimension()); CPPUNIT_ASSERT_EQUAL(1, obj.countGroups()); Group* gr2 = obj.addGroup(XAO::FACE); + gr2->setName("AA"); Group* agr = obj.getGroup(0); CPPUNIT_ASSERT(gr == agr); CPPUNIT_ASSERT_THROW(obj.getGroup(10), XAO_Exception); CPPUNIT_ASSERT_EQUAL(true, obj.removeGroup(gr2)); - CPPUNIT_ASSERT(gr2 != NULL); CPPUNIT_ASSERT_EQUAL(1, obj.countGroups()); - CPPUNIT_ASSERT_EQUAL(false, obj.removeGroup(gr2)); // remove again + + // remove other group + Group* gr3 = new Group(XAO::FACE, 3); + CPPUNIT_ASSERT_EQUAL(false, obj.removeGroup(gr3)); + delete gr3; } void XaoTest::testFields() @@ -64,7 +68,10 @@ void XaoTest::testFields() CPPUNIT_ASSERT_THROW(obj.getField(10), XAO_Exception); CPPUNIT_ASSERT_EQUAL(true, obj.removeField(fb)); - CPPUNIT_ASSERT(fb != NULL); CPPUNIT_ASSERT_EQUAL(3, obj.countFields()); - CPPUNIT_ASSERT_EQUAL(false, obj.removeField(fb)); // remove again + + + Field* ff = Field::createField(XAO::INTEGER, XAO::FACE, 3, 3); + CPPUNIT_ASSERT_EQUAL(false, obj.removeField(ff)); + delete ff; } -- 2.39.2