mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-28 07:30:33 +05:00
more rework
This commit is contained in:
parent
e128656640
commit
17602f8a3a
@ -42,9 +42,6 @@ namespace XAO
|
||||
BooleanStep* addStep(const int& step);
|
||||
BooleanStep* addStep(const int& step, const int& stamp);
|
||||
BooleanStep* getStep(const int& index);
|
||||
|
||||
// private:
|
||||
// std::vector<BooleanStep*> m_steps;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -25,20 +25,20 @@ using namespace XAO;
|
||||
|
||||
BooleanStep::BooleanStep(const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
Init(0, 0, nbElements, nbComponents);
|
||||
init(0, 0, nbElements, nbComponents);
|
||||
}
|
||||
|
||||
BooleanStep::BooleanStep(const int& step, const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
Init(step, 0, nbElements, nbComponents);
|
||||
init(step, 0, nbElements, nbComponents);
|
||||
}
|
||||
|
||||
BooleanStep::BooleanStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
Init(step, stamp, nbElements, nbComponents);
|
||||
init(step, stamp, nbElements, nbComponents);
|
||||
}
|
||||
|
||||
void BooleanStep::Init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
|
||||
void BooleanStep::init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
m_nbElements = nbElements;
|
||||
m_nbComponents = nbComponents;
|
||||
@ -104,6 +104,11 @@ const bool BooleanStep::getValue(const int& element, const int& component)
|
||||
return m_values[element][component];
|
||||
}
|
||||
|
||||
const std::string BooleanStep::getStringValue(const int& element, const int& component)
|
||||
{
|
||||
return (getValue(element, component) ? "true" : "false");
|
||||
}
|
||||
|
||||
void BooleanStep::setValues(const std::vector<bool>& values)
|
||||
{
|
||||
if (values.size() != m_nbComponents * m_nbElements)
|
||||
@ -145,3 +150,11 @@ void BooleanStep::setValue(const int& element, const int& component, const bool&
|
||||
|
||||
m_values[element][component] = value;
|
||||
}
|
||||
|
||||
void BooleanStep::setStringValue(const int& element, const int& component, const std::string& value)
|
||||
{
|
||||
if (value != "true" && value != "false")
|
||||
throw SALOME_Exception("Bad boolean value");
|
||||
|
||||
setValue(element, component, value == "true");
|
||||
}
|
||||
|
@ -72,8 +72,11 @@ namespace XAO
|
||||
void setComponents(const int& component, const std::vector<bool>& components);
|
||||
void setValue(const int& element, const int& component, const bool& value);
|
||||
|
||||
virtual const std::string getStringValue(const int& element, const int& component);
|
||||
virtual void setStringValue(const int& element, const int& component, const std::string& value);
|
||||
|
||||
private:
|
||||
void Init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents);
|
||||
void init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents);
|
||||
|
||||
private:
|
||||
std::vector< std::vector<bool> > m_values;
|
||||
|
@ -43,9 +43,6 @@ namespace XAO
|
||||
DoubleStep* addStep(const int& step);
|
||||
DoubleStep* addStep(const int& step, const int& stamp);
|
||||
DoubleStep* getStep(const int& index);
|
||||
|
||||
// private:
|
||||
// std::vector<DoubleStep*> m_steps;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -20,25 +20,26 @@
|
||||
|
||||
#include "DoubleStep.hxx"
|
||||
#include <Utils_SALOME_Exception.hxx>
|
||||
#include "XaoUtils.hxx"
|
||||
|
||||
using namespace XAO;
|
||||
|
||||
DoubleStep::DoubleStep(const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
Init(0, 0, nbElements, nbComponents);
|
||||
init(0, 0, nbElements, nbComponents);
|
||||
}
|
||||
|
||||
DoubleStep::DoubleStep(const int& step, const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
Init(step, 0, nbElements, nbComponents);
|
||||
init(step, 0, nbElements, nbComponents);
|
||||
}
|
||||
|
||||
DoubleStep::DoubleStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
Init(step, stamp, nbElements, nbComponents);
|
||||
init(step, stamp, nbElements, nbComponents);
|
||||
}
|
||||
|
||||
void DoubleStep::Init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
|
||||
void DoubleStep::init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
m_nbElements = nbElements;
|
||||
m_nbComponents = nbComponents;
|
||||
@ -104,6 +105,11 @@ const double DoubleStep::getValue(const int& element, const int& component)
|
||||
return m_values[element][component];
|
||||
}
|
||||
|
||||
const std::string DoubleStep::getStringValue(const int& element, const int& component)
|
||||
{
|
||||
return XaoUtils::doubleToString(getValue(element, component));
|
||||
}
|
||||
|
||||
void DoubleStep::setValues(const std::vector<double>& values)
|
||||
{
|
||||
if (values.size() != m_nbComponents * m_nbElements)
|
||||
@ -145,3 +151,8 @@ void DoubleStep::setValue(const int& element, const int& component, const double
|
||||
|
||||
m_values[element][component] = value;
|
||||
}
|
||||
|
||||
void DoubleStep::setStringValue(const int& element, const int& component, const std::string& value)
|
||||
{
|
||||
setValue(element, component, XaoUtils::stringToDouble(value));
|
||||
}
|
||||
|
@ -49,8 +49,11 @@ namespace XAO
|
||||
void setComponents(const int& component, const std::vector<double>& components);
|
||||
void setValue(const int& element, const int& component, const double& value);
|
||||
|
||||
virtual const std::string getStringValue(const int& element, const int& component);
|
||||
virtual void setStringValue(const int& element, const int& component, const std::string& value);
|
||||
|
||||
private:
|
||||
void Init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents);
|
||||
void init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents);
|
||||
|
||||
private:
|
||||
std::vector< std::vector<double> > m_values;
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
namespace XAO
|
||||
{
|
||||
typedef std::vector<Step*>::iterator stepIterator;
|
||||
|
||||
/**
|
||||
* @class Field
|
||||
* A geometrical Field.
|
||||
@ -136,6 +138,9 @@ namespace XAO
|
||||
*/
|
||||
bool removeStep(Step* step);
|
||||
|
||||
stepIterator begin() { return m_steps.begin(); }
|
||||
stepIterator end() { return m_steps.end(); }
|
||||
|
||||
private:
|
||||
void checkComponent(const int& component);
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
//
|
||||
// Author : Frederic Pons (OpenCascade)
|
||||
|
||||
#include <cstring>
|
||||
#include <Utils_SALOME_Exception.hxx>
|
||||
|
||||
#include "GeometricElement.hxx"
|
||||
@ -32,7 +31,7 @@ GeometricElement::GeometricElement()
|
||||
m_reference = "";
|
||||
}
|
||||
|
||||
GeometricElement::GeometricElement(const char* name, const char* reference)
|
||||
GeometricElement::GeometricElement(const std::string& name, const std::string& reference)
|
||||
{
|
||||
m_name = name;
|
||||
m_reference = reference;
|
||||
@ -52,12 +51,12 @@ GeometricElementList::GeometricElementList()
|
||||
setSize(0);
|
||||
}
|
||||
|
||||
GeometricElementList::GeometricElementList(const int count)
|
||||
GeometricElementList::GeometricElementList(const int& count)
|
||||
{
|
||||
setSize(m_count);
|
||||
}
|
||||
|
||||
void GeometricElementList::setSize(const int nb)
|
||||
void GeometricElementList::setSize(const int& nb)
|
||||
{
|
||||
m_count = nb;
|
||||
m_elements.clear();
|
||||
@ -67,7 +66,7 @@ void GeometricElementList::setSize(const int nb)
|
||||
}
|
||||
}
|
||||
|
||||
void GeometricElementList::setElement(const int index, const char* name, const char* reference)
|
||||
void GeometricElementList::setElement(const int& index, const std::string& name, const std::string& reference)
|
||||
{
|
||||
if (m_count == 0 || index > m_count)
|
||||
throw SALOME_Exception("Problem with number of elements");
|
||||
@ -76,7 +75,7 @@ void GeometricElementList::setElement(const int index, const char* name, const c
|
||||
m_elements[index].setReference(reference);
|
||||
}
|
||||
|
||||
const char* GeometricElementList::getName(const int index)
|
||||
const std::string GeometricElementList::getName(const int& index)
|
||||
{
|
||||
if (m_count == 0 || index > m_count)
|
||||
throw SALOME_Exception("Problem with number of elements");
|
||||
@ -84,7 +83,7 @@ const char* GeometricElementList::getName(const int index)
|
||||
return m_elements[index].getName();
|
||||
}
|
||||
|
||||
void GeometricElementList::setName(const int index, const char* name)
|
||||
void GeometricElementList::setName(const int& index, const std::string& name)
|
||||
{
|
||||
if (m_count == 0 || index > m_count)
|
||||
{
|
||||
@ -94,7 +93,7 @@ void GeometricElementList::setName(const int index, const char* name)
|
||||
m_elements[index].setName(name);
|
||||
}
|
||||
|
||||
bool GeometricElementList::hasName(const int index)
|
||||
const bool GeometricElementList::hasName(const int& index)
|
||||
{
|
||||
if (m_count == 0 || index > m_count)
|
||||
{
|
||||
@ -104,7 +103,7 @@ bool GeometricElementList::hasName(const int index)
|
||||
return m_elements[index].hasName();
|
||||
}
|
||||
|
||||
const char* GeometricElementList::getReference(const int index)
|
||||
const std::string GeometricElementList::getReference(const int& index)
|
||||
{
|
||||
if (m_count == 0 || index > m_count)
|
||||
throw SALOME_Exception("Problem with number of elements");
|
||||
@ -112,7 +111,7 @@ const char* GeometricElementList::getReference(const int index)
|
||||
return m_elements[index].getReference();
|
||||
}
|
||||
|
||||
void GeometricElementList::setReference(const int index, const char* name)
|
||||
void GeometricElementList::setReference(const int& index, const std::string& name)
|
||||
{
|
||||
if (m_count == 0 || index > m_count)
|
||||
throw SALOME_Exception("Problem with number of elements");
|
||||
@ -120,11 +119,11 @@ void GeometricElementList::setReference(const int index, const char* name)
|
||||
m_elements[index].setReference(name);
|
||||
}
|
||||
|
||||
const int GeometricElementList::getIndexByReference(const char* ref)
|
||||
const int GeometricElementList::getIndexByReference(const std::string& ref)
|
||||
{
|
||||
for (int index = 0; index < m_count; ++index)
|
||||
{
|
||||
if (strcmp(ref, m_elements[index].getReference()) == 0)
|
||||
if (ref == m_elements[index].getReference())
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ namespace XAO
|
||||
* \param name the name of the element.
|
||||
* \param reference the reference of the element.
|
||||
*/
|
||||
GeometricElement(const char* name, const char* reference);
|
||||
GeometricElement(const std::string& name, const std::string& reference);
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
@ -52,15 +52,15 @@ namespace XAO
|
||||
* Gets the name of the element.
|
||||
* \return the name.
|
||||
*/
|
||||
const char* getName()
|
||||
const std::string getName()
|
||||
{
|
||||
return m_name.c_str();
|
||||
return m_name;
|
||||
}
|
||||
/**
|
||||
* Sets the name of the element
|
||||
* \param name the name to set.
|
||||
*/
|
||||
void setName(const char* name)
|
||||
void setName(const std::string& name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
@ -75,15 +75,15 @@ namespace XAO
|
||||
* Gets the reference of the element.
|
||||
* \return the reference.
|
||||
*/
|
||||
const char* getReference()
|
||||
const std::string getReference()
|
||||
{
|
||||
return m_reference.c_str();
|
||||
return m_reference;
|
||||
}
|
||||
/**
|
||||
* Sets the reference of the element.
|
||||
* \param reference the reference to set.
|
||||
*/
|
||||
void setReference(const char* reference)
|
||||
void setReference(const std::string& reference)
|
||||
{
|
||||
m_reference = reference;
|
||||
}
|
||||
@ -108,7 +108,7 @@ namespace XAO
|
||||
* Constructor with size.
|
||||
* \param nb the size to set.
|
||||
*/
|
||||
GeometricElementList(const int nb);
|
||||
GeometricElementList(const int& nb);
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
@ -118,13 +118,13 @@ namespace XAO
|
||||
* Gets the size of the list.
|
||||
* \return the size of the list.
|
||||
*/
|
||||
int getSize() { return m_count; }
|
||||
const int getSize() { return m_count; }
|
||||
/**
|
||||
* Sets the size of the list.
|
||||
* \param nb the size to set.
|
||||
* \warning the list will be cleared.
|
||||
*/
|
||||
void setSize(const int nb);
|
||||
void setSize(const int& nb);
|
||||
|
||||
/**
|
||||
* Sets the name and the reference of an element.
|
||||
@ -133,28 +133,28 @@ namespace XAO
|
||||
* \param reference the reference to set.
|
||||
* \throw SALOME_Exception if index is bigger than the size of the list.
|
||||
*/
|
||||
void setElement(const int index, const char* name, const char* reference);
|
||||
void setElement(const int& index, const std::string& name, const std::string& reference);
|
||||
/**
|
||||
* Gets the name of an element.
|
||||
* \param index the index of the element to set.
|
||||
* \return the name of the element with the given index.
|
||||
* \throw SALOME_Exception if index is bigger than the size of the list.
|
||||
*/
|
||||
const char* getName(const int index);
|
||||
const std::string getName(const int& index);
|
||||
/**
|
||||
* Sets the name of an element.
|
||||
* \param index the index of the element.
|
||||
* \param name the name to set.
|
||||
* \throw SALOME_Exception if index is bigger than the size of the list.
|
||||
*/
|
||||
void setName(const int index, const char* name);
|
||||
void setName(const int& index, const std::string& name);
|
||||
|
||||
/**
|
||||
* Checks if an element has a name.
|
||||
* @param index the index of the element.
|
||||
* @return true if the element has a name, false otherwise.
|
||||
*/
|
||||
bool hasName(const int index);
|
||||
const bool hasName(const int& index);
|
||||
|
||||
/**
|
||||
* Gets the reference of an element.
|
||||
@ -162,21 +162,21 @@ namespace XAO
|
||||
* \return the reference of the element.
|
||||
* \throw SALOME_Exception if index is bigger than the size of the list.
|
||||
*/
|
||||
const char* getReference(const int index);
|
||||
const std::string getReference(const int& index);
|
||||
/**
|
||||
* Sets the reference of an element.
|
||||
* \param index the index of the element to set.
|
||||
* \param reference the reference to set.
|
||||
* \throw SALOME_Exception if index is bigger than the size of the list.
|
||||
*/
|
||||
void setReference(const int index, const char* reference);
|
||||
void setReference(const int& index, const std::string& reference);
|
||||
|
||||
/**
|
||||
* Gets the index of an element using its reference.
|
||||
* \param reference the searched reference.
|
||||
* \return the index of the element or -1 if no element found.
|
||||
*/
|
||||
const int getIndexByReference(const char* reference);
|
||||
const int getIndexByReference(const std::string& reference);
|
||||
|
||||
/**
|
||||
* Iterator on the element of the list.
|
||||
|
@ -150,7 +150,21 @@ void Geometry::initListIds(const Standard_Integer shapeType)
|
||||
}
|
||||
}
|
||||
|
||||
const char* Geometry::getElementReference(const Dimension dim, const int index)
|
||||
const int Geometry::countElements(const XAO::Dimension& dim)
|
||||
{
|
||||
if (dim == VERTEX)
|
||||
return countVertices();
|
||||
if (dim == EDGE)
|
||||
return countEdges();
|
||||
if (dim == FACE)
|
||||
return countFaces();
|
||||
if (dim == SOLID)
|
||||
return countSolids();
|
||||
|
||||
throw SALOME_Exception("Unknown dimension");
|
||||
}
|
||||
|
||||
const std::string Geometry::getElementReference(const XAO::Dimension& dim, const int& index)
|
||||
{
|
||||
if (dim == VERTEX)
|
||||
return getVertexReference(index);
|
||||
@ -165,7 +179,7 @@ const char* Geometry::getElementReference(const Dimension dim, const int index)
|
||||
throw SALOME_Exception("Unknown dimension");
|
||||
}
|
||||
|
||||
const int Geometry::getElementIndexByReference(const Dimension dim, const char* reference)
|
||||
const int Geometry::getElementIndexByReference(const XAO::Dimension& dim, const std::string& reference)
|
||||
{
|
||||
if (dim == VERTEX)
|
||||
return getVertexIndexByReference(reference);
|
||||
@ -180,7 +194,7 @@ const int Geometry::getElementIndexByReference(const Dimension dim, const char*
|
||||
throw SALOME_Exception("Unknown dimension");
|
||||
}
|
||||
|
||||
GeometricElementList::iterator Geometry::begin(const Dimension dim)
|
||||
GeometricElementList::iterator Geometry::begin(const XAO::Dimension& dim)
|
||||
{
|
||||
if (dim == VERTEX)
|
||||
return m_vertices.begin();
|
||||
@ -195,7 +209,7 @@ GeometricElementList::iterator Geometry::begin(const Dimension dim)
|
||||
throw SALOME_Exception("Unknown dimension");
|
||||
}
|
||||
|
||||
GeometricElementList::iterator Geometry::end(const Dimension dim)
|
||||
GeometricElementList::iterator Geometry::end(const XAO::Dimension& dim)
|
||||
{
|
||||
if (dim == VERTEX)
|
||||
return m_vertices.end();
|
||||
|
@ -37,20 +37,20 @@ namespace XAO
|
||||
Geometry();
|
||||
~Geometry();
|
||||
|
||||
const char* getName()
|
||||
const std::string getName()
|
||||
{
|
||||
return m_name.c_str();
|
||||
return m_name;
|
||||
}
|
||||
void setName(const char* name)
|
||||
void setName(const std::string& name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
const char* getFormat()
|
||||
const std::string getFormat()
|
||||
{
|
||||
return m_format.c_str();
|
||||
return m_format;
|
||||
}
|
||||
void setFormat(const char* format)
|
||||
void setFormat(const std::string& format)
|
||||
{
|
||||
m_format = format;
|
||||
}
|
||||
@ -64,55 +64,56 @@ namespace XAO
|
||||
const char* getBREP();
|
||||
void setShape(const char* brep);
|
||||
|
||||
int countVertices() { return m_vertices.getSize(); }
|
||||
int countEdges() { return m_edges.getSize(); }
|
||||
int countFaces() { return m_faces.getSize(); }
|
||||
int countSolids() { return m_solids.getSize(); }
|
||||
const int countElements(const XAO::Dimension& dim);
|
||||
const int countVertices() { return m_vertices.getSize(); }
|
||||
const int countEdges() { return m_edges.getSize(); }
|
||||
const int countFaces() { return m_faces.getSize(); }
|
||||
const int countSolids() { return m_solids.getSize(); }
|
||||
|
||||
void setCountVertices(const int nb) { m_vertices.setSize(nb); }
|
||||
void setCountEdges(const int nb) { m_edges.setSize(nb); }
|
||||
void setCountFaces(const int nb) { m_faces.setSize(nb); }
|
||||
void setCountSolids(const int nb) { m_solids.setSize(nb); }
|
||||
void setCountVertices(const int& nb) { m_vertices.setSize(nb); }
|
||||
void setCountEdges(const int& nb) { m_edges.setSize(nb); }
|
||||
void setCountFaces(const int& nb) { m_faces.setSize(nb); }
|
||||
void setCountSolids(const int& nb) { m_solids.setSize(nb); }
|
||||
|
||||
void setVertex(const int index, const char* name, const char* reference) { m_vertices.setElement(index, name, reference); }
|
||||
void setEdge(const int index, const char* name, const char* reference) { m_edges.setElement(index, name, reference); }
|
||||
void setFace(const int index, const char* name, const char* reference) { m_faces.setElement(index, name, reference); }
|
||||
void setSolid(const int index, const char* name, const char* reference) { m_solids.setElement(index, name, 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 char* getVertexName(const int index) { return m_vertices.getName(index); }
|
||||
const char* getEdgeName(const int index) { return m_edges.getName(index); }
|
||||
const char* getFaceName(const int index) { return m_faces.getName(index); }
|
||||
const char* getSolidName(const int index) { return m_solids.getName(index); }
|
||||
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); }
|
||||
const std::string getSolidName(const int& index) { return m_solids.getName(index); }
|
||||
|
||||
void setVertexName(const int index, const char* name) { m_vertices.setName(index, name); }
|
||||
void setEdgeName(const int index, const char* name) { m_edges.setName(index, name); }
|
||||
void setFaceName(const int index, const char* name) { m_faces.setName(index, name); }
|
||||
void setSolidName(const int index, const char* name) { m_solids.setName(index, name); }
|
||||
void setVertexName(const int& index, const std::string& name) { m_vertices.setName(index, name); }
|
||||
void setEdgeName(const int& index, const std::string& name) { m_edges.setName(index, name); }
|
||||
void setFaceName(const int& index, const std::string& name) { m_faces.setName(index, name); }
|
||||
void setSolidName(const int& index, const std::string& name) { m_solids.setName(index, name); }
|
||||
|
||||
bool hasVertexName(const int index) { return m_vertices.hasName(index); }
|
||||
bool hasEdgeName(const int index) { return m_edges.hasName(index); }
|
||||
bool hasFaceName(const int index) { return m_faces.hasName(index); }
|
||||
bool hasSolidName(const int index) { return m_solids.hasName(index); }
|
||||
const bool hasVertexName(const int& index) { return m_vertices.hasName(index); }
|
||||
const bool hasEdgeName(const int& index) { return m_edges.hasName(index); }
|
||||
const bool hasFaceName(const int& index) { return m_faces.hasName(index); }
|
||||
const bool hasSolidName(const int& index) { return m_solids.hasName(index); }
|
||||
|
||||
const char* getVertexReference(const int index) { return m_vertices.getReference(index); }
|
||||
const char* getEdgeReference(const int index) { return m_edges.getReference(index); }
|
||||
const char* getFaceReference(const int index) { return m_faces.getReference(index); }
|
||||
const char* getSolidReference(const int index) { return m_solids.getReference(index); }
|
||||
const char* getElementReference(const Dimension dim, const int index);
|
||||
const std::string getVertexReference(const int& index) { return m_vertices.getReference(index); }
|
||||
const std::string getEdgeReference(const int& index) { return m_edges.getReference(index); }
|
||||
const std::string getFaceReference(const int& index) { return m_faces.getReference(index); }
|
||||
const std::string getSolidReference(const int& index) { return m_solids.getReference(index); }
|
||||
const std::string getElementReference(const XAO::Dimension& dim, const int& index);
|
||||
|
||||
void setVertexReference(const int index, const char* reference) { m_vertices.setReference(index, reference); }
|
||||
void setEdgeReference(const int index, const char* reference) { m_edges.setReference(index, reference); }
|
||||
void setFaceReference(const int index, const char* reference) { m_faces.setReference(index, reference); }
|
||||
void setSolidReference(const int index, const char* reference) { m_solids.setReference(index, reference); }
|
||||
void setVertexReference(const int& index, const std::string& reference) { m_vertices.setReference(index, reference); }
|
||||
void setEdgeReference(const int& index, const std::string& reference) { m_edges.setReference(index, reference); }
|
||||
void setFaceReference(const int& index, const std::string& reference) { m_faces.setReference(index, reference); }
|
||||
void setSolidReference(const int& index, const std::string& reference) { m_solids.setReference(index, reference); }
|
||||
|
||||
const int getVertexIndexByReference(const char* reference) { return m_vertices.getIndexByReference(reference); }
|
||||
const int getEdgeIndexByReference(const char* reference) { return m_edges.getIndexByReference(reference); }
|
||||
const int getFaceIndexByReference(const char* reference) { return m_faces.getIndexByReference(reference); }
|
||||
const int getSolidIndexByReference(const char* reference) { return m_solids.getIndexByReference(reference); }
|
||||
const int getElementIndexByReference(const Dimension dim, const char* 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); }
|
||||
const int getSolidIndexByReference(const std::string& reference) { return m_solids.getIndexByReference(reference); }
|
||||
const int getElementIndexByReference(const XAO::Dimension& dim, const std::string& reference);
|
||||
|
||||
GeometricElementList::iterator begin(const Dimension dim);
|
||||
GeometricElementList::iterator end(const Dimension dim);
|
||||
GeometricElementList::iterator begin(const XAO::Dimension& dim);
|
||||
GeometricElementList::iterator end(const XAO::Dimension& dim);
|
||||
|
||||
private:
|
||||
void initListIds(const Standard_Integer shapeType);
|
||||
|
@ -18,27 +18,41 @@
|
||||
//
|
||||
// Author : Nathalie Gore (OpenCascade), Frederic Pons (OpenCascade)
|
||||
|
||||
#include <sstream>
|
||||
#include "Group.hxx"
|
||||
#include <Utils_SALOME_Exception.hxx>
|
||||
|
||||
using namespace XAO;
|
||||
|
||||
Group::Group()
|
||||
|
||||
Group::Group(const XAO::Dimension& dim, const int& nbElements)
|
||||
{
|
||||
m_dimension = VERTEX;
|
||||
initGroup("", dim, nbElements);
|
||||
}
|
||||
|
||||
Group::Group(const std::string& name, const XAO::Dimension& dim, const int& nbElements)
|
||||
{
|
||||
initGroup(name, dim, nbElements);
|
||||
}
|
||||
|
||||
void Group::initGroup(const std::string& name, const XAO::Dimension& dim, const int& nbElements)
|
||||
{
|
||||
m_name = name;
|
||||
m_dimension = dim;
|
||||
m_count = 0;
|
||||
m_nbElements = nbElements;
|
||||
}
|
||||
|
||||
Group::~Group()
|
||||
{
|
||||
}
|
||||
|
||||
const Dimension Group::getDimension()
|
||||
void Group::checkElement(const int& element)
|
||||
{
|
||||
return m_dimension;
|
||||
}
|
||||
|
||||
void Group::setDimension(const Dimension dimension)
|
||||
{
|
||||
m_dimension = dimension;
|
||||
if (element >= m_nbElements)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << "IndexOutOfRange element: " << element << " >= " << m_nbElements;
|
||||
throw SALOME_Exception(str.str().c_str()); // TODO
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ namespace XAO
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
Group();
|
||||
Group(const XAO::Dimension& dim, const int& nbElements);
|
||||
Group(const std::string& name, const XAO::Dimension& dim, const int& nbelements);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
@ -50,7 +51,7 @@ namespace XAO
|
||||
* Sets the name of the group.
|
||||
* \param name the name to set.
|
||||
*/
|
||||
void setName(const char* name)
|
||||
void setName(const std::string& name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
@ -58,22 +59,19 @@ namespace XAO
|
||||
* Gets the name of the group.
|
||||
* \return the name of the group.
|
||||
*/
|
||||
const char *getName() const
|
||||
const std::string getName() const
|
||||
{
|
||||
return m_name.c_str();
|
||||
return m_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dimension of the group.
|
||||
* \return the dimension of the group.
|
||||
*/
|
||||
const Dimension getDimension();
|
||||
|
||||
/**
|
||||
* Sets the dimension of the group.
|
||||
* \param dim the dimension to set.
|
||||
*/
|
||||
void setDimension(const Dimension dim);
|
||||
const XAO::Dimension getDimension()
|
||||
{
|
||||
return m_dimension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of elements in the group.
|
||||
@ -88,8 +86,9 @@ namespace XAO
|
||||
* Adds an element to the group.
|
||||
* \param value the index of the element to add in the geometric element list (vertex, face...).
|
||||
*/
|
||||
void addElement(const int value)
|
||||
void addElement(const int& value)
|
||||
{
|
||||
checkElement(value);
|
||||
m_elements.push_back(value);
|
||||
}
|
||||
|
||||
@ -98,16 +97,23 @@ namespace XAO
|
||||
* \param index the index of the element.
|
||||
* \return the reference of the element.
|
||||
*/
|
||||
const int getElement(const int index)
|
||||
const int getElement(const int& index)
|
||||
{
|
||||
checkElement(index);
|
||||
return m_elements[index];
|
||||
}
|
||||
|
||||
private:
|
||||
void initGroup(const std::string& name, const XAO::Dimension& dim, const int& nbElements);
|
||||
void checkElement(const int& element);
|
||||
|
||||
private:
|
||||
/** The name of the group. */
|
||||
std::string m_name;
|
||||
/** The number of elements in the associated geometry. */
|
||||
int m_nbElements;
|
||||
/** The dimension of the group. */
|
||||
Dimension m_dimension;
|
||||
XAO::Dimension m_dimension;
|
||||
/** The number of elements in the group. */
|
||||
int m_count;
|
||||
/** The elements of the group. */
|
||||
|
@ -43,9 +43,6 @@ namespace XAO
|
||||
IntegerStep* addStep(const int& step);
|
||||
IntegerStep* addStep(const int& step, const int& stamp);
|
||||
IntegerStep* getStep(const int& index);
|
||||
|
||||
// private:
|
||||
// std::vector<IntegerStep*> m_steps;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -20,25 +20,26 @@
|
||||
|
||||
#include "IntegerStep.hxx"
|
||||
#include <Utils_SALOME_Exception.hxx>
|
||||
#include "XaoUtils.hxx"
|
||||
|
||||
using namespace XAO;
|
||||
|
||||
IntegerStep::IntegerStep(const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
Init(0, 0, nbElements, nbComponents);
|
||||
init(0, 0, nbElements, nbComponents);
|
||||
}
|
||||
|
||||
IntegerStep::IntegerStep(const int& step, const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
Init(step, 0, nbElements, nbComponents);
|
||||
init(step, 0, nbElements, nbComponents);
|
||||
}
|
||||
|
||||
IntegerStep::IntegerStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
Init(step, stamp, nbElements, nbComponents);
|
||||
init(step, stamp, nbElements, nbComponents);
|
||||
}
|
||||
|
||||
void IntegerStep::Init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
|
||||
void IntegerStep::init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
m_nbElements = nbElements;
|
||||
m_nbComponents = nbComponents;
|
||||
@ -104,6 +105,11 @@ const int IntegerStep::getValue(const int& element, const int& component)
|
||||
return m_values[element][component];
|
||||
}
|
||||
|
||||
const std::string IntegerStep::getStringValue(const int& element, const int& component)
|
||||
{
|
||||
return XaoUtils::intToString(getValue(element, component));
|
||||
}
|
||||
|
||||
void IntegerStep::setValues(const std::vector<int>& values)
|
||||
{
|
||||
if (values.size() != m_nbComponents * m_nbElements)
|
||||
@ -145,3 +151,8 @@ void IntegerStep::setValue(const int& element, const int& component, const int&
|
||||
|
||||
m_values[element][component] = value;
|
||||
}
|
||||
|
||||
void IntegerStep::setStringValue(const int& element, const int& component, const std::string& value)
|
||||
{
|
||||
setValue(element, component, XaoUtils::stringToInt(value));
|
||||
}
|
||||
|
@ -49,8 +49,11 @@ namespace XAO
|
||||
void setComponents(const int& element, const std::vector<int>& components);
|
||||
void setValue(const int& element, const int& component, const int& value);
|
||||
|
||||
virtual const std::string getStringValue(const int& element, const int& component);
|
||||
virtual void setStringValue(const int& element, const int& component, const std::string& value);
|
||||
|
||||
private:
|
||||
void Init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents);
|
||||
void init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents);
|
||||
|
||||
private:
|
||||
std::vector< std::vector<int> > m_values;
|
||||
|
@ -68,6 +68,9 @@ namespace XAO
|
||||
|
||||
const int countValues() { return m_nbElements * m_nbComponents; }
|
||||
|
||||
virtual const std::string getStringValue(const int& element, const int& component) = 0;
|
||||
virtual void setStringValue(const int& element, const int& component, const std::string& value) = 0;
|
||||
|
||||
protected:
|
||||
void checkElement(const int& element);
|
||||
void checkComponent(const int& component);
|
||||
|
@ -43,9 +43,6 @@ namespace XAO
|
||||
StringStep* addStep(const int& step);
|
||||
StringStep* addStep(const int& step, const int& stamp);
|
||||
StringStep* getStep(const int& index);
|
||||
|
||||
// private:
|
||||
// std::vector<StringStep*> m_steps;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -25,20 +25,20 @@ using namespace XAO;
|
||||
|
||||
StringStep::StringStep(const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
Init(0, 0, nbElements, nbComponents);
|
||||
init(0, 0, nbElements, nbComponents);
|
||||
}
|
||||
|
||||
StringStep::StringStep(const int& step, const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
Init(step, 0, nbElements, nbComponents);
|
||||
init(step, 0, nbElements, nbComponents);
|
||||
}
|
||||
|
||||
StringStep::StringStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
Init(step, stamp, nbElements, nbComponents);
|
||||
init(step, stamp, nbElements, nbComponents);
|
||||
}
|
||||
|
||||
void StringStep::Init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
|
||||
void StringStep::init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents)
|
||||
{
|
||||
m_nbElements = nbElements;
|
||||
m_nbComponents = nbComponents;
|
||||
@ -104,6 +104,11 @@ const std::string StringStep::getValue(const int& element, const int& component)
|
||||
return m_values[element][component];
|
||||
}
|
||||
|
||||
const std::string StringStep::getStringValue(const int& element, const int& component)
|
||||
{
|
||||
return getValue(element, component);
|
||||
}
|
||||
|
||||
void StringStep::setValues(const std::vector<std::string>& values)
|
||||
{
|
||||
if (values.size() != m_nbComponents * m_nbElements)
|
||||
@ -145,3 +150,8 @@ void StringStep::setValue(const int& element, const int& component, const std::s
|
||||
|
||||
m_values[element][component] = value;
|
||||
}
|
||||
|
||||
void StringStep::setStringValue(const int& element, const int& component, const std::string& value)
|
||||
{
|
||||
setValue(element, component, value);
|
||||
}
|
||||
|
@ -50,8 +50,11 @@ namespace XAO
|
||||
void setComponents(const int& component, const std::vector<std::string>& components);
|
||||
void setValue(const int& element, const int& component, const std::string& value);
|
||||
|
||||
virtual const std::string getStringValue(const int& element, const int& component);
|
||||
virtual void setStringValue(const int& element, const int& component, const std::string& value);
|
||||
|
||||
private:
|
||||
void Init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents);
|
||||
void init(const int& step, const int& stamp, const int& nbElements, const int& nbComponents);
|
||||
|
||||
private:
|
||||
std::vector< std::vector<std::string> > m_values;
|
||||
|
@ -39,7 +39,7 @@ Xao::Xao()
|
||||
m_geometry = NULL;
|
||||
}
|
||||
|
||||
Xao::Xao(const char* author, const char* version)
|
||||
Xao::Xao(const std::string& author, const std::string& version)
|
||||
{
|
||||
m_author = author;
|
||||
m_version = version;
|
||||
@ -65,12 +65,12 @@ Xao::~Xao()
|
||||
}
|
||||
}
|
||||
|
||||
int Xao::countGroups()
|
||||
const int Xao::countGroups()
|
||||
{
|
||||
return m_groups.size();
|
||||
}
|
||||
|
||||
Group* Xao::getGroup(const int index)
|
||||
Group* Xao::getGroup(const int& index)
|
||||
{
|
||||
int i = 0;
|
||||
for (std::list<Group*>::iterator it = m_groups.begin(); it != m_groups.end(); ++it, ++i)
|
||||
@ -82,9 +82,17 @@ Group* Xao::getGroup(const int index)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Xao::addGroup(Group* group)
|
||||
Group* Xao::addGroup(const XAO::Dimension& dim)
|
||||
{
|
||||
return addGroup("", dim);
|
||||
}
|
||||
|
||||
Group* Xao::addGroup(const std::string& name, const XAO::Dimension& dim)
|
||||
{
|
||||
checkGeometry();
|
||||
Group* group = new Group(name, dim, m_geometry->countElements(dim));
|
||||
m_groups.push_back(group);
|
||||
return group;
|
||||
}
|
||||
|
||||
void Xao::removeGroup(Group* group)
|
||||
@ -92,12 +100,12 @@ void Xao::removeGroup(Group* group)
|
||||
m_groups.remove(group);
|
||||
}
|
||||
|
||||
int Xao::countFields()
|
||||
const int Xao::countFields()
|
||||
{
|
||||
return m_fields.size();
|
||||
}
|
||||
|
||||
Field* Xao::getField(const int index)
|
||||
Field* Xao::getField(const int& index)
|
||||
{
|
||||
int i = 0;
|
||||
for (std::list<Field*>::iterator it = m_fields.begin(); it != m_fields.end(); ++it, ++i)
|
||||
@ -109,9 +117,18 @@ Field* Xao::getField(const int index)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Xao::addField(Field* field)
|
||||
Field* Xao::addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents)
|
||||
{
|
||||
return addField(type, "", dim, nbComponents);
|
||||
}
|
||||
|
||||
Field* Xao::addField(const XAO::Type& type, const std::string& name, const XAO::Dimension& dim, const int& nbComponents)
|
||||
{
|
||||
checkGeometry();
|
||||
int nbElts = m_geometry->countElements(dim);
|
||||
Field* field = Field::createField(type, name, dim, nbElts, nbComponents);
|
||||
m_fields.push_back(field);
|
||||
return field;
|
||||
}
|
||||
|
||||
void Xao::removeField(Field* field)
|
||||
@ -119,7 +136,7 @@ void Xao::removeField(Field* field)
|
||||
m_fields.remove(field);
|
||||
}
|
||||
|
||||
bool Xao::exportXAO(const char* fileName)
|
||||
const bool Xao::exportXAO(const std::string& fileName)
|
||||
{
|
||||
// xmlDocPtr doc = exportXMLDoc();
|
||||
// xmlSaveFormatFileEnc(fileName, doc, "UTF-8", 2);
|
||||
@ -129,7 +146,7 @@ bool Xao::exportXAO(const char* fileName)
|
||||
return XaoExporter::saveToFile(this, fileName);
|
||||
}
|
||||
|
||||
const char* Xao::getXML()
|
||||
const std::string Xao::getXML()
|
||||
{
|
||||
// xmlDocPtr doc = exportXMLDoc();
|
||||
//
|
||||
@ -143,12 +160,18 @@ const char* Xao::getXML()
|
||||
return XaoExporter::saveToXml(this);
|
||||
}
|
||||
|
||||
bool Xao::importXAO(const char* fileName)
|
||||
const bool Xao::importXAO(const std::string& fileName)
|
||||
{
|
||||
return XaoExporter::readFromFile(fileName, this);
|
||||
}
|
||||
|
||||
bool Xao::setXML(const char* xml)
|
||||
const bool Xao::setXML(const std::string& xml)
|
||||
{
|
||||
return XaoExporter::setXML(xml, this);
|
||||
}
|
||||
|
||||
void Xao::checkGeometry()
|
||||
{
|
||||
if (m_geometry == NULL)
|
||||
throw SALOME_Exception("Geometry is null"); // TODO
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ namespace XAO
|
||||
* \param author the author of the file.
|
||||
* \param version the version of the XAO format.
|
||||
*/
|
||||
Xao(const char* author, const char* version);
|
||||
Xao(const std::string& author, const std::string& version);
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
@ -77,15 +77,15 @@ namespace XAO
|
||||
* Gets the author of the file.
|
||||
* \return the author of the file.
|
||||
*/
|
||||
const char* getAuthor()
|
||||
const std::string getAuthor()
|
||||
{
|
||||
return m_author.c_str();
|
||||
return m_author;
|
||||
}
|
||||
/**
|
||||
* Sets the author of the file.
|
||||
* \param author the author to set.
|
||||
*/
|
||||
void setAuthor(const char* author)
|
||||
void setAuthor(const std::string& author)
|
||||
{
|
||||
m_author = author;
|
||||
}
|
||||
@ -94,15 +94,15 @@ namespace XAO
|
||||
* Gets the version of the file.
|
||||
* \return the version of the file.
|
||||
*/
|
||||
const char* getVersion()
|
||||
const std::string getVersion()
|
||||
{
|
||||
return m_version.c_str();
|
||||
return m_version;
|
||||
}
|
||||
/**
|
||||
* Sets the version of the file.
|
||||
* \param version the version to set.
|
||||
*/
|
||||
void setVersion(const char* version)
|
||||
void setVersion(const std::string& version)
|
||||
{
|
||||
m_version = version;
|
||||
}
|
||||
@ -136,18 +136,26 @@ namespace XAO
|
||||
* Gets the number of groups.
|
||||
* \return the number of groups.
|
||||
*/
|
||||
int countGroups();
|
||||
const int countGroups();
|
||||
/**
|
||||
* Gets a group.
|
||||
* \param index the index of the wanted group.
|
||||
* \return the group or NULL if index is bigger than the number of groups.
|
||||
*/
|
||||
Group* getGroup(const int index);
|
||||
Group* getGroup(const int& index);
|
||||
/**
|
||||
* Adds a group.
|
||||
* \param group the group to add.
|
||||
* \param dim the dimension of the group.
|
||||
* \return the created group.
|
||||
*/
|
||||
void addGroup(Group* group);
|
||||
Group* addGroup(const XAO::Dimension& dim);
|
||||
/**
|
||||
* 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);
|
||||
/**
|
||||
* Removes a group.
|
||||
* \param group the group to remove.
|
||||
@ -162,18 +170,30 @@ namespace XAO
|
||||
* Gets the number of fields.
|
||||
* \return the number of fields.
|
||||
*/
|
||||
int countFields();
|
||||
const int countFields();
|
||||
/**
|
||||
* Gets a field.
|
||||
* \param index the index of the wanted field.
|
||||
* \return the field or NULL if the index is bigger than the number of fields.
|
||||
*/
|
||||
Field* getField(const int index);
|
||||
Field* getField(const int& index);
|
||||
/**
|
||||
* Adds a field.
|
||||
* \param field the field to add.
|
||||
* \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.
|
||||
*/
|
||||
void addField(Field* field);
|
||||
Field* addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents);
|
||||
/**
|
||||
* Adds a field.
|
||||
* \param type the type of the field.
|
||||
* \param 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);
|
||||
/**
|
||||
* Removes a field.
|
||||
* \param field the field to remove.
|
||||
@ -188,25 +208,28 @@ namespace XAO
|
||||
* \param fileName the name of the file to create.
|
||||
* \return true is the export is successful.
|
||||
*/
|
||||
bool exportXAO(const char* fileName);
|
||||
const bool exportXAO(const std::string& fileName);
|
||||
/**
|
||||
* Gets the XML corresponding to this XAO.
|
||||
* \return the XML as a string.
|
||||
*/
|
||||
const char* getXML();
|
||||
const std::string getXML();
|
||||
|
||||
/**
|
||||
* Imports an XAO file into this object.
|
||||
* \param fileName the name of the file to import.
|
||||
* \return true if the import is successful.
|
||||
*/
|
||||
bool importXAO(const char* fileName);
|
||||
const bool importXAO(const std::string& fileName);
|
||||
/**
|
||||
* Sets an XML describing an XAO format to this object.
|
||||
* \param xml the XML to set.
|
||||
* \return true if the import is successful.
|
||||
*/
|
||||
bool setXML(const char* xml);
|
||||
const bool setXML(const std::string& xml);
|
||||
|
||||
private:
|
||||
void checkGeometry();
|
||||
|
||||
private:
|
||||
/** The author of the file. */
|
||||
|
@ -7,6 +7,11 @@
|
||||
#include "Geometry.hxx"
|
||||
#include "Group.hxx"
|
||||
#include "Field.hxx"
|
||||
#include "Step.hxx"
|
||||
#include "BooleanStep.hxx"
|
||||
#include "IntegerStep.hxx"
|
||||
#include "DoubleStep.hxx"
|
||||
#include "StringStep.hxx"
|
||||
#include "XaoUtils.hxx"
|
||||
|
||||
namespace XAO
|
||||
@ -63,16 +68,16 @@ namespace XAO
|
||||
|
||||
using namespace XAO;
|
||||
|
||||
bool XaoExporter::saveToFile(Xao* xaoObject, const char* fileName)
|
||||
const bool XaoExporter::saveToFile(Xao* xaoObject, const std::string& fileName)
|
||||
{
|
||||
xmlDocPtr doc = exportXMLDoc(xaoObject);
|
||||
xmlSaveFormatFileEnc(fileName, doc, "UTF-8", 2);
|
||||
xmlSaveFormatFileEnc(fileName.c_str(), doc, "UTF-8", 2);
|
||||
xmlFreeDoc(doc);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* XaoExporter::saveToXml(Xao* xaoObject)
|
||||
const std::string XaoExporter::saveToXml(Xao* xaoObject)
|
||||
{
|
||||
xmlDocPtr doc = exportXMLDoc(xaoObject);
|
||||
|
||||
@ -92,8 +97,8 @@ xmlDocPtr XaoExporter::exportXMLDoc(Xao* xaoObject)
|
||||
xmlNodePtr xao = xmlNewNode(0, C_TAG_XAO);
|
||||
xmlDocSetRootElement(masterDocument, xao);
|
||||
|
||||
xmlNewProp(xao, C_ATTR_XAO_VERSION, BAD_CAST xaoObject->getVersion());
|
||||
xmlNewProp(xao, C_ATTR_XAO_AUTHOR, BAD_CAST xaoObject->getAuthor());
|
||||
xmlNewProp(xao, C_ATTR_XAO_VERSION, BAD_CAST xaoObject->getVersion().c_str());
|
||||
xmlNewProp(xao, C_ATTR_XAO_AUTHOR, BAD_CAST xaoObject->getAuthor().c_str());
|
||||
|
||||
if (xaoObject->getGeometry() != NULL)
|
||||
{
|
||||
@ -107,7 +112,7 @@ xmlDocPtr XaoExporter::exportXMLDoc(Xao* xaoObject)
|
||||
}
|
||||
|
||||
void XaoExporter::exportGeometricElements(Geometry* xaoGeometry,
|
||||
xmlNodePtr topology, Dimension dim, const xmlChar* colTag, const xmlChar* eltTag)
|
||||
xmlNodePtr topology, XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag)
|
||||
{
|
||||
xmlNodePtr vertices = xmlNewChild(topology, 0, colTag, 0);
|
||||
xmlNewProp(vertices, C_ATTR_COUNT, BAD_CAST XaoUtils::intToString(xaoGeometry->countVertices()).c_str());
|
||||
@ -120,8 +125,8 @@ void XaoExporter::exportGeometricElements(Geometry* xaoGeometry,
|
||||
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());
|
||||
xmlNewProp(vertex, C_ATTR_ELT_REFERENCE, BAD_CAST elt.getReference());
|
||||
xmlNewProp(vertex, C_ATTR_ELT_NAME, BAD_CAST elt.getName().c_str());
|
||||
xmlNewProp(vertex, C_ATTR_ELT_REFERENCE, BAD_CAST elt.getReference().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,20 +134,20 @@ void XaoExporter::exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePt
|
||||
{
|
||||
// Geometric part
|
||||
xmlNodePtr geometry = xmlNewChild(xao, 0, C_TAG_GEOMETRY, 0);
|
||||
xmlNewProp(geometry, C_ATTR_GEOMETRY_NAME, BAD_CAST xaoGeometry->getName());
|
||||
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());
|
||||
xmlNewProp(shape, C_ATTR_SHAPE_FORMAT, BAD_CAST xaoGeometry->getFormat().c_str());
|
||||
const char* brep = xaoGeometry->getBREP();
|
||||
xmlNodePtr cdata = xmlNewCDataBlock(doc, BAD_CAST brep, strlen(brep));
|
||||
xmlAddChild(shape, cdata);
|
||||
|
||||
xmlNodePtr topology = xmlNewChild(geometry, 0, C_TAG_TOPOLOGY, 0);
|
||||
|
||||
exportGeometricElements(xaoGeometry, topology, VERTEX, C_TAG_VERTICES, C_TAG_VERTEX);
|
||||
exportGeometricElements(xaoGeometry, topology, EDGE, C_TAG_EDGES, C_TAG_EDGE);
|
||||
exportGeometricElements(xaoGeometry, topology, FACE, C_TAG_FACES, C_TAG_FACE);
|
||||
exportGeometricElements(xaoGeometry, topology, SOLID, C_TAG_SOLIDS, C_TAG_SOLID);
|
||||
exportGeometricElements(xaoGeometry, topology, XAO::VERTEX, C_TAG_VERTICES, C_TAG_VERTEX);
|
||||
exportGeometricElements(xaoGeometry, topology, XAO::EDGE, C_TAG_EDGES, C_TAG_EDGE);
|
||||
exportGeometricElements(xaoGeometry, topology, XAO::FACE, C_TAG_FACES, C_TAG_FACE);
|
||||
exportGeometricElements(xaoGeometry, topology, XAO::SOLID, C_TAG_SOLIDS, C_TAG_SOLID);
|
||||
}
|
||||
|
||||
void XaoExporter::exportGroups(Xao* xaoObject, xmlNodePtr xao)
|
||||
@ -156,8 +161,8 @@ void XaoExporter::exportGroups(Xao* xaoObject, xmlNodePtr xao)
|
||||
//Group* grp = (*it);
|
||||
Group* grp = xaoObject->getGroup(i);
|
||||
xmlNodePtr group = xmlNewChild(groups, 0, C_TAG_GROUP, 0);
|
||||
xmlNewProp(group, C_ATTR_GROUP_NAME, BAD_CAST grp->getName());
|
||||
xmlNewProp(group, C_ATTR_GROUP_DIM, BAD_CAST XaoUtils::dimensionToString(grp->getDimension()));
|
||||
xmlNewProp(group, C_ATTR_GROUP_NAME, BAD_CAST grp->getName().c_str());
|
||||
xmlNewProp(group, C_ATTR_GROUP_DIM, BAD_CAST XaoUtils::dimensionToString(grp->getDimension()).c_str());
|
||||
xmlNewProp(group, C_ATTR_COUNT, BAD_CAST XaoUtils::intToString(grp->getCount()).c_str());
|
||||
|
||||
for (int j = 0; j < grp->getCount(); j++)
|
||||
@ -178,8 +183,8 @@ void XaoExporter::exportFields(Xao* xaoObject, xmlNodePtr xao)
|
||||
Field* field = xaoObject->getField(i);
|
||||
xmlNodePtr nodeField = xmlNewChild(fields, 0, C_TAG_FIELD, 0);
|
||||
xmlNewProp(nodeField, C_ATTR_FIELD_NAME, BAD_CAST field->getName().c_str());
|
||||
xmlNewProp(nodeField, C_ATTR_FIELD_TYPE, BAD_CAST XaoUtils::fieldTypeToString(field->getType()));
|
||||
xmlNewProp(nodeField, C_ATTR_FIELD_DIMENSION, BAD_CAST XaoUtils::dimensionToString(field->getDimension()));
|
||||
xmlNewProp(nodeField, C_ATTR_FIELD_TYPE, BAD_CAST XaoUtils::fieldTypeToString(field->getType()).c_str());
|
||||
xmlNewProp(nodeField, C_ATTR_FIELD_DIMENSION, BAD_CAST XaoUtils::dimensionToString(field->getDimension()).c_str());
|
||||
|
||||
int nbComponents = field->countComponents();
|
||||
xmlNodePtr components = xmlNewChild(nodeField, 0, C_TAG_COMPONENTS, 0);
|
||||
@ -196,11 +201,11 @@ void XaoExporter::exportFields(Xao* xaoObject, xmlNodePtr xao)
|
||||
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).second;
|
||||
// exportStep(step, field, nodeSteps);
|
||||
// }
|
||||
for (stepIterator itStep = field->begin(); itStep != field->end(); itStep++)
|
||||
{
|
||||
Step* step = *itStep;
|
||||
exportStep(step, field, nodeSteps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,56 +218,25 @@ void XaoExporter::exportStep(Step* step, Field* field, xmlNodePtr nodeSteps)
|
||||
xmlNewProp(nodeStep, C_ATTR_STEP_STAMP, BAD_CAST XaoUtils::intToString(step->getStamp()).c_str());
|
||||
}
|
||||
|
||||
/*
|
||||
for(stepElementIterator itElt = step->begin(); itElt != step->end(); itElt++)
|
||||
for(int i = 0; i < step->countElements(); ++i)
|
||||
{
|
||||
StepElement* elt = (*itElt);
|
||||
xmlNodePtr nodeElt = xmlNewChild(nodeStep, 0, C_TAG_ELEMENT, 0);
|
||||
xmlNewProp(nodeElt, C_ATTR_ELEMENT_INDEX, BAD_CAST XaoUtils::intToString(elt->getElement()).c_str());
|
||||
xmlNewProp(nodeElt, C_ATTR_ELEMENT_INDEX, BAD_CAST XaoUtils::intToString(i).c_str());
|
||||
|
||||
for (int i = 0; i < elt->getNbComponents(); i++)
|
||||
for (int j = 0; j < step->countComponents(); ++j)
|
||||
{
|
||||
// TODO: do other type
|
||||
std::string content;
|
||||
switch (field->getType())
|
||||
{
|
||||
case FIELD_BOOLEAN:
|
||||
{
|
||||
BooleanStepElement* boolElt = (BooleanStepElement*)elt;
|
||||
content = (boolElt->getValue(i) ? "true" : "false");
|
||||
break;
|
||||
}
|
||||
case FIELD_STRING:
|
||||
{
|
||||
StringStepElement* strElt = (StringStepElement*)elt;
|
||||
content = strElt->getValue(i);
|
||||
break;
|
||||
}
|
||||
case FIELD_INTEGER:
|
||||
{
|
||||
IntegerStepElement* intElt = (IntegerStepElement*)elt;
|
||||
content = XaoUtils::intToString(intElt->getValue(i));
|
||||
break;
|
||||
}
|
||||
case FIELD_DOUBLE:
|
||||
{
|
||||
DoubleStepElement* dElt = (DoubleStepElement*)elt;
|
||||
content = XaoUtils::doubleToString(dElt->getValue(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string content = step->getStringValue(i, j);
|
||||
xmlNodePtr nodeValue= xmlNewTextChild(nodeElt, 0, C_TAG_VALUE, BAD_CAST content.c_str());
|
||||
xmlNewProp(nodeValue, C_ATTR_VALUE_COMPONENT, BAD_CAST XaoUtils::intToString(i).c_str());
|
||||
xmlNewProp(nodeValue, C_ATTR_VALUE_COMPONENT, BAD_CAST XaoUtils::intToString(j).c_str());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
bool XaoExporter::readFromFile(const char* fileName, Xao* xaoObject)
|
||||
const bool XaoExporter::readFromFile(const std::string& fileName, Xao* xaoObject)
|
||||
{
|
||||
// parse the file and get the DOM
|
||||
int options = XML_PARSE_HUGE || XML_PARSE_NOCDATA;
|
||||
xmlDocPtr doc = xmlReadFile(fileName, NULL, options);
|
||||
xmlDocPtr doc = xmlReadFile(fileName.c_str(), NULL, options);
|
||||
if (doc == NULL)
|
||||
{
|
||||
throw SALOME_Exception("Cannot read XAO file");
|
||||
@ -272,10 +246,10 @@ bool XaoExporter::readFromFile(const char* fileName, Xao* xaoObject)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool XaoExporter::setXML(const char* xml, Xao* xaoObject)
|
||||
const bool XaoExporter::setXML(const std::string& xml, Xao* xaoObject)
|
||||
{
|
||||
int options = XML_PARSE_HUGE || XML_PARSE_NOCDATA;
|
||||
xmlDocPtr doc = xmlReadDoc(BAD_CAST xml, "", NULL, options);
|
||||
xmlDocPtr doc = xmlReadDoc(BAD_CAST xml.c_str(), "", NULL, options);
|
||||
if (doc == NULL)
|
||||
{
|
||||
throw SALOME_Exception("Cannot read XAO stream");
|
||||
@ -514,18 +488,15 @@ void XaoExporter::parseGroupNode(xmlNodePtr groupNode, Xao* xaoObject)
|
||||
if (dimension == NULL)
|
||||
throw SALOME_Exception("Bad dimension for group");
|
||||
|
||||
Group* group = new Group();
|
||||
XAO::Dimension dim = XaoUtils::stringToDimension((char*)dimension);
|
||||
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);
|
||||
|
||||
group->setDimension(XaoUtils::stringToDimension((char*)dimension));
|
||||
xmlFree(dimension);
|
||||
|
||||
xaoObject->addGroup(group);
|
||||
|
||||
for (xmlNodePtr node = groupNode->children; node; node = node->next)
|
||||
{
|
||||
if (xmlStrcmp(node->name, C_TAG_ELEMENT) == 0)
|
||||
|
@ -13,17 +13,18 @@ namespace XAO
|
||||
{
|
||||
class XaoExporter
|
||||
{
|
||||
public:
|
||||
static bool saveToFile(Xao* xaoObject, const char* fileName);
|
||||
static const char* saveToXml(Xao* xaoObject);
|
||||
public:
|
||||
static const bool saveToFile(Xao* xaoObject, const std::string& fileName);
|
||||
static const std::string saveToXml(Xao* xaoObject);
|
||||
|
||||
static bool readFromFile(const char* fileName, Xao* xaoObject);
|
||||
static bool setXML(const char* xml, Xao* xaoObject);
|
||||
private:
|
||||
static const bool readFromFile(const std::string& fileName, Xao* xaoObject);
|
||||
static const bool setXML(const std::string& xml, Xao* xaoObject);
|
||||
|
||||
private:
|
||||
static xmlDocPtr exportXMLDoc(Xao* xaoObject);
|
||||
static void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao);
|
||||
static void exportGeometricElements(Geometry* xaoGeometry, xmlNodePtr topology,
|
||||
Dimension dim, const xmlChar* colTag, const xmlChar* eltTag);
|
||||
XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag);
|
||||
static void exportGroups(Xao* xaoObject, xmlNodePtr xao);
|
||||
static void exportFields(Xao* xaoObject, xmlNodePtr xao);
|
||||
static void exportStep(Step* step, Field* field, xmlNodePtr nodeSteps);
|
||||
|
@ -30,20 +30,15 @@
|
||||
|
||||
using namespace XAO;
|
||||
|
||||
/*const char* XaoUtils::intToString(const int value)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << value;
|
||||
return str.str().c_str();
|
||||
}*/
|
||||
const std::string XaoUtils::intToString(const int value)
|
||||
|
||||
const std::string XaoUtils::intToString(const int& value)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << value;
|
||||
return str.str();
|
||||
}
|
||||
|
||||
const int XaoUtils::stringToInt(const std::string value)
|
||||
const int XaoUtils::stringToInt(const std::string& value)
|
||||
{
|
||||
int res;
|
||||
std::istringstream convert(value);
|
||||
@ -52,14 +47,23 @@ const int XaoUtils::stringToInt(const std::string value)
|
||||
return res;
|
||||
}
|
||||
|
||||
const std::string XaoUtils::doubleToString(const double value)
|
||||
const std::string XaoUtils::doubleToString(const double& value)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << value;
|
||||
return str.str();
|
||||
}
|
||||
|
||||
const char* XaoUtils::dimensionToString(const XAO::Dimension dimension)
|
||||
const double XaoUtils::stringToDouble(const std::string& value)
|
||||
{
|
||||
double res;
|
||||
std::istringstream convert(value);
|
||||
if ( !(convert >> res) )
|
||||
res = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
const std::string XaoUtils::dimensionToString(const XAO::Dimension& dimension)
|
||||
{
|
||||
if (dimension == VERTEX)
|
||||
return "vertex";
|
||||
@ -74,22 +78,22 @@ const char* XaoUtils::dimensionToString(const XAO::Dimension dimension)
|
||||
throw SALOME_Exception("Bad dimension");
|
||||
}
|
||||
|
||||
const XAO::Dimension XaoUtils::stringToDimension(const char* dimension)
|
||||
const XAO::Dimension XaoUtils::stringToDimension(const std::string& dimension)
|
||||
{
|
||||
if (strcmp(dimension, "vertex") == 0)
|
||||
if (dimension == "vertex")
|
||||
return VERTEX;
|
||||
if (strcmp(dimension, "edge") == 0)
|
||||
if (dimension == "edge")
|
||||
return EDGE;
|
||||
if (strcmp(dimension, "face") == 0)
|
||||
if (dimension == "face")
|
||||
return FACE;
|
||||
if (strcmp(dimension, "solid") == 0)
|
||||
if (dimension == "solid")
|
||||
return SOLID;
|
||||
if (strcmp(dimension, "whole") == 0)
|
||||
if (dimension == "whole")
|
||||
return WHOLE;
|
||||
throw SALOME_Exception("Bad dimension");
|
||||
}
|
||||
|
||||
const char* XaoUtils::fieldTypeToString(const XAO::Type type)
|
||||
const std::string XaoUtils::fieldTypeToString(const XAO::Type& type)
|
||||
{
|
||||
if (type == BOOLEAN)
|
||||
return "boolean";
|
||||
@ -102,15 +106,15 @@ const char* XaoUtils::fieldTypeToString(const XAO::Type type)
|
||||
throw SALOME_Exception("Bad type");
|
||||
}
|
||||
|
||||
const XAO::Type XaoUtils::stringToFieldType(const char* type)
|
||||
const XAO::Type XaoUtils::stringToFieldType(const std::string& type)
|
||||
{
|
||||
if (strcmp(type, "boolean") == 0)
|
||||
if (type == "boolean")
|
||||
return BOOLEAN;
|
||||
if (strcmp(type, "integer") == 0)
|
||||
if (type == "integer")
|
||||
return INTEGER;
|
||||
if (strcmp(type, "double") == 0)
|
||||
if (type == "double")
|
||||
return DOUBLE;
|
||||
if (strcmp(type, "string") == 0)
|
||||
if (type == "string")
|
||||
return STRING;
|
||||
throw SALOME_Exception("Bad type");
|
||||
}
|
||||
|
@ -39,10 +39,11 @@ namespace XAO
|
||||
* \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);
|
||||
static const std::string intToString(const int& value);
|
||||
static const int stringToInt(const std::string& value);
|
||||
|
||||
static const std::string doubleToString(const double value);
|
||||
static const std::string doubleToString(const double& value);
|
||||
static const double stringToDouble(const std::string& value);
|
||||
|
||||
/**
|
||||
* Converts a Dimension to string.
|
||||
@ -50,7 +51,7 @@ namespace XAO
|
||||
* \return the dimension as a string.
|
||||
* \throw SALOME_Exception
|
||||
*/
|
||||
static const char* dimensionToString(const XAO::Dimension dimension);
|
||||
static const std::string dimensionToString(const XAO::Dimension& dimension);
|
||||
|
||||
/**
|
||||
* Converts a string into a Dimension.
|
||||
@ -58,7 +59,7 @@ namespace XAO
|
||||
* \return the converted Dimension.
|
||||
* \throw SALOME_Exception
|
||||
*/
|
||||
static const XAO::Dimension stringToDimension(const char* dimension);
|
||||
static const XAO::Dimension stringToDimension(const std::string& dimension);
|
||||
|
||||
/**
|
||||
* Converts a Type to string.
|
||||
@ -66,7 +67,7 @@ namespace XAO
|
||||
* \return the Type as a string.
|
||||
* \throw SALOME_Exception
|
||||
*/
|
||||
static const char* fieldTypeToString(const XAO::Type type);
|
||||
static const std::string fieldTypeToString(const XAO::Type& type);
|
||||
|
||||
/**
|
||||
* Converts a string into a Type.
|
||||
@ -74,7 +75,7 @@ namespace XAO
|
||||
* \return the converted Type.
|
||||
* \throw SALOME_Exception
|
||||
*/
|
||||
static const XAO::Type stringToFieldType(const char* type);
|
||||
static const XAO::Type stringToFieldType(const std::string& type);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ void ImportExportTest::testExportGeometry()
|
||||
geom->setName("mygeom");
|
||||
xao.setGeometry(geom);
|
||||
|
||||
// add elements
|
||||
geom->setCountVertices(4);
|
||||
geom->setVertex(0, "v1", "1");
|
||||
geom->setVertex(1, "", "2");
|
||||
@ -79,24 +80,20 @@ void ImportExportTest::testExportGeometry()
|
||||
geom->setCountSolids(1);
|
||||
geom->setSolid(0, "s1", "10");
|
||||
|
||||
Group* group = new Group();
|
||||
xao.addGroup(group);
|
||||
// groups
|
||||
Group* group = xao.addGroup(XAO::SOLID);
|
||||
group->setName("boite1");
|
||||
group->setDimension(XAO::SOLID);
|
||||
group->addElement(1);
|
||||
group->addElement(0);
|
||||
|
||||
group = new Group();
|
||||
xao.addGroup(group);
|
||||
group = xao.addGroup(XAO::FACE);
|
||||
group->setName("faces");
|
||||
group->setDimension(XAO::FACE);
|
||||
group->addElement(5);
|
||||
group->addElement(8);
|
||||
group->addElement(9);
|
||||
group->addElement(0);
|
||||
group->addElement(1);
|
||||
|
||||
bool res = xao.exportXAO("mygeom.xao");
|
||||
CPPUNIT_ASSERT(res);
|
||||
|
||||
const char* xml = xao.getXML();
|
||||
std::string xml = xao.getXML();
|
||||
//CPPUNIT_ASSERT(strlen(xml) == 1007);
|
||||
}
|
||||
|
||||
@ -121,54 +118,61 @@ void ImportExportTest::testImportXao()
|
||||
|
||||
void ImportExportTest::checkImport(Xao& xao)
|
||||
{
|
||||
CPPUNIT_ASSERT(strcmp(xao.getAuthor(), "me") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(xao.getVersion(), "1.0") == 0);
|
||||
// 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");
|
||||
|
||||
Geometry* geom = xao.getGeometry();
|
||||
CPPUNIT_ASSERT(geom != NULL);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getName(), "mygeom") == 0);
|
||||
CPPUNIT_ASSERT(geom->getName() == "mygeom");
|
||||
|
||||
CPPUNIT_ASSERT(geom->countVertices() == 4);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getVertexName(0), "v1") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getVertexReference(0), "1") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getVertexName(1), "") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getVertexReference(1), "2") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getVertexName(2), "v3") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getVertexReference(2), "3") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getVertexName(3), "") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getVertexReference(3), "4") == 0);
|
||||
CPPUNIT_ASSERT(geom->getVertexName(0) == "v1");
|
||||
CPPUNIT_ASSERT(geom->getVertexReference(0) == "1");
|
||||
CPPUNIT_ASSERT(geom->getVertexName(1) == "");
|
||||
CPPUNIT_ASSERT(geom->getVertexReference(1) == "2");
|
||||
CPPUNIT_ASSERT(geom->getVertexName(2) == "v3");
|
||||
CPPUNIT_ASSERT(geom->getVertexReference(2) == "3");
|
||||
CPPUNIT_ASSERT(geom->getVertexName(3) == "");
|
||||
CPPUNIT_ASSERT(geom->getVertexReference(3) == "4");
|
||||
|
||||
CPPUNIT_ASSERT(geom->countEdges() == 3);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getEdgeName(0), "e1") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getEdgeReference(0), "5") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getEdgeName(1), "") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getEdgeReference(1), "6") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getEdgeName(2), "e3") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getEdgeReference(2), "7") == 0);
|
||||
CPPUNIT_ASSERT(geom->getEdgeName(0) == "e1");
|
||||
CPPUNIT_ASSERT(geom->getEdgeReference(0) == "5");
|
||||
CPPUNIT_ASSERT(geom->getEdgeName(1) == "");
|
||||
CPPUNIT_ASSERT(geom->getEdgeReference(1) == "6");
|
||||
CPPUNIT_ASSERT(geom->getEdgeName(2) == "e3");
|
||||
CPPUNIT_ASSERT(geom->getEdgeReference(2) == "7");
|
||||
|
||||
CPPUNIT_ASSERT(geom->countFaces() == 2);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getFaceName(0), "f1") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getFaceReference(0), "8") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getFaceName(1), "") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getFaceReference(1), "9") == 0);
|
||||
CPPUNIT_ASSERT(geom->getFaceName(0) == "f1");
|
||||
CPPUNIT_ASSERT(geom->getFaceReference(0) == "8");
|
||||
CPPUNIT_ASSERT(geom->getFaceName(1) == "");
|
||||
CPPUNIT_ASSERT(geom->getFaceReference(1) == "9");
|
||||
|
||||
CPPUNIT_ASSERT(geom->countSolids() == 1);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getSolidName(0), "s1") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(geom->getSolidReference(0), "10") == 0);
|
||||
CPPUNIT_ASSERT(geom->getSolidName(0) == "s1");
|
||||
CPPUNIT_ASSERT(geom->getSolidReference(0) == "10");
|
||||
|
||||
CPPUNIT_ASSERT(xao.countGroups() == 2);
|
||||
Group* group = xao.getGroup(0);
|
||||
CPPUNIT_ASSERT(group->getCount() == 1);
|
||||
CPPUNIT_ASSERT(strcmp(group->getName(), "boite_1") == 0);
|
||||
CPPUNIT_ASSERT(group->getName() == "boite_1");
|
||||
CPPUNIT_ASSERT(group->getDimension() == XAO::SOLID);
|
||||
CPPUNIT_ASSERT(group->getElement(0) == 1);
|
||||
CPPUNIT_ASSERT(group->getElement(0) == 0);
|
||||
group = xao.getGroup(1);
|
||||
CPPUNIT_ASSERT(group->getCount() == 3);
|
||||
CPPUNIT_ASSERT(strcmp(group->getName(), "") == 0);
|
||||
CPPUNIT_ASSERT(group->getCount() == 2);
|
||||
CPPUNIT_ASSERT(group->getName() == "");
|
||||
CPPUNIT_ASSERT(group->getDimension() == XAO::FACE);
|
||||
CPPUNIT_ASSERT(group->getElement(0) == 5);
|
||||
CPPUNIT_ASSERT(group->getElement(1) == 8);
|
||||
CPPUNIT_ASSERT(group->getElement(2) == 9);
|
||||
CPPUNIT_ASSERT(group->getElement(0) == 0);
|
||||
CPPUNIT_ASSERT(group->getElement(1) == 1);
|
||||
}
|
||||
|
||||
void ImportExportTest::testImportXaoFromText()
|
||||
|
@ -310,12 +310,11 @@ So
|
||||
</geometry>
|
||||
<groups>
|
||||
<group name="boite_1" dimension="solid" count="1">
|
||||
<element index="1" />
|
||||
<element index="0" />
|
||||
</group>
|
||||
<group name="" dimension="face" count="3">
|
||||
<element index="5" />
|
||||
<element index="8" />
|
||||
<element index="9" />
|
||||
<element index="0" />
|
||||
<element index="1" />
|
||||
</group>
|
||||
</groups>
|
||||
</XAO>
|
||||
|
Loading…
Reference in New Issue
Block a user