diff --git a/src/ifcexpressparser/mapping.py b/src/ifcexpressparser/mapping.py index 5b9721e191..0700ddab06 100644 --- a/src/ifcexpressparser/mapping.py +++ b/src/ifcexpressparser/mapping.py @@ -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): diff --git a/src/ifcparse/IfcLateBoundEntity.cpp b/src/ifcparse/IfcLateBoundEntity.cpp index f18dc74403..d3af738c91 100644 --- a/src/ifcparse/IfcLateBoundEntity.cpp +++ b/src/ifcparse/IfcLateBoundEntity.cpp @@ -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& 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& 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 >& 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 >& v) { IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i); if (arg_type == Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE) { diff --git a/src/ifcparse/IfcLateBoundEntity.h b/src/ifcparse/IfcLateBoundEntity.h index 9ae00dea58..0fc3cc8728 100644 --- a/src/ifcparse/IfcLateBoundEntity.h +++ b/src/ifcparse/IfcLateBoundEntity.h @@ -68,11 +68,13 @@ namespace IfcParse { void setArgumentAsEntityInstance(unsigned int i, IfcLateBoundEntity* v); void setArgumentAsAggregateOfInt(unsigned int i, const std::vector& v); + void setArgumentAsAggregateOfBool(unsigned int i, const std::vector& v); void setArgumentAsAggregateOfDouble(unsigned int i, const std::vector& v); void setArgumentAsAggregateOfString(unsigned int i, const std::vector& v); void setArgumentAsAggregateOfEntityInstance(unsigned int i, IfcEntityList::ptr v); void setArgumentAsAggregateOfAggregateOfInt(unsigned int i, const std::vector< std::vector >& v); + void setArgumentAsAggregateOfAggregateOfBool(unsigned int i, const std::vector< std::vector >& v); void setArgumentAsAggregateOfAggregateOfDouble(unsigned int i, const std::vector< std::vector >& v); void setArgumentAsAggregateOfAggregateOfEntityInstance(unsigned int i, IfcEntityListList::ptr v); diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 9573a0707c..30da978ee8 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -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() const { - return read_aggregate_as_vector(list); -} - ArgumentList::operator std::vector() const { return read_aggregate_as_vector(list); } +ArgumentList::operator std::vector() const { + return read_aggregate_as_vector(list); +} + +ArgumentList::operator std::vector() const { + return read_aggregate_as_vector(list); +} + ArgumentList::operator std::vector() const { return read_aggregate_as_vector(list); } @@ -638,6 +646,10 @@ ArgumentList::operator std::vector< std::vector >() const { return read_aggregate_of_aggregate_as_vector2(list); } +ArgumentList::operator std::vector< std::vector >() const { + return read_aggregate_of_aggregate_as_vector2(list); +} + ArgumentList::operator std::vector< std::vector >() const { return read_aggregate_of_aggregate_as_vector2(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() const { throw IfcException("Argument is not a list of floats"); } TokenArgument::operator std::vector() const { throw IfcException("Argument is not a list of ints"); } +TokenArgument::operator std::vector() const { throw IfcException("Argument is not a list of bools"); } +TokenArgument::operator std::vector() const { throw IfcException("Argument is not a list of floats"); } TokenArgument::operator std::vector() const { throw IfcException("Argument is not a list of strings"); } TokenArgument::operator std::vector >() 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 >() const { throw IfcException("Argument is not a list of list of ints"); } +TokenArgument::operator std::vector< std::vector >() const { throw IfcException("Argument is not a list of list of bools"); } TokenArgument::operator std::vector< std::vector >() 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() const { throw IfcException("Argument is not a list of floats"); } EntityArgument::operator std::vector() const { throw IfcException("Argument is not a list of ints"); } +EntityArgument::operator std::vector() const { throw IfcException("Argument is not a list of bools"); } +EntityArgument::operator std::vector() const { throw IfcException("Argument is not a list of floats"); } EntityArgument::operator std::vector() const { throw IfcException("Argument is not a list of strings"); } EntityArgument::operator std::vector >() 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 >() const { throw IfcException("Argument is not a list of list of ints"); } +EntityArgument::operator std::vector< std::vector >() const { throw IfcException("Argument is not a list of list of bools"); } EntityArgument::operator std::vector< std::vector >() 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; } diff --git a/src/ifcparse/IfcParse.h b/src/ifcparse/IfcParse.h index aa95772509..e38fc4bbf9 100644 --- a/src/ifcparse/IfcParse.h +++ b/src/ifcparse/IfcParse.h @@ -144,12 +144,14 @@ namespace IfcParse { operator IfcUtil::IfcBaseClass*() const; operator std::vector() const; + operator std::vector() const; operator std::vector() const; operator std::vector() const; operator std::vector >() const; operator IfcEntityList::ptr() const; operator std::vector< std::vector >() const; + operator std::vector< std::vector >() const; operator std::vector< std::vector >() const; operator IfcEntityListList::ptr() const; @@ -182,12 +184,14 @@ namespace IfcParse { operator IfcUtil::IfcBaseClass*() const; operator std::vector() const; + operator std::vector() const; operator std::vector() const; operator std::vector() const; operator std::vector >() const; operator IfcEntityList::ptr() const; operator std::vector< std::vector >() const; + operator std::vector< std::vector >() const; operator std::vector< std::vector >() const; operator IfcEntityListList::ptr() const; @@ -218,12 +222,14 @@ namespace IfcParse { operator IfcUtil::IfcBaseClass*() const; operator std::vector() const; + operator std::vector() const; operator std::vector() const; operator std::vector() const; operator std::vector >() const; operator IfcEntityList::ptr() const; operator std::vector< std::vector >() const; + operator std::vector< std::vector >() const; operator std::vector< std::vector >() const; operator IfcEntityListList::ptr() const; diff --git a/src/ifcparse/IfcUtil.cpp b/src/ifcparse/IfcUtil.cpp index 5320d8f41e..0e1d6fc5af 100644 --- a/src/ifcparse/IfcUtil.cpp +++ b/src/ifcparse/IfcUtil.cpp @@ -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", diff --git a/src/ifcparse/IfcUtil.h b/src/ifcparse/IfcUtil.h index 8e96766f42..140a4617bf 100644 --- a/src/ifcparse/IfcUtil.h +++ b/src/ifcparse/IfcUtil.h @@ -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() const = 0; + virtual operator std::vector() const = 0; virtual operator std::vector() const = 0; virtual operator std::vector() const = 0; virtual operator std::vector >() const = 0; virtual operator IfcEntityList::ptr() const = 0; virtual operator std::vector< std::vector >() const = 0; + virtual operator std::vector< std::vector >() const = 0; virtual operator std::vector< std::vector >() const = 0; virtual operator IfcEntityListList::ptr() const = 0; diff --git a/src/ifcparse/IfcWritableEntity.h b/src/ifcparse/IfcWritableEntity.h index e1c0d8610b..136ca1e81e 100644 --- a/src/ifcparse/IfcWritableEntity.h +++ b/src/ifcparse/IfcWritableEntity.h @@ -83,12 +83,14 @@ namespace IfcWrite { void setArgument(int i,IfcUtil::IfcBaseClass* v); void setArgument(int i,const std::vector& v); + void setArgument(int i,const std::vector& v); void setArgument(int i,const std::vector& v); void setArgument(int i,const std::vector& 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 >& v); + void setArgument(int i,const std::vector< std::vector >& v); void setArgument(int i,const std::vector< std::vector >& v); void setArgument(int i,IfcEntityListList::ptr v); }; diff --git a/src/ifcparse/IfcWrite.cpp b/src/ifcparse/IfcWrite.cpp index b8132a3b60..efe15a361f 100644 --- a/src/ifcparse/IfcWrite.cpp +++ b/src/ifcparse/IfcWrite.cpp @@ -169,6 +169,10 @@ void IfcWritableEntity::setArgument(int i, Argument* a) { std::vector attr_value = *a; this->setArgument(i, attr_value); } break; + case IfcUtil::Argument_AGGREGATE_OF_BOOL: { + std::vector attr_value = *a; + this->setArgument(i, attr_value); } + break; case IfcUtil::Argument_AGGREGATE_OF_DOUBLE: { std::vector attr_value = *a; this->setArgument(i, attr_value); } @@ -204,6 +208,10 @@ void IfcWritableEntity::setArgument(int i, Argument* a) { std::vector< std::vector > attr_value = *a; this->setArgument(i, attr_value); } break; + case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL: { + std::vector< std::vector > attr_value = *a; + this->setArgument(i, attr_value); } + break; case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE: { std::vector< std::vector > 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& v){ +void IfcWritableEntity::setArgument(int i,const std::vector& v){ _setArgument(i, v); } -void IfcWritableEntity::setArgument(int i,const std::vector< std::vector >& v){ +void IfcWritableEntity::setArgument(int i,const std::vector& v){ + _setArgument(i, v); +} +void IfcWritableEntity::setArgument(int i,const std::vector& v){ _setArgument(i, v); } void IfcWritableEntity::setArgument(int i,const std::vector& v){ _setArgument(i, v); } -void IfcWritableEntity::setArgument(int i,const std::vector& v){ +void IfcWritableEntity::setArgument(int i,const std::vector< std::vector >& v){ _setArgument(i, v); } -void IfcWritableEntity::setArgument(int i,const std::vector< std::vector >& v){ +void IfcWritableEntity::setArgument(int i,const std::vector< std::vector >& v){ + _setArgument(i, v); +} +void IfcWritableEntity::setArgument(int i,const std::vector< std::vector >& 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& i) const { return (int)i.size(); } + int operator()(const std::vector& i) const { return (int)i.size(); } int operator()(const std::vector& i) const { return (int)i.size(); } int operator()(const std::vector< std::vector >& i) const { return (int)i.size(); } + int operator()(const std::vector< std::vector >& i) const { return (int)i.size(); } int operator()(const std::vector< std::vector >& i) const { return (int)i.size(); } int operator()(const std::vector& 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& i); + void operator()(const std::vector& i); void operator()(const std::vector& i); void operator()(const std::vector& i); void operator()(const std::vector< boost::dynamic_bitset<> >& i); @@ -411,6 +432,7 @@ public: data << ")"; } void operator()(const std::vector< std::vector >& i); + void operator()(const std::vector< std::vector >& i); void operator()(const std::vector< std::vector >& i); void operator()(const IfcEntityListList::ptr& i) { data << "("; @@ -453,6 +475,16 @@ void StringBuilderVisitor::serialize(const std::vector& i) { data << ")"; } +template <> +void StringBuilderVisitor::serialize(const std::vector& i) { + data << "("; + for (std::vector::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& i) { serialize(i); } +void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } void StringBuilderVisitor::operator()(const std::vector& 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 >& i) } data << ")"; } +void StringBuilderVisitor::operator()(const std::vector< std::vector >& i) { + data << "("; + for (std::vector< std::vector >::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 >& i) { data << "("; for (std::vector< std::vector >::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(); } IfcWriteArgument::operator boost::dynamic_bitset<>() const { return as< boost::dynamic_bitset<> >(); } -IfcWriteArgument::operator std::vector() const { return as >(); } IfcWriteArgument::operator std::vector() const { return as >(); } +IfcWriteArgument::operator std::vector() const { return as >(); } +IfcWriteArgument::operator std::vector() const { return as >(); } IfcWriteArgument::operator std::vector() const { return as >(); } IfcWriteArgument::operator std::vector< boost::dynamic_bitset<> >() const { return as< std::vector< boost::dynamic_bitset<> > >(); } IfcWriteArgument::operator IfcEntityList::ptr() const { return as(); } IfcWriteArgument::operator std::vector< std::vector >() const { return as > >(); } +IfcWriteArgument::operator std::vector< std::vector >() const { return as > >(); } IfcWriteArgument::operator std::vector< std::vector >() const { return as > >(); } IfcWriteArgument::operator IfcEntityListList::ptr() const { throw; } bool IfcWriteArgument::isNull() const { return type() == IfcUtil::Argument_NULL; } diff --git a/src/ifcparse/IfcWrite.h b/src/ifcparse/IfcWrite.h index d7b1e01678..d12a80ae50 100644 --- a/src/ifcparse/IfcWrite.h +++ b/src/ifcparse/IfcWrite.h @@ -86,6 +86,8 @@ namespace IfcWrite { // AGGREGATES: // An aggregate of integers, e.g. (1,2,3) std::vector, + // An aggregate of bools, e.g. (.T.,.F.) + std::vector, // An aggregate of floats, e.g. (12.3,4.) std::vector, // 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 >, + // An aggregate of bools, e.g. (.T.,(.T.,.F.)) + std::vector< std::vector >, // An aggregate of an aggregate of floats. E.g. ((1., 2.3), (4.)) std::vector< std::vector >, // 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() const; + operator std::vector() const; operator std::vector() const; operator std::vector() const; operator std::vector >() const; operator IfcEntityList::ptr() const; operator std::vector< std::vector >() const; + operator std::vector< std::vector >() const; operator std::vector< std::vector >() const; operator IfcEntityListList::ptr() const; diff --git a/src/ifcwrap/utils/type_conversion.i b/src/ifcwrap/utils/type_conversion.i index 9ea0644457..9eb1bfd0a3 100644 --- a/src/ifcwrap/utils/type_conversion.i +++ b/src/ifcwrap/utils/type_conversion.i @@ -21,6 +21,7 @@ %{ template void* get_python_type(); template <> void* get_python_type() { return &PyFloat_Type; } + template <> void* get_python_type() { return &PyBool_Type; } #if PY_VERSION_HEX >= 0x03000000 template <> void* get_python_type() { return &PyLong_Type; } template <> void* get_python_type() { return &PyUnicode_Type; } @@ -59,6 +60,11 @@ return static_cast(PyInt_AsLong(element)); } + template <> + bool cast_pyobject(PyObject* element) { + return cast_pyobject(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); } diff --git a/src/ifcwrap/utils/typemaps_in.i b/src/ifcwrap/utils/typemaps_in.i index b486b80d6a..ce867462de 100644 --- a/src/ifcwrap/utils/typemaps_in.i +++ b/src/ifcwrap/utils/typemaps_in.i @@ -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) diff --git a/src/ifcwrap/utils/typemaps_out.i b/src/ifcwrap/utils/typemaps_out.i index 69cccc8081..3611254f3c 100644 --- a/src/ifcwrap/utils/typemaps_out.i +++ b/src/ifcwrap/utils/typemaps_out.i @@ -47,6 +47,10 @@ std::vector v = arg; $result = pythonize_vector(v); break; } + case IfcUtil::Argument_AGGREGATE_OF_BOOL: { + std::vector v = arg; + $result = pythonize_vector(v); + break; } case IfcUtil::Argument_AGGREGATE_OF_DOUBLE: { std::vector v = arg; $result = pythonize_vector(v); @@ -71,6 +75,10 @@ std::vector< std::vector > v = arg; $result = pythonize_vector2(v); break; } + case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL: { + std::vector< std::vector > v = arg; + $result = pythonize_vector2(v); + break; } case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE: { std::vector< std::vector > 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)