BooleanStep* addStep(const int& step);
BooleanStep* addStep(const int& step, const int& stamp);
BooleanStep* getStep(const int& index);
-
-// private:
-// std::vector<BooleanStep*> m_steps;
};
}
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;
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)
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");
+}
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;
DoubleStep* addStep(const int& step);
DoubleStep* addStep(const int& step, const int& stamp);
DoubleStep* getStep(const int& index);
-
-// private:
-// std::vector<DoubleStep*> m_steps;
};
}
#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;
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)
m_values[element][component] = value;
}
+
+void DoubleStep::setStringValue(const int& element, const int& component, const std::string& value)
+{
+ setValue(element, component, XaoUtils::stringToDouble(value));
+}
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;
namespace XAO
{
+ typedef std::vector<Step*>::iterator stepIterator;
+
/**
* @class Field
* A geometrical Field.
*/
bool removeStep(Step* step);
+ stepIterator begin() { return m_steps.begin(); }
+ stepIterator end() { return m_steps.end(); }
+
private:
void checkComponent(const int& component);
//
// Author : Frederic Pons (OpenCascade)
-#include <cstring>
#include <Utils_SALOME_Exception.hxx>
#include "GeometricElement.hxx"
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;
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();
}
}
-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");
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");
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)
{
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)
{
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");
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");
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;
}
* \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.
*/
* 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;
}
* 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;
}
* Constructor with size.
* \param nb the size to set.
*/
- GeometricElementList(const int nb);
+ GeometricElementList(const int& nb);
/**
* Destructor.
*/
* 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.
* \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.
* \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.
}
}
-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);
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);
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();
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();
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;
}
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(); }
-
- 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); }
-
- 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); }
-
- 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); }
-
- 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 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);
-
- 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); }
-
- 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);
-
- GeometricElementList::iterator begin(const Dimension dim);
- GeometricElementList::iterator end(const Dimension dim);
+ 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 setVertex(const int& index, const std::string& name, const std::string& reference) { m_vertices.setElement(index, name, reference); }
+ void setEdge(const int& index, const std::string& name, const std::string& reference) { m_edges.setElement(index, name, reference); }
+ void setFace(const int& index, const std::string& name, const std::string& reference) { m_faces.setElement(index, name, reference); }
+ void setSolid(const int& index, const std::string& name, const std::string& reference) { m_solids.setElement(index, name, reference); }
+
+ const std::string getVertexName(const int& index) { return m_vertices.getName(index); }
+ const std::string getEdgeName(const int& index) { return m_edges.getName(index); }
+ const std::string getFaceName(const int& index) { return m_faces.getName(index); }
+ const std::string getSolidName(const int& index) { return m_solids.getName(index); }
+
+ 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); }
+
+ 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 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 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 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 XAO::Dimension& dim);
+ GeometricElementList::iterator end(const XAO::Dimension& dim);
private:
void initListIds(const Standard_Integer shapeType);
//
// 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;
- m_count = 0;
+ initGroup("", dim, nbElements);
}
-Group::~Group()
+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;
}
-const Dimension Group::getDimension()
+Group::~Group()
{
- return m_dimension;
}
-void Group::setDimension(const Dimension dimension)
+void Group::checkElement(const int& element)
{
- m_dimension = dimension;
+ if (element >= m_nbElements)
+ {
+ std::ostringstream str;
+ str << "IndexOutOfRange element: " << element << " >= " << m_nbElements;
+ throw SALOME_Exception(str.str().c_str()); // TODO
+ }
}
/**
* Default constructor.
*/
- Group();
+ Group(const XAO::Dimension& dim, const int& nbElements);
+ Group(const std::string& name, const XAO::Dimension& dim, const int& nbelements);
/**
* Destructor.
* 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;
}
* 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.
* 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);
}
* \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. */
IntegerStep* addStep(const int& step);
IntegerStep* addStep(const int& step, const int& stamp);
IntegerStep* getStep(const int& index);
-
-// private:
-// std::vector<IntegerStep*> m_steps;
};
}
#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;
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)
m_values[element][component] = value;
}
+
+void IntegerStep::setStringValue(const int& element, const int& component, const std::string& value)
+{
+ setValue(element, component, XaoUtils::stringToInt(value));
+}
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;
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);
StringStep* addStep(const int& step);
StringStep* addStep(const int& step, const int& stamp);
StringStep* getStep(const int& index);
-
-// private:
-// std::vector<StringStep*> m_steps;
};
}
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;
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)
m_values[element][component] = value;
}
+
+void StringStep::setStringValue(const int& element, const int& component, const std::string& value)
+{
+ setValue(element, component, value);
+}
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;
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;
}
}
-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)
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)
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)
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)
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);
return XaoExporter::saveToFile(this, fileName);
}
-const char* Xao::getXML()
+const std::string Xao::getXML()
{
// xmlDocPtr doc = exportXMLDoc();
//
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
+}
* \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.
*/
* 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;
}
* 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;
}
* 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.
* 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 type the type of the field.
+ * \param dim the dimension of the field.
+ * \param nbComponents the number of components in the field.
+ * \return the created field.
+ */
+ Field* addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents);
/**
* Adds a field.
- * \param field the field to add.
+ * \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.
*/
- void addField(Field* 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.
* \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. */
#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
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);
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)
{
}
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());
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());
}
}
{
// 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)
//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++)
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);
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);
+ }
}
}
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");
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");
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)
{
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);
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);
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";
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";
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");
}
* \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.
* \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.
* \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.
* \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.
* \return the converted Type.
* \throw SALOME_Exception
*/
- static const XAO::Type stringToFieldType(const char* type);
+ static const XAO::Type stringToFieldType(const std::string& type);
};
}
geom->setName("mygeom");
xao.setGeometry(geom);
+ // add elements
geom->setCountVertices(4);
geom->setVertex(0, "v1", "1");
geom->setVertex(1, "", "2");
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);
}
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()
</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>