mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-03-25 05:27:55 +05:00
add addXXXField and getXXXField on Xao to add and get field of givent type because of issue with SWIG
This commit is contained in:
parent
7fb55ab92e
commit
811909e23f
@ -25,6 +25,9 @@
|
|||||||
#include "XAO_Group.hxx"
|
#include "XAO_Group.hxx"
|
||||||
#include "XAO_Field.hxx"
|
#include "XAO_Field.hxx"
|
||||||
#include "XAO_IntegerField.hxx"
|
#include "XAO_IntegerField.hxx"
|
||||||
|
#include "XAO_BooleanField.hxx"
|
||||||
|
#include "XAO_DoubleField.hxx"
|
||||||
|
#include "XAO_StringField.hxx"
|
||||||
#include "XAO_XaoExporter.hxx"
|
#include "XAO_XaoExporter.hxx"
|
||||||
|
|
||||||
using namespace XAO;
|
using namespace XAO;
|
||||||
@ -115,6 +118,12 @@ const int Xao::countFields() const
|
|||||||
return m_fields.size();
|
return m_fields.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const XAO::Type Xao::getFieldType(const int& index)
|
||||||
|
throw (XAO_Exception)
|
||||||
|
{
|
||||||
|
return getField(index)->getType();
|
||||||
|
}
|
||||||
|
|
||||||
Field* Xao::getField(const int& index)
|
Field* Xao::getField(const int& index)
|
||||||
throw (XAO_Exception)
|
throw (XAO_Exception)
|
||||||
{
|
{
|
||||||
@ -127,7 +136,43 @@ throw (XAO_Exception)
|
|||||||
return (*it);
|
return (*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
throw XAO_Exception("Field not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
BooleanField* Xao::getBooleanField(const int& index)
|
||||||
|
throw (XAO_Exception)
|
||||||
|
{
|
||||||
|
Field* field = getField(index);
|
||||||
|
if (field->getType() != XAO::BOOLEAN)
|
||||||
|
throw XAO_Exception(MsgBuilder() << "Field " << index << " is not a boolean field.");
|
||||||
|
return (BooleanField*)field;
|
||||||
|
}
|
||||||
|
|
||||||
|
DoubleField* Xao::getDoubleField(const int& index)
|
||||||
|
throw (XAO_Exception)
|
||||||
|
{
|
||||||
|
Field* field = getField(index);
|
||||||
|
if (field->getType() != XAO::DOUBLE)
|
||||||
|
throw XAO_Exception(MsgBuilder() << "Field " << index << " is not a double field.");
|
||||||
|
return (DoubleField*)field;
|
||||||
|
}
|
||||||
|
|
||||||
|
IntegerField* Xao::getIntegerField(const int& index)
|
||||||
|
throw (XAO_Exception)
|
||||||
|
{
|
||||||
|
Field* field = getField(index);
|
||||||
|
if (field->getType() != XAO::INTEGER)
|
||||||
|
throw XAO_Exception(MsgBuilder() << "Field " << index << " is not an integer field.");
|
||||||
|
return (IntegerField*)field;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringField* Xao::getStringField(const int& index)
|
||||||
|
throw (XAO_Exception)
|
||||||
|
{
|
||||||
|
Field* field = getField(index);
|
||||||
|
if (field->getType() != XAO::STRING)
|
||||||
|
throw XAO_Exception(MsgBuilder() << "Field " << index << " is not a string field.");
|
||||||
|
return (StringField*)field;
|
||||||
}
|
}
|
||||||
|
|
||||||
Field* Xao::addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents, const std::string& name)
|
Field* Xao::addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents, const std::string& name)
|
||||||
@ -140,6 +185,45 @@ throw (XAO_Exception)
|
|||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntegerField* Xao::addIntegerField(const XAO::Dimension& dim, const int& nbComponents, const std::string& name)
|
||||||
|
throw (XAO_Exception)
|
||||||
|
{
|
||||||
|
checkGeometry();
|
||||||
|
int nbElts = m_geometry->countElements(dim);
|
||||||
|
IntegerField* field = new IntegerField(dim, nbElts, nbComponents, name);
|
||||||
|
m_fields.push_back(field);
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
BooleanField* Xao::addBooleanField(const XAO::Dimension& dim, const int& nbComponents, const std::string& name)
|
||||||
|
throw (XAO_Exception)
|
||||||
|
{
|
||||||
|
checkGeometry();
|
||||||
|
int nbElts = m_geometry->countElements(dim);
|
||||||
|
BooleanField* field = new BooleanField(dim, nbElts, nbComponents, name);
|
||||||
|
m_fields.push_back(field);
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
DoubleField* Xao::addDoubleField(const XAO::Dimension& dim, const int& nbComponents, const std::string& name)
|
||||||
|
throw (XAO_Exception)
|
||||||
|
{
|
||||||
|
checkGeometry();
|
||||||
|
int nbElts = m_geometry->countElements(dim);
|
||||||
|
DoubleField* field = new DoubleField(dim, nbElts, nbComponents, name);
|
||||||
|
m_fields.push_back(field);
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
StringField* Xao::addStringField(const XAO::Dimension& dim, const int& nbComponents, const std::string& name)
|
||||||
|
throw (XAO_Exception)
|
||||||
|
{
|
||||||
|
checkGeometry();
|
||||||
|
int nbElts = m_geometry->countElements(dim);
|
||||||
|
StringField* field = new StringField(dim, nbElts, nbComponents, name);
|
||||||
|
m_fields.push_back(field);
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Xao::removeField(Field* field)
|
bool Xao::removeField(Field* field)
|
||||||
{
|
{
|
||||||
int nb = countFields();
|
int nb = countFields();
|
||||||
|
@ -31,6 +31,10 @@ namespace XAO
|
|||||||
{
|
{
|
||||||
class Group;
|
class Group;
|
||||||
class Field;
|
class Field;
|
||||||
|
class IntegerField;
|
||||||
|
class DoubleField;
|
||||||
|
class BooleanField;
|
||||||
|
class StringField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Xao
|
* @class Xao
|
||||||
@ -150,6 +154,14 @@ namespace XAO
|
|||||||
* \return the number of fields.
|
* \return the number of fields.
|
||||||
*/
|
*/
|
||||||
const int countFields() const;
|
const int countFields() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type of a field.
|
||||||
|
* \param index the index of the wanted field.
|
||||||
|
* \return the type of the field.
|
||||||
|
*/
|
||||||
|
const XAO::Type getFieldType(const int& index) throw (XAO_Exception);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a field.
|
* Gets a field.
|
||||||
* \param index the index of the wanted field.
|
* \param index the index of the wanted field.
|
||||||
@ -157,6 +169,11 @@ namespace XAO
|
|||||||
*/
|
*/
|
||||||
Field* getField(const int& index) throw (XAO_Exception);
|
Field* getField(const int& index) throw (XAO_Exception);
|
||||||
|
|
||||||
|
BooleanField* getBooleanField(const int& index) throw (XAO_Exception);
|
||||||
|
DoubleField* getDoubleField(const int& index) throw (XAO_Exception);
|
||||||
|
IntegerField* getIntegerField(const int& index) throw (XAO_Exception);
|
||||||
|
StringField* getStringField(const int& index) throw (XAO_Exception);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a field.
|
* Adds a field.
|
||||||
* \param type the type of the field.
|
* \param type the type of the field.
|
||||||
@ -169,6 +186,15 @@ namespace XAO
|
|||||||
const std::string& name = std::string(""))
|
const std::string& name = std::string(""))
|
||||||
throw (XAO_Exception);
|
throw (XAO_Exception);
|
||||||
|
|
||||||
|
BooleanField* addBooleanField(const XAO::Dimension& dim, const int& nbComponents,
|
||||||
|
const std::string& name = std::string("")) throw (XAO_Exception);
|
||||||
|
IntegerField* addIntegerField(const XAO::Dimension& dim, const int& nbComponents,
|
||||||
|
const std::string& name = std::string("")) throw (XAO_Exception);
|
||||||
|
DoubleField* addDoubleField(const XAO::Dimension& dim, const int& nbComponents,
|
||||||
|
const std::string& name = std::string("")) throw (XAO_Exception);
|
||||||
|
StringField* addStringField(const XAO::Dimension& dim, const int& nbComponents,
|
||||||
|
const std::string& name = std::string("")) throw (XAO_Exception);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a field.
|
* Removes a field.
|
||||||
* \param field the field to remove.
|
* \param field the field to remove.
|
||||||
|
@ -75,3 +75,29 @@ void XaoTest::testFields()
|
|||||||
CPPUNIT_ASSERT_EQUAL(false, obj.removeField(ff));
|
CPPUNIT_ASSERT_EQUAL(false, obj.removeField(ff));
|
||||||
delete ff;
|
delete ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XaoTest::testFieldsTypes()
|
||||||
|
{
|
||||||
|
Xao obj;
|
||||||
|
BrepGeometry* geom = new BrepGeometry("test");
|
||||||
|
obj.setGeometry(geom);
|
||||||
|
|
||||||
|
IntegerField* fi = obj.addIntegerField(XAO::FACE, 3);
|
||||||
|
BooleanField* fb = obj.addBooleanField(XAO::FACE, 3);
|
||||||
|
DoubleField* fd = obj.addDoubleField(XAO::FACE, 3);
|
||||||
|
StringField* fs = obj.addStringField(XAO::FACE, 3);
|
||||||
|
|
||||||
|
IntegerField* gfi = obj.getIntegerField(0);
|
||||||
|
CPPUNIT_ASSERT(gfi == fi);
|
||||||
|
BooleanField* gfb = obj.getBooleanField(1);
|
||||||
|
CPPUNIT_ASSERT(gfb == fb);
|
||||||
|
DoubleField* gfd = obj.getDoubleField(2);
|
||||||
|
CPPUNIT_ASSERT(gfd == fd);
|
||||||
|
StringField* gfs = obj.getStringField(3);
|
||||||
|
CPPUNIT_ASSERT(gfs == fs);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_THROW(obj.getIntegerField(1), XAO_Exception);
|
||||||
|
CPPUNIT_ASSERT_THROW(obj.getBooleanField(0), XAO_Exception);
|
||||||
|
CPPUNIT_ASSERT_THROW(obj.getDoubleField(0), XAO_Exception);
|
||||||
|
CPPUNIT_ASSERT_THROW(obj.getStringField(0), XAO_Exception);
|
||||||
|
}
|
||||||
|
@ -10,6 +10,7 @@ namespace XAO
|
|||||||
CPPUNIT_TEST_SUITE(XaoTest);
|
CPPUNIT_TEST_SUITE(XaoTest);
|
||||||
CPPUNIT_TEST(testGroups);
|
CPPUNIT_TEST(testGroups);
|
||||||
CPPUNIT_TEST(testFields);
|
CPPUNIT_TEST(testFields);
|
||||||
|
CPPUNIT_TEST(testFieldsTypes);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -19,6 +20,7 @@ namespace XAO
|
|||||||
|
|
||||||
void testGroups();
|
void testGroups();
|
||||||
void testFields();
|
void testFields();
|
||||||
|
void testFieldsTypes();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user