mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-11 00:33:08 +05:00
move optional name parameter to the end
This commit is contained in:
parent
d1d1ae4704
commit
390054003f
@ -154,7 +154,7 @@ void GEOMImpl_IImportExportOperations::exportGroups(std::list<Handle(GEOM_Object
|
|||||||
|
|
||||||
TopAbs_ShapeEnum shapeGroup = m_groupOperations->GetType(currGroup);
|
TopAbs_ShapeEnum shapeGroup = m_groupOperations->GetType(currGroup);
|
||||||
XAO::Dimension dim = shapeEnumToDimension(shapeGroup);
|
XAO::Dimension dim = shapeEnumToDimension(shapeGroup);
|
||||||
XAO::Group* group = xaoObject->addGroup(currGroup->GetName(), dim);
|
XAO::Group* group = xaoObject->addGroup(dim, currGroup->GetName());
|
||||||
|
|
||||||
switch (shapeGroup)
|
switch (shapeGroup)
|
||||||
{
|
{
|
||||||
|
@ -24,9 +24,9 @@
|
|||||||
|
|
||||||
using namespace XAO;
|
using namespace XAO;
|
||||||
|
|
||||||
BooleanField::BooleanField(const std::string& name, const XAO::Dimension& dimension,
|
BooleanField::BooleanField(const XAO::Dimension& dimension,
|
||||||
const int& nbElements, const int& nbComponents)
|
const int& nbElements, const int& nbComponents, const std::string& name)
|
||||||
: Field(name, dimension, nbElements, nbComponents)
|
: Field(dimension, nbElements, nbComponents, name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,12 +38,12 @@ namespace XAO
|
|||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param name the name of the field.
|
|
||||||
* @param dimension the dimension of the field.
|
* @param dimension the dimension of the field.
|
||||||
* @param nbElements the number of elements.
|
* @param nbElements the number of elements.
|
||||||
* @param nbComponents the number of components.
|
* @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; }
|
virtual const XAO::Type getType() { return XAO::BOOLEAN; }
|
||||||
|
|
||||||
|
@ -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;
|
std::ostringstream streamShape;
|
||||||
BRepTools::Write(m_shape, streamShape);
|
BRepTools::Write(m_shape, streamShape);
|
||||||
@ -59,7 +59,7 @@ const std::string BrepGeometry::getShape()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrepGeometry::setShape(const std::string& shape)
|
void BrepGeometry::setShapeString(const std::string& shape)
|
||||||
{
|
{
|
||||||
std::istringstream streamBrep(shape.c_str());
|
std::istringstream streamBrep(shape.c_str());
|
||||||
BRep_Builder builder;
|
BRep_Builder builder;
|
||||||
|
@ -49,6 +49,8 @@ namespace XAO
|
|||||||
*/
|
*/
|
||||||
BrepGeometry(const std::string& name);
|
BrepGeometry(const std::string& name);
|
||||||
|
|
||||||
|
virtual ~BrepGeometry() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the format of the geometry.
|
* Gets the format of the geometry.
|
||||||
* @return the format of the geometry.
|
* @return the format of the geometry.
|
||||||
@ -59,13 +61,23 @@ namespace XAO
|
|||||||
* Gets the shape as a string.
|
* Gets the shape as a string.
|
||||||
* @return 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.
|
* Sets the shape from a string.
|
||||||
* @param shape the shape as 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.
|
* Gets the shape as a TopoDS_Shape.
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
using namespace XAO;
|
using namespace XAO;
|
||||||
|
|
||||||
DoubleField::DoubleField(const std::string& name, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents)
|
DoubleField::DoubleField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name)
|
||||||
: Field(name, dimension, nbElements, nbComponents)
|
: Field(dimension, nbElements, nbComponents, name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,12 +38,12 @@ namespace XAO
|
|||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param name the name of the field.
|
|
||||||
* @param dimension the dimension of the field.
|
* @param dimension the dimension of the field.
|
||||||
* @param nbElements the number of elements.
|
* @param nbElements the number of elements.
|
||||||
* @param nbComponents the number of components.
|
* @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; }
|
virtual const XAO::Type getType() { return XAO::DOUBLE; }
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ namespace XAO
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ~XAO_Exception() throw() {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the error message.
|
* Returns the error message.
|
||||||
* @return the error message.
|
* @return the error message.
|
||||||
@ -47,6 +49,16 @@ namespace XAO
|
|||||||
return m_message;
|
return m_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SWIG
|
||||||
|
%extend
|
||||||
|
{
|
||||||
|
std::string __str__() const
|
||||||
|
{
|
||||||
|
return std::string(self->what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char* m_message;
|
const char* m_message;
|
||||||
};
|
};
|
||||||
|
@ -33,8 +33,8 @@ using namespace XAO;
|
|||||||
|
|
||||||
// -------------------------------------------------------
|
// -------------------------------------------------------
|
||||||
|
|
||||||
Field::Field(const std::string& name, const XAO::Dimension& dimension,
|
Field::Field(const XAO::Dimension& dimension,
|
||||||
const int& nbElements, const int& nbComponents)
|
const int& nbElements, const int& nbComponents, const std::string& name)
|
||||||
: m_name(name), m_dimension(dimension), m_nbElements(nbElements), m_nbComponents(nbComponents)
|
: m_name(name), m_dimension(dimension), m_nbElements(nbElements), m_nbComponents(nbComponents)
|
||||||
{
|
{
|
||||||
m_components.reserve(nbComponents);
|
m_components.reserve(nbComponents);
|
||||||
@ -49,24 +49,17 @@ Field::~Field()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Field* Field::createField(const XAO::Type& type, const XAO::Dimension& dimension,
|
Field* Field::createField(const XAO::Type& type, const XAO::Dimension& dimension,
|
||||||
const int& nbElements, const int& nbComponents)
|
const int& nbElements, const int& nbComponents, const std::string& name)
|
||||||
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)
|
|
||||||
throw (XAO_Exception)
|
throw (XAO_Exception)
|
||||||
{
|
{
|
||||||
if (type == XAO::BOOLEAN)
|
if (type == XAO::BOOLEAN)
|
||||||
return new BooleanField(name, dimension, nbElements, nbComponents);
|
return new BooleanField(dimension, nbElements, nbComponents, name);
|
||||||
if (type == XAO::INTEGER)
|
if (type == XAO::INTEGER)
|
||||||
return new IntegerField(name, dimension, nbElements, nbComponents);
|
return new IntegerField(dimension, nbElements, nbComponents, name);
|
||||||
if (type == XAO::DOUBLE)
|
if (type == XAO::DOUBLE)
|
||||||
return new DoubleField(name, dimension, nbElements, nbComponents);
|
return new DoubleField(dimension, nbElements, nbComponents, name);
|
||||||
if (type == XAO::STRING)
|
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);
|
throw XAO_Exception(MsgBuilder() << "Bad Type: " << type);
|
||||||
}
|
}
|
||||||
@ -121,7 +114,7 @@ throw (XAO_Exception)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
throw XAO_Exception(MsgBuilder() << "Step index is out of range [0, "
|
throw XAO_Exception(MsgBuilder() << "Step index is out of range [0, "
|
||||||
<< m_nbComponents << "]: " << component);
|
<< m_nbComponents-1 << "]: " << component);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Field::checkStepIndex(const int& step)
|
void Field::checkStepIndex(const int& step)
|
||||||
@ -131,5 +124,5 @@ throw (XAO_Exception)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
throw XAO_Exception(MsgBuilder() << "Step index is out of range [0, "
|
throw XAO_Exception(MsgBuilder() << "Step index is out of range [0, "
|
||||||
<< m_steps.size() << "]: " << step);
|
<< m_steps.size()-1 << "]: " << step);
|
||||||
}
|
}
|
||||||
|
@ -40,39 +40,28 @@ namespace XAO
|
|||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param name the name of the field.
|
|
||||||
* @param dimension the dimension ot the field.
|
* @param dimension the dimension ot the field.
|
||||||
* @param nbElements the number of elements.
|
* @param nbElements the number of elements.
|
||||||
* @param nbComponents the number of components.
|
* @param nbComponents the number of components.
|
||||||
|
* @param name the name of the field.
|
||||||
*/
|
*/
|
||||||
Field(const std::string& name, const XAO::Dimension& dimension,
|
Field(const XAO::Dimension& dimension,
|
||||||
const int& nbElements, const int& nbComponents);
|
const int& nbElements, const int& nbComponents, const std::string& name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
/**
|
/**
|
||||||
* Creates a Field of the given type.
|
* Creates a Field of the given type.
|
||||||
* @param type the type of the field to create.
|
* @param type the type of the field to create.
|
||||||
* @param dimension the dimension.
|
* @param dimension the dimension.
|
||||||
* @param nbElements the number of geometrical elements.
|
* @param nbElements the number of geometrical elements.
|
||||||
* @param nbComponents the number of components.
|
* @param nbComponents the number of components.
|
||||||
|
* @name the name of the field.
|
||||||
* @return the created field.
|
* @return the created field.
|
||||||
*/
|
*/
|
||||||
static Field* createField(const XAO::Type& type, const XAO::Dimension& dimension,
|
static Field* createField(const XAO::Type& type, const XAO::Dimension& dimension,
|
||||||
const int& nbElements, const int& nbComponents)
|
const int& nbElements, const int& nbComponents,
|
||||||
throw (XAO_Exception);
|
const std::string& name = std::string(""))
|
||||||
|
|
||||||
/**
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
* @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)
|
|
||||||
throw (XAO_Exception);
|
throw (XAO_Exception);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,7 +71,8 @@ throw (XAO_Exception)
|
|||||||
if (m_count >= 0 && index < m_count)
|
if (m_count >= 0 && index < m_count)
|
||||||
return;
|
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)
|
void GeometricElementList::setElement(const int& index, const std::string& name, const std::string& reference)
|
||||||
|
@ -43,6 +43,7 @@ namespace XAO
|
|||||||
Geometry(const std::string& name);
|
Geometry(const std::string& name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a geometry.
|
* Creates a geometry.
|
||||||
* @param format the format of the geometry.
|
* @param format the format of the geometry.
|
||||||
@ -60,7 +61,7 @@ namespace XAO
|
|||||||
throw (XAO_Exception);
|
throw (XAO_Exception);
|
||||||
|
|
||||||
/** Destructor. */
|
/** Destructor. */
|
||||||
~Geometry();
|
virtual ~Geometry();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name of the geometry.
|
* Gets the name of the geometry.
|
||||||
@ -85,8 +86,8 @@ namespace XAO
|
|||||||
*/
|
*/
|
||||||
virtual const XAO::Format getFormat() = 0;
|
virtual const XAO::Format getFormat() = 0;
|
||||||
|
|
||||||
virtual const std::string getShape() = 0;
|
virtual const std::string getShapeString() = 0;
|
||||||
virtual void setShape(const std::string& shape) = 0;
|
virtual void setShapeString(const std::string& shape) = 0;
|
||||||
|
|
||||||
const int countElements(const XAO::Dimension& dim) const throw (XAO_Exception);
|
const int countElements(const XAO::Dimension& dim) const throw (XAO_Exception);
|
||||||
const int countVertices() const { return m_vertices.getSize(); }
|
const int countVertices() const { return m_vertices.getSize(); }
|
||||||
|
@ -24,19 +24,7 @@
|
|||||||
using namespace XAO;
|
using namespace XAO;
|
||||||
|
|
||||||
|
|
||||||
Group::Group(const XAO::Dimension& dim, const int& nbElements)
|
Group::Group(const XAO::Dimension& dim, const int& nbElements, const std::string& name)
|
||||||
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)
|
|
||||||
throw (XAO_Exception)
|
throw (XAO_Exception)
|
||||||
{
|
{
|
||||||
if (dim == XAO::WHOLE)
|
if (dim == XAO::WHOLE)
|
||||||
|
@ -39,16 +39,10 @@ namespace XAO
|
|||||||
* Constructor.
|
* Constructor.
|
||||||
* @param dim the dimension of the group.
|
* @param dim the dimension of the group.
|
||||||
* @param nbElements the number of geometrical elements for the dimension in the geometry.
|
* @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);
|
Group(const XAO::Dimension& dim, const int& nbelements, const std::string& name = std::string(""))
|
||||||
|
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);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
@ -138,15 +132,6 @@ namespace XAO
|
|||||||
std::set<int>::iterator end() { return m_elements.end(); }
|
std::set<int>::iterator end() { return m_elements.end(); }
|
||||||
|
|
||||||
private:
|
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.
|
* Ensures that the given element is valid.
|
||||||
* @param element
|
* @param element
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
using namespace XAO;
|
using namespace XAO;
|
||||||
|
|
||||||
IntegerField::IntegerField(const std::string& name, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents)
|
IntegerField::IntegerField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name)
|
||||||
: Field(name, dimension, nbElements, nbComponents)
|
: Field(dimension, nbElements, nbComponents, name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,12 +38,12 @@ namespace XAO
|
|||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param name the name of the field.
|
|
||||||
* @param dimension the dimension of the field.
|
* @param dimension the dimension of the field.
|
||||||
* @param nbElements the number of elements.
|
* @param nbElements the number of elements.
|
||||||
* @param nbComponents the number of components.
|
* @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; }
|
virtual const XAO::Type getType() { return XAO::INTEGER; }
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
using namespace XAO;
|
using namespace XAO;
|
||||||
|
|
||||||
StringField::StringField(const std::string& name, const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents)
|
StringField::StringField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name)
|
||||||
: Field(name, dimension, nbElements, nbComponents)
|
: Field(dimension, nbElements, nbComponents, name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,12 +38,12 @@ namespace XAO
|
|||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param name the name of the field.
|
|
||||||
* @param dimension the dimension of the field.
|
* @param dimension the dimension of the field.
|
||||||
* @param nbElements the number of elements.
|
* @param nbElements the number of elements.
|
||||||
* @param nbComponents the number of components.
|
* @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; }
|
virtual const XAO::Type getType() { return XAO::STRING; }
|
||||||
|
|
||||||
|
@ -18,11 +18,13 @@
|
|||||||
//
|
//
|
||||||
// Author : Nathalie Gore (OpenCascade), Frederic Pons (OpenCascade)
|
// Author : Nathalie Gore (OpenCascade), Frederic Pons (OpenCascade)
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include "XAO_XaoUtils.hxx"
|
#include "XAO_XaoUtils.hxx"
|
||||||
#include "XAO_Xao.hxx"
|
#include "XAO_Xao.hxx"
|
||||||
#include "XAO_Geometry.hxx"
|
#include "XAO_Geometry.hxx"
|
||||||
#include "XAO_Group.hxx"
|
#include "XAO_Group.hxx"
|
||||||
#include "XAO_Field.hxx"
|
#include "XAO_Field.hxx"
|
||||||
|
#include "XAO_IntegerField.hxx"
|
||||||
#include "XAO_XaoExporter.hxx"
|
#include "XAO_XaoExporter.hxx"
|
||||||
|
|
||||||
using namespace XAO;
|
using namespace XAO;
|
||||||
@ -82,19 +84,13 @@ throw (XAO_Exception)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Group* Xao::addGroup(const XAO::Dimension& dim)
|
Group* Xao::addGroup(const XAO::Dimension& dim, const std::string& name)
|
||||||
throw (XAO_Exception)
|
|
||||||
{
|
|
||||||
return addGroup("", dim);
|
|
||||||
}
|
|
||||||
|
|
||||||
Group* Xao::addGroup(const std::string& name, const XAO::Dimension& dim)
|
|
||||||
throw (XAO_Exception)
|
throw (XAO_Exception)
|
||||||
{
|
{
|
||||||
checkGeometry();
|
checkGeometry();
|
||||||
checkGroupDimension(dim);
|
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);
|
m_groups.push_back(group);
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
@ -103,7 +99,15 @@ bool Xao::removeGroup(Group* group)
|
|||||||
{
|
{
|
||||||
int nb = countGroups();
|
int nb = countGroups();
|
||||||
m_groups.remove(group);
|
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
|
const int Xao::countFields() const
|
||||||
@ -126,18 +130,12 @@ throw (XAO_Exception)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Field* Xao::addField(const XAO::Type& type, 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)
|
|
||||||
{
|
|
||||||
return addField(type, "", dim, nbComponents);
|
|
||||||
}
|
|
||||||
|
|
||||||
Field* Xao::addField(const XAO::Type& type, const std::string& name, const XAO::Dimension& dim, const int& nbComponents)
|
|
||||||
throw (XAO_Exception)
|
throw (XAO_Exception)
|
||||||
{
|
{
|
||||||
checkGeometry();
|
checkGeometry();
|
||||||
int nbElts = m_geometry->countElements(dim);
|
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);
|
m_fields.push_back(field);
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
@ -146,7 +144,15 @@ bool Xao::removeField(Field* field)
|
|||||||
{
|
{
|
||||||
int nb = countFields();
|
int nb = countFields();
|
||||||
m_fields.remove(field);
|
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)
|
const bool Xao::exportXAO(const std::string& fileName)
|
||||||
|
@ -130,16 +130,10 @@ namespace XAO
|
|||||||
/**
|
/**
|
||||||
* Adds a group.
|
* Adds a group.
|
||||||
* \param dim the dimension of the 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 name the name of the group.
|
||||||
* \param dim the dimension of the group.
|
|
||||||
* \return the created 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.
|
* Removes a group.
|
||||||
* \param group the group to remove.
|
* \param group the group to remove.
|
||||||
@ -162,25 +156,19 @@ namespace XAO
|
|||||||
* \return the field.
|
* \return the field.
|
||||||
*/
|
*/
|
||||||
Field* getField(const int& index) throw (XAO_Exception);
|
Field* getField(const int& index) throw (XAO_Exception);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a field.
|
* Adds a field.
|
||||||
* \param type the type of the field.
|
* \param type the type of the field.
|
||||||
* \param dim the dimension of the field.
|
* \param dim the dimension of the field.
|
||||||
* \param nbComponents the number of components in 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 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.
|
* \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);
|
throw (XAO_Exception);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a field.
|
* Removes a field.
|
||||||
* \param field the field to remove.
|
* \param field the field to remove.
|
||||||
|
@ -200,7 +200,7 @@ void XaoExporter::exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePt
|
|||||||
|
|
||||||
xmlNodePtr shape = xmlNewChild(geometry, 0, C_TAG_SHAPE, 0);
|
xmlNodePtr shape = xmlNewChild(geometry, 0, C_TAG_SHAPE, 0);
|
||||||
xmlNewProp(shape, C_ATTR_SHAPE_FORMAT, BAD_CAST XaoUtils::shapeFormatToString(xaoGeometry->getFormat()).c_str());
|
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());
|
xmlNodePtr cdata = xmlNewCDataBlock(doc, BAD_CAST txtShape.c_str(), txtShape.size());
|
||||||
xmlAddChild(shape, cdata);
|
xmlAddChild(shape, cdata);
|
||||||
|
|
||||||
@ -386,7 +386,7 @@ void XaoExporter::parseShapeNode(xmlDocPtr doc, xmlNodePtr shapeNode, Geometry*
|
|||||||
xmlChar* data = xmlNodeGetContent(shapeNode->children);
|
xmlChar* data = xmlNodeGetContent(shapeNode->children);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
throw XAO_Exception("Missing BREP");
|
throw XAO_Exception("Missing BREP");
|
||||||
geometry->setShape((char*)data);
|
geometry->setShapeString((char*)data);
|
||||||
xmlFree(data);
|
xmlFree(data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -174,6 +174,7 @@ namespace XAO
|
|||||||
/** Destructor. */
|
/** Destructor. */
|
||||||
~MsgBuilder() {};
|
~MsgBuilder() {};
|
||||||
|
|
||||||
|
#ifndef SWIG
|
||||||
/** Stream operator. */
|
/** Stream operator. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
MsgBuilder& operator <<(const T& t)
|
MsgBuilder& operator <<(const T& t)
|
||||||
@ -186,6 +187,7 @@ namespace XAO
|
|||||||
* Conversion operator to char*.
|
* Conversion operator to char*.
|
||||||
*/
|
*/
|
||||||
operator const char*() const { return m_stream.str().c_str(); }
|
operator const char*() const { return m_stream.str().c_str(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
private :
|
private :
|
||||||
std::stringstream m_stream;
|
std::stringstream m_stream;
|
||||||
|
@ -23,7 +23,7 @@ void BrepGeometryTest::cleanUp()
|
|||||||
void readBrep(Geometry* geom, const std::string& fileName)
|
void readBrep(Geometry* geom, const std::string& fileName)
|
||||||
{
|
{
|
||||||
char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath(fileName));
|
char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath(fileName));
|
||||||
geom->setShape(txt);
|
geom->setShapeString(txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrepGeometryTest::testGetIDs()
|
void BrepGeometryTest::testGetIDs()
|
||||||
|
@ -117,7 +117,7 @@ void GeometryTest::testSetElement()
|
|||||||
CPPUNIT_ASSERT_THROW(geom->setVertexName(0, "aa"), XAO_Exception);
|
CPPUNIT_ASSERT_THROW(geom->setVertexName(0, "aa"), XAO_Exception);
|
||||||
|
|
||||||
char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath("Box_1.brep"));
|
char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath("Box_1.brep"));
|
||||||
geom->setShape(txt);
|
geom->setShapeString(txt);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(false, geom->hasVertexName(0));
|
CPPUNIT_ASSERT_EQUAL(false, geom->hasVertexName(0));
|
||||||
geom->setVertexName(0, "va");
|
geom->setVertexName(0, "va");
|
||||||
|
@ -90,7 +90,7 @@ void ImportExportTest::testExportGeometry()
|
|||||||
group->add(1);
|
group->add(1);
|
||||||
|
|
||||||
// fields
|
// 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)
|
for (int stepIndex = 0; stepIndex < 10; ++stepIndex)
|
||||||
{
|
{
|
||||||
IntegerStep* istep = field->addStep(stepIndex, 100*stepIndex);
|
IntegerStep* istep = field->addStep(stepIndex, 100*stepIndex);
|
||||||
|
@ -33,15 +33,19 @@ void XaoTest::testGroups()
|
|||||||
CPPUNIT_ASSERT_EQUAL(XAO::FACE, gr->getDimension());
|
CPPUNIT_ASSERT_EQUAL(XAO::FACE, gr->getDimension());
|
||||||
CPPUNIT_ASSERT_EQUAL(1, obj.countGroups());
|
CPPUNIT_ASSERT_EQUAL(1, obj.countGroups());
|
||||||
Group* gr2 = obj.addGroup(XAO::FACE);
|
Group* gr2 = obj.addGroup(XAO::FACE);
|
||||||
|
gr2->setName("AA");
|
||||||
|
|
||||||
Group* agr = obj.getGroup(0);
|
Group* agr = obj.getGroup(0);
|
||||||
CPPUNIT_ASSERT(gr == agr);
|
CPPUNIT_ASSERT(gr == agr);
|
||||||
CPPUNIT_ASSERT_THROW(obj.getGroup(10), XAO_Exception);
|
CPPUNIT_ASSERT_THROW(obj.getGroup(10), XAO_Exception);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(true, obj.removeGroup(gr2));
|
CPPUNIT_ASSERT_EQUAL(true, obj.removeGroup(gr2));
|
||||||
CPPUNIT_ASSERT(gr2 != NULL);
|
|
||||||
CPPUNIT_ASSERT_EQUAL(1, obj.countGroups());
|
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()
|
void XaoTest::testFields()
|
||||||
@ -64,7 +68,10 @@ void XaoTest::testFields()
|
|||||||
CPPUNIT_ASSERT_THROW(obj.getField(10), XAO_Exception);
|
CPPUNIT_ASSERT_THROW(obj.getField(10), XAO_Exception);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(true, obj.removeField(fb));
|
CPPUNIT_ASSERT_EQUAL(true, obj.removeField(fb));
|
||||||
CPPUNIT_ASSERT(fb != NULL);
|
|
||||||
CPPUNIT_ASSERT_EQUAL(3, obj.countFields());
|
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user