diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 3b669d069b..1069f6ba30 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -93,47 +93,6 @@ %ignore IfcGeom::Iterator::Iterator(const IfcGeom::IteratorSettings&, void*, int); %ignore IfcGeom::Iterator::Iterator(const IfcGeom::IteratorSettings&, std::istream&, int); -// Ignore the std::vector accessors and replace them to pairs that will -// be expanded to Python tuples by means of typemaps. This in order to -// minimize passing STL objects across dynamic library boundaries. -%ignore IfcGeom::Representation::Triangulation::verts; -%ignore IfcGeom::Representation::Triangulation::faces; -%ignore IfcGeom::Representation::Triangulation::edges; -%ignore IfcGeom::Representation::Triangulation::normals; -%ignore IfcGeom::Representation::Triangulation::material_ids; -%ignore IfcGeom::Representation::Triangulation::materials; -%extend IfcGeom::Representation::Triangulation { - std::pair get_faces() { - return std::make_pair(&$self->faces()[0], $self->faces().size()); - } - std::pair get_edges() { - return std::make_pair(&$self->edges()[0], $self->edges().size()); - } - std::pair get_material_ids() { - return std::make_pair(&$self->material_ids()[0], $self->material_ids().size()); - } - std::pair get_materials() { - return std::make_pair(&$self->materials()[0], $self->materials().size()); - } -} -%extend IfcGeom::Representation::Triangulation { - std::pair get_verts() { - return std::make_pair(&$self->verts()[0], $self->verts().size()); - } - std::pair get_normals() { - return std::make_pair(&$self->normals()[0], $self->normals().size()); - } -} -%extend IfcGeom::Representation::Triangulation { - std::pair get_verts() { - return std::make_pair(&$self->verts()[0], $self->verts().size()); - } - std::pair get_normals() { - return std::make_pair(&$self->normals()[0], $self->normals().size()); - } -} - - %extend IfcGeom::IteratorSettings { %pythoncode %{ attrs = ("convert_back_units", "deflection_tolerance", "disable_opening_subtractions", "disable_triangulation", "faster_booleans", "sew_shells", "use_brep_data", "use_world_coords", "weld_vertices") @@ -159,10 +118,10 @@ if _newclass: # Hide the getters with read-only property implementations id = property(id) - faces = property(get_faces) - edges = property(get_edges) - material_ids = property(get_material_ids) - materials = property(get_materials) + faces = property(faces) + edges = property(edges) + material_ids = property(material_ids) + materials = property(materials) %} }; @@ -172,16 +131,16 @@ %pythoncode %{ if _newclass: # Hide the getters with read-only property implementations - verts = property(get_verts) - normals = property(get_normals) + verts = property(verts) + normals = property(normals) %} }; %extend IfcGeom::Representation::Triangulation { %pythoncode %{ if _newclass: # Hide the getters with read-only property implementations - verts = property(get_verts) - normals = property(get_normals) + verts = property(verts) + normals = property(normals) %} }; diff --git a/src/ifcwrap/utils/type_conversion.i b/src/ifcwrap/utils/type_conversion.i index 604be11ced..1f83559a5f 100644 --- a/src/ifcwrap/utils/type_conversion.i +++ b/src/ifcwrap/utils/type_conversion.i @@ -112,7 +112,9 @@ PyObject* pythonize(const double& t) { return PyFloat_FromDouble(t); } PyObject* pythonize(const std::string& t) { return PyString_FromString(t.c_str()); } PyObject* pythonize(const IfcUtil::IfcBaseClass* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__IfcLateBoundEntity, 0); } - + // NB: This cannot be temporary as a Python object is constructed from a pointer to the address of this object + PyObject* pythonize(const IfcGeom::Material& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(&t), SWIGTYPE_p_IfcGeom__Material, 0); } + PyObject* pythonize(const boost::dynamic_bitset<>& t) { std::string bitstring; boost::to_string(t, bitstring); diff --git a/src/ifcwrap/utils/typemaps_out.i b/src/ifcwrap/utils/typemaps_out.i index 5680a07ab5..69cccc8081 100644 --- a/src/ifcwrap/utils/typemaps_out.i +++ b/src/ifcwrap/utils/typemaps_out.i @@ -105,3 +105,4 @@ CREATE_VECTOR_TYPEMAP_OUT(int) CREATE_VECTOR_TYPEMAP_OUT(unsigned int) CREATE_VECTOR_TYPEMAP_OUT(double) CREATE_VECTOR_TYPEMAP_OUT(std::string) +CREATE_VECTOR_TYPEMAP_OUT(IfcGeom::Material)