Add support for aggregate of bool

This commit is contained in:
aothms
2016-02-24 11:25:45 +01:00
parent 766d45e0cb
commit c1c738390f
13 changed files with 125 additions and 15 deletions
+2 -2
View File
@@ -37,8 +37,8 @@ class Mapping:
supported_argument_types = set([
'INT', 'BOOL', 'DOUBLE', 'STRING', 'BINARY', 'ENUMERATION', 'ENTITY_INSTANCE',
'AGGREGATE_OF_INT', 'AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_STRING', 'AGGREGATE_OF_BINARY', 'AGGREGATE_OF_ENTITY_INSTANCE',
'AGGREGATE_OF_AGGREGATE_OF_INT', 'AGGREGATE_OF_AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE',
'AGGREGATE_OF_INT', 'AGGREGATE_OF_BOOL', 'AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_STRING', 'AGGREGATE_OF_BINARY', 'AGGREGATE_OF_ENTITY_INSTANCE',
'AGGREGATE_OF_AGGREGATE_OF_INT', 'AGGREGATE_OF_AGGREGATE_OF_BOOL', 'AGGREGATE_OF_AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE',
])
def __init__(self, schema):
+13
View File
@@ -25,6 +25,7 @@
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/IfcWrite.h"
#include "../ifcparse/IfcFile.h"
#ifdef USE_IFC4
#include "../ifcparse/Ifc4-latebound.h"
@@ -163,6 +164,12 @@ void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfInt(unsigned int i, c
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF INT");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfBool(unsigned int i, const std::vector<bool>& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_BOOL) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF BOOL");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfDouble(unsigned int i, const std::vector<double>& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_DOUBLE) {
@@ -204,6 +211,12 @@ void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfAggregateOfInt(unsign
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF AGGREGATE OF INT");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfAggregateOfBool(unsigned int i, const std::vector< std::vector<bool> >& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF AGGREGATE OF BOOL");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfAggregateOfDouble(unsigned int i, const std::vector< std::vector<double> >& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE) {
+2
View File
@@ -68,11 +68,13 @@ namespace IfcParse {
void setArgumentAsEntityInstance(unsigned int i, IfcLateBoundEntity* v);
void setArgumentAsAggregateOfInt(unsigned int i, const std::vector<int>& v);
void setArgumentAsAggregateOfBool(unsigned int i, const std::vector<bool>& v);
void setArgumentAsAggregateOfDouble(unsigned int i, const std::vector<double>& v);
void setArgumentAsAggregateOfString(unsigned int i, const std::vector<std::string>& v);
void setArgumentAsAggregateOfEntityInstance(unsigned int i, IfcEntityList::ptr v);
void setArgumentAsAggregateOfAggregateOfInt(unsigned int i, const std::vector< std::vector<int> >& v);
void setArgumentAsAggregateOfAggregateOfBool(unsigned int i, const std::vector< std::vector<bool> >& v);
void setArgumentAsAggregateOfAggregateOfDouble(unsigned int i, const std::vector< std::vector<double> >& v);
void setArgumentAsAggregateOfAggregateOfEntityInstance(unsigned int i, IfcEntityListList::ptr v);
+22 -6
View File
@@ -551,6 +551,8 @@ IfcUtil::ArgumentType ArgumentList::type() const {
const IfcUtil::ArgumentType elem_type = list[0]->type();
if (elem_type == IfcUtil::Argument_INT) {
return IfcUtil::Argument_AGGREGATE_OF_INT;
} else if (elem_type == IfcUtil::Argument_BOOL) {
return IfcUtil::Argument_AGGREGATE_OF_BOOL;
} else if (elem_type == IfcUtil::Argument_DOUBLE) {
return IfcUtil::Argument_AGGREGATE_OF_DOUBLE;
} else if (elem_type == IfcUtil::Argument_STRING) {
@@ -561,6 +563,8 @@ IfcUtil::ArgumentType ArgumentList::type() const {
return IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_INT) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_BOOL) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_DOUBLE) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
@@ -605,14 +609,18 @@ ArgumentList::operator double() const { throw IfcException("Argument is not a nu
ArgumentList::operator std::string() const { throw IfcException("Argument is not a string"); }
ArgumentList::operator boost::dynamic_bitset<>() const { throw IfcException("Argument is not a binary"); }
ArgumentList::operator std::vector<double>() const {
return read_aggregate_as_vector<double>(list);
}
ArgumentList::operator std::vector<int>() const {
return read_aggregate_as_vector<int>(list);
}
ArgumentList::operator std::vector<bool>() const {
return read_aggregate_as_vector<bool>(list);
}
ArgumentList::operator std::vector<double>() const {
return read_aggregate_as_vector<double>(list);
}
ArgumentList::operator std::vector<std::string>() const {
return read_aggregate_as_vector<std::string>(list);
}
@@ -638,6 +646,10 @@ ArgumentList::operator std::vector< std::vector<int> >() const {
return read_aggregate_of_aggregate_as_vector2<int>(list);
}
ArgumentList::operator std::vector< std::vector<bool> >() const {
return read_aggregate_of_aggregate_as_vector2<bool>(list);
}
ArgumentList::operator std::vector< std::vector<double> >() const {
return read_aggregate_of_aggregate_as_vector2<double>(list);
}
@@ -730,13 +742,15 @@ TokenArgument::operator bool() const { return TokenFunc::asBool(token); }
TokenArgument::operator double() const { return TokenFunc::asFloat(token); }
TokenArgument::operator std::string() const { return TokenFunc::asString(token); }
TokenArgument::operator boost::dynamic_bitset<>() const { return TokenFunc::asBinary(token); }
TokenArgument::operator std::vector<double>() const { throw IfcException("Argument is not a list of floats"); }
TokenArgument::operator std::vector<int>() const { throw IfcException("Argument is not a list of ints"); }
TokenArgument::operator std::vector<bool>() const { throw IfcException("Argument is not a list of bools"); }
TokenArgument::operator std::vector<double>() const { throw IfcException("Argument is not a list of floats"); }
TokenArgument::operator std::vector<std::string>() const { throw IfcException("Argument is not a list of strings"); }
TokenArgument::operator std::vector<boost::dynamic_bitset<> >() const { throw IfcException("Argument is not a list of binaries"); }
TokenArgument::operator IfcUtil::IfcBaseClass*() const { return token.first->file->entityById(TokenFunc::asInt(token)); }
TokenArgument::operator IfcEntityList::ptr() const { throw IfcException("Argument is not a list of entity instances"); }
TokenArgument::operator std::vector< std::vector<int> >() const { throw IfcException("Argument is not a list of list of ints"); }
TokenArgument::operator std::vector< std::vector<bool> >() const { throw IfcException("Argument is not a list of list of bools"); }
TokenArgument::operator std::vector< std::vector<double> >() const { throw IfcException("Argument is not a list of list of floats"); }
TokenArgument::operator IfcEntityListList::ptr() const { throw IfcException("Argument is not a list of list of entity instances"); }
unsigned int TokenArgument::size() const { return 1; }
@@ -762,13 +776,15 @@ EntityArgument::operator bool() const { throw IfcException("Argument is not a bo
EntityArgument::operator double() const { throw IfcException("Argument is not a number"); }
EntityArgument::operator boost::dynamic_bitset<>() const { throw IfcException("Argument is not a binary"); }
EntityArgument::operator std::string() const { throw IfcException("Argument is not a string"); }
EntityArgument::operator std::vector<double>() const { throw IfcException("Argument is not a list of floats"); }
EntityArgument::operator std::vector<int>() const { throw IfcException("Argument is not a list of ints"); }
EntityArgument::operator std::vector<bool>() const { throw IfcException("Argument is not a list of bools"); }
EntityArgument::operator std::vector<double>() const { throw IfcException("Argument is not a list of floats"); }
EntityArgument::operator std::vector<std::string>() const { throw IfcException("Argument is not a list of strings"); }
EntityArgument::operator std::vector<boost::dynamic_bitset<> >() const { throw IfcException("Argument is not a list of binaries"); }
EntityArgument::operator IfcUtil::IfcBaseClass*() const { return entity; }
EntityArgument::operator IfcEntityList::ptr() const { throw IfcException("Argument is not a list of entity instances"); }
EntityArgument::operator std::vector< std::vector<int> >() const { throw IfcException("Argument is not a list of list of ints"); }
EntityArgument::operator std::vector< std::vector<bool> >() const { throw IfcException("Argument is not a list of list of bools"); }
EntityArgument::operator std::vector< std::vector<double> >() const { throw IfcException("Argument is not a list of list of floats"); }
EntityArgument::operator IfcEntityListList::ptr() const { throw IfcException("Argument is not a list of list of entity instances"); }
unsigned int EntityArgument::size() const { return 1; }
+6
View File
@@ -144,12 +144,14 @@ namespace IfcParse {
operator IfcUtil::IfcBaseClass*() const;
operator std::vector<int>() const;
operator std::vector<bool>() const;
operator std::vector<double>() const;
operator std::vector<std::string>() const;
operator std::vector<boost::dynamic_bitset<> >() const;
operator IfcEntityList::ptr() const;
operator std::vector< std::vector<int> >() const;
operator std::vector< std::vector<bool> >() const;
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
@@ -182,12 +184,14 @@ namespace IfcParse {
operator IfcUtil::IfcBaseClass*() const;
operator std::vector<int>() const;
operator std::vector<bool>() const;
operator std::vector<double>() const;
operator std::vector<std::string>() const;
operator std::vector<boost::dynamic_bitset<> >() const;
operator IfcEntityList::ptr() const;
operator std::vector< std::vector<int> >() const;
operator std::vector< std::vector<bool> >() const;
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
@@ -218,12 +222,14 @@ namespace IfcParse {
operator IfcUtil::IfcBaseClass*() const;
operator std::vector<int>() const;
operator std::vector<bool>() const;
operator std::vector<double>() const;
operator std::vector<std::string>() const;
operator std::vector<boost::dynamic_bitset<> >() const;
operator IfcEntityList::ptr() const;
operator std::vector< std::vector<int> >() const;
operator std::vector< std::vector<bool> >() const;
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
+2
View File
@@ -122,12 +122,14 @@ static const char* const argument_type_string[] = {
"ENTITY INSTANCE",
"AGGREGATE OF INT",
"AGGREGATE OF BOOL",
"AGGREGATE OF DOUBLE",
"AGGREGATE OF STRING",
"AGGREGATE OF BINARY",
"AGGREGATE OF ENTITY INSTANCE",
"AGGREGATE OF AGGREGATE OF INT",
"AGGREGATE OF AGGREGATE OF BOOL",
"AGGREGATE OF AGGREGATE OF DOUBLE",
"AGGREGATE OF AGGREGATE OF ENTITY INSTANCE",
+4
View File
@@ -65,12 +65,14 @@ namespace IfcUtil {
Argument_ENTITY_INSTANCE,
Argument_AGGREGATE_OF_INT,
Argument_AGGREGATE_OF_BOOL,
Argument_AGGREGATE_OF_DOUBLE,
Argument_AGGREGATE_OF_STRING,
Argument_AGGREGATE_OF_BINARY,
Argument_AGGREGATE_OF_ENTITY_INSTANCE,
Argument_AGGREGATE_OF_AGGREGATE_OF_INT,
Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL,
Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,
Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE,
@@ -318,12 +320,14 @@ public:
virtual operator IfcUtil::IfcBaseClass*() const = 0;
virtual operator std::vector<int>() const = 0;
virtual operator std::vector<bool>() const = 0;
virtual operator std::vector<double>() const = 0;
virtual operator std::vector<std::string>() const = 0;
virtual operator std::vector<boost::dynamic_bitset<> >() const = 0;
virtual operator IfcEntityList::ptr() const = 0;
virtual operator std::vector< std::vector<int> >() const = 0;
virtual operator std::vector< std::vector<bool> >() const = 0;
virtual operator std::vector< std::vector<double> >() const = 0;
virtual operator IfcEntityListList::ptr() const = 0;
+2
View File
@@ -83,12 +83,14 @@ namespace IfcWrite {
void setArgument(int i,IfcUtil::IfcBaseClass* v);
void setArgument(int i,const std::vector<int>& v);
void setArgument(int i,const std::vector<bool>& v);
void setArgument(int i,const std::vector<double>& v);
void setArgument(int i,const std::vector<std::string>& v);
void setArgument(int i,const std::vector< boost::dynamic_bitset<> >& v);
void setArgument(int i,IfcEntityList::ptr v);
void setArgument(int i,const std::vector< std::vector<int> >& v);
void setArgument(int i,const std::vector< std::vector<bool> >& v);
void setArgument(int i,const std::vector< std::vector<double> >& v);
void setArgument(int i,IfcEntityListList::ptr v);
};
+49 -6
View File
@@ -169,6 +169,10 @@ void IfcWritableEntity::setArgument(int i, Argument* a) {
std::vector<int> attr_value = *a;
this->setArgument(i, attr_value); }
break;
case IfcUtil::Argument_AGGREGATE_OF_BOOL: {
std::vector<bool> attr_value = *a;
this->setArgument(i, attr_value); }
break;
case IfcUtil::Argument_AGGREGATE_OF_DOUBLE: {
std::vector<double> attr_value = *a;
this->setArgument(i, attr_value); }
@@ -204,6 +208,10 @@ void IfcWritableEntity::setArgument(int i, Argument* a) {
std::vector< std::vector<int> > attr_value = *a;
this->setArgument(i, attr_value); }
break;
case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL: {
std::vector< std::vector<bool> > attr_value = *a;
this->setArgument(i, attr_value); }
break;
case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE: {
std::vector< std::vector<double> > attr_value = *a;
this->setArgument(i, attr_value); }
@@ -270,19 +278,25 @@ void IfcWritableEntity::setArgument(int i,IfcEntityListList::ptr v){
_setArgument(i, boost::none);
}
}
void IfcWritableEntity::setArgument(int i,const std::vector<double>& v){
void IfcWritableEntity::setArgument(int i,const std::vector<int>& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector< std::vector<double> >& v){
void IfcWritableEntity::setArgument(int i,const std::vector<bool>& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector<double>& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector<std::string>& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector<int>& v){
void IfcWritableEntity::setArgument(int i,const std::vector< std::vector<int> >& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector< std::vector<int> >& v){
void IfcWritableEntity::setArgument(int i,const std::vector< std::vector<bool> >& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector< std::vector<double> >& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector< boost::dynamic_bitset<> >& v){
@@ -299,8 +313,10 @@ public:
int operator()(const std::string& /*i*/) const { return -1; }
int operator()(const boost::dynamic_bitset<>& /*i*/) const { return -1; }
int operator()(const std::vector<int>& i) const { return (int)i.size(); }
int operator()(const std::vector<bool>& i) const { return (int)i.size(); }
int operator()(const std::vector<double>& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<int> >& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<bool> >& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<double> >& i) const { return (int)i.size(); }
int operator()(const std::vector<std::string>& i) const { return (int)i.size(); }
int operator()(const std::vector< boost::dynamic_bitset<> >& i) const { return (int)i.size(); }
@@ -349,6 +365,10 @@ private:
return oss.str();
}
std::string format_bool(bool b) {
return b ? ".T." : ".F.";
}
std::string format_binary(const boost::dynamic_bitset<>& b) {
std::ostringstream oss;
oss.imbue(std::locale::classic());
@@ -376,7 +396,7 @@ public:
void operator()(const boost::none_t& /*i*/) { data << "$"; }
void operator()(const IfcWriteArgument::Derived& /*i*/) { data << "*"; }
void operator()(const int& i) { data << i; }
void operator()(const bool& i) { data << (i ? ".T." : ".F."); }
void operator()(const bool& i) { data << format_bool(i); }
void operator()(const double& i) { data << format_double(i); }
void operator()(const boost::dynamic_bitset<>& i) { data << format_binary(i); }
void operator()(const std::string& i) {
@@ -388,6 +408,7 @@ public:
}
}
void operator()(const std::vector<int>& i);
void operator()(const std::vector<bool>& i);
void operator()(const std::vector<double>& i);
void operator()(const std::vector<std::string>& i);
void operator()(const std::vector< boost::dynamic_bitset<> >& i);
@@ -411,6 +432,7 @@ public:
data << ")";
}
void operator()(const std::vector< std::vector<int> >& i);
void operator()(const std::vector< std::vector<bool> >& i);
void operator()(const std::vector< std::vector<double> >& i);
void operator()(const IfcEntityListList::ptr& i) {
data << "(";
@@ -453,6 +475,16 @@ void StringBuilderVisitor::serialize(const std::vector<double>& i) {
data << ")";
}
template <>
void StringBuilderVisitor::serialize(const std::vector<bool>& i) {
data << "(";
for (std::vector<bool>::const_iterator it = i.begin(); it != i.end(); ++it) {
if (it != i.begin()) data << ",";
data << format_bool(*it);
}
data << ")";
}
template <>
void StringBuilderVisitor::serialize(const std::vector< boost::dynamic_bitset<> >& i) {
data << "(";
@@ -464,6 +496,7 @@ void StringBuilderVisitor::serialize(const std::vector< boost::dynamic_bitset<>
}
void StringBuilderVisitor::operator()(const std::vector<int>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<bool>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<double>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<std::string>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector< boost::dynamic_bitset<> >& i) { serialize(i); }
@@ -475,6 +508,14 @@ void StringBuilderVisitor::operator()(const std::vector< std::vector<int> >& i)
}
data << ")";
}
void StringBuilderVisitor::operator()(const std::vector< std::vector<bool> >& i) {
data << "(";
for (std::vector< std::vector<bool> >::const_iterator it = i.begin(); it != i.end(); ++it) {
if (it != i.begin()) data << ",";
serialize(*it);
}
data << ")";
}
void StringBuilderVisitor::operator()(const std::vector< std::vector<double> >& i) {
data << "(";
for (std::vector< std::vector<double> >::const_iterator it = i.begin(); it != i.end(); ++it) {
@@ -495,12 +536,14 @@ IfcWriteArgument::operator std::string() const {
}
IfcWriteArgument::operator IfcUtil::IfcBaseClass*() const { return as<IfcUtil::IfcBaseClass*>(); }
IfcWriteArgument::operator boost::dynamic_bitset<>() const { return as< boost::dynamic_bitset<> >(); }
IfcWriteArgument::operator std::vector<double>() const { return as<std::vector<double> >(); }
IfcWriteArgument::operator std::vector<int>() const { return as<std::vector<int> >(); }
IfcWriteArgument::operator std::vector<bool>() const { return as<std::vector<bool> >(); }
IfcWriteArgument::operator std::vector<double>() const { return as<std::vector<double> >(); }
IfcWriteArgument::operator std::vector<std::string>() const { return as<std::vector<std::string > >(); }
IfcWriteArgument::operator std::vector< boost::dynamic_bitset<> >() const { return as< std::vector< boost::dynamic_bitset<> > >(); }
IfcWriteArgument::operator IfcEntityList::ptr() const { return as<IfcEntityList::ptr>(); }
IfcWriteArgument::operator std::vector< std::vector<int> >() const { return as<std::vector< std::vector<int> > >(); }
IfcWriteArgument::operator std::vector< std::vector<bool> >() const { return as<std::vector< std::vector<bool> > >(); }
IfcWriteArgument::operator std::vector< std::vector<double> >() const { return as<std::vector< std::vector<double> > >(); }
IfcWriteArgument::operator IfcEntityListList::ptr() const { throw; }
bool IfcWriteArgument::isNull() const { return type() == IfcUtil::Argument_NULL; }
+6
View File
@@ -86,6 +86,8 @@ namespace IfcWrite {
// AGGREGATES:
// An aggregate of integers, e.g. (1,2,3)
std::vector<int>,
// An aggregate of bools, e.g. (.T.,.F.)
std::vector<bool>,
// An aggregate of floats, e.g. (12.3,4.)
std::vector<double>,
// An aggregate of strings, e.g. ('Ifc','Open','Shell')
@@ -100,6 +102,8 @@ namespace IfcWrite {
// AGGREGATES OF AGGREGATES:
// An aggregate of an aggregate of ints. E.g. ((1, 2), (3))
std::vector< std::vector<int> >,
// An aggregate of bools, e.g. (.T.,(.T.,.F.))
std::vector< std::vector<bool> >,
// An aggregate of an aggregate of floats. E.g. ((1., 2.3), (4.))
std::vector< std::vector<double> >,
// An aggregate of an aggregate of entities. E.g. ((#1, #2), (#3))
@@ -126,12 +130,14 @@ namespace IfcWrite {
operator IfcUtil::IfcBaseClass*() const;
operator std::vector<int>() const;
operator std::vector<bool>() const;
operator std::vector<double>() const;
operator std::vector<std::string>() const;
operator std::vector<boost::dynamic_bitset<> >() const;
operator IfcEntityList::ptr() const;
operator std::vector< std::vector<int> >() const;
operator std::vector< std::vector<bool> >() const;
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
+7 -1
View File
@@ -21,6 +21,7 @@
%{
template <typename T> void* get_python_type();
template <> void* get_python_type<double>() { return &PyFloat_Type; }
template <> void* get_python_type<bool>() { return &PyBool_Type; }
#if PY_VERSION_HEX >= 0x03000000
template <> void* get_python_type<int>() { return &PyLong_Type; }
template <> void* get_python_type<std::string>() { return &PyUnicode_Type; }
@@ -59,6 +60,11 @@
return static_cast<int>(PyInt_AsLong(element));
}
template <>
bool cast_pyobject(PyObject* element) {
return cast_pyobject<int>(element) != 0;
}
template <>
double cast_pyobject(PyObject* element) {
return PyFloat_AsDouble(element);
@@ -107,8 +113,8 @@
// Conversion functions to convert STL vectors into Python objects
%{
PyObject* pythonize(const int& t) { return PyInt_FromLong(t); }
PyObject* pythonize(const unsigned int& t) { return PyInt_FromLong(t); }
PyObject* pythonize(const bool& t) { return PyBool_FromLong(t); }
PyObject* pythonize(const unsigned int& t) { return PyInt_FromLong(t); }
PyObject* pythonize(const double& t) { return PyFloat_FromDouble(t); }
PyObject* pythonize(const std::string& t) { return PyUnicode_FromString(t.c_str()); }
PyObject* pythonize(const IfcUtil::IfcBaseClass* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__IfcLateBoundEntity, 0); }
+1
View File
@@ -62,6 +62,7 @@
%enddef
CREATE_VECTOR_TYPEMAP_IN(int, INTEGER, int)
CREATE_VECTOR_TYPEMAP_IN(bool, BOOLEAN, bool)
CREATE_VECTOR_TYPEMAP_IN(double, REAL, float)
CREATE_VECTOR_TYPEMAP_IN(std::string, STRING, str)
+9
View File
@@ -47,6 +47,10 @@
std::vector<int> v = arg;
$result = pythonize_vector(v);
break; }
case IfcUtil::Argument_AGGREGATE_OF_BOOL: {
std::vector<bool> v = arg;
$result = pythonize_vector(v);
break; }
case IfcUtil::Argument_AGGREGATE_OF_DOUBLE: {
std::vector<double> v = arg;
$result = pythonize_vector(v);
@@ -71,6 +75,10 @@
std::vector< std::vector<int> > v = arg;
$result = pythonize_vector2(v);
break; }
case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL: {
std::vector< std::vector<bool> > v = arg;
$result = pythonize_vector2(v);
break; }
case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE: {
std::vector< std::vector<double> > v = arg;
$result = pythonize_vector2(v);
@@ -102,6 +110,7 @@
%enddef
CREATE_VECTOR_TYPEMAP_OUT(int)
CREATE_VECTOR_TYPEMAP_OUT(bool)
CREATE_VECTOR_TYPEMAP_OUT(unsigned int)
CREATE_VECTOR_TYPEMAP_OUT(double)
CREATE_VECTOR_TYPEMAP_OUT(std::string)