From 19b89a3b1fd1d972d03f2ac6cfd08a4fc9afc284 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 2 Jul 2024 11:43:09 +0200 Subject: [PATCH] Workarounds for unstyled elements in tree and wrapper #4924 --- src/ifcgeom/kernels/opencascade/IfcGeomTree.h | 8 ++-- src/ifcgeom/taxonomy.cpp | 6 +-- src/ifcwrap/IfcGeomWrapper.i | 36 +-------------- src/ifcwrap/utils/type_conversion.i | 45 +++++++++++++++++++ src/ifcwrap/utils/typemaps_out.i | 38 ++++++++++++++++ 5 files changed, 92 insertions(+), 41 deletions(-) diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomTree.h b/src/ifcgeom/kernels/opencascade/IfcGeomTree.h index 6fe6286727..6472851d1d 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomTree.h +++ b/src/ifcgeom/kernels/opencascade/IfcGeomTree.h @@ -1976,11 +1976,11 @@ namespace IfcGeom { TopoDS_Iterator it(compound); for (; it.More(); it.Next(), ++git) { // Assumption is that the number of styles is small, so the linear lookup time is not significant. - auto sit = std::find(styles_.begin(), styles_.end(), git->Style()); + auto sit = std::find(styles_.begin(), styles_.end(), git->StylePtr()); size_t index; if (sit == styles_.end()) { index = styles_.size(); - styles_.push_back(git->Style()); + styles_.push_back(git->StylePtr()); } else { index = std::distance(styles_.begin(), sit); } @@ -2058,7 +2058,7 @@ namespace IfcGeom { enable_face_styles_ = b; } - const std::vector& styles() const { + const std::vector& styles() const { return styles_; } @@ -2066,7 +2066,7 @@ namespace IfcGeom { typedef TopTools_DataMapOfShapeInteger face_style_map_t; face_style_map_t face_styles_; - std::vector styles_; + std::vector styles_; }; } diff --git a/src/ifcgeom/taxonomy.cpp b/src/ifcgeom/taxonomy.cpp index 2f2046c375..0783621ff9 100644 --- a/src/ifcgeom/taxonomy.cpp +++ b/src/ifcgeom/taxonomy.cpp @@ -575,13 +575,13 @@ void ifcopenshell::geometry::taxonomy::colour::print(std::ostream& o, int indent void ifcopenshell::geometry::taxonomy::style::print(std::ostream& o, int indent) const { o << std::string(indent, ' ') << "style" << std::endl; - o << std::string(indent, ' ') << " " << "name" << (name) << std::endl; + o << std::string(indent, ' ') << " " << "name " << (name) << std::endl; if (diffuse.components_) { - o << std::string(indent, ' ') << " " << "diffuse" << (name) << std::endl; + o << std::string(indent, ' ') << " " << "diffuse" << std::endl; diffuse.print(o, indent + 5 + 7); } if (specular.components_) { - o << std::string(indent, ' ') << " " << "specular" << (name) << std::endl; + o << std::string(indent, ' ') << " " << "specular" << std::endl; specular.print(o, indent + 5 + 8); } // @todo diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 496b51ccff..b0f890fdf2 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -204,9 +204,6 @@ std::string taxonomy_item_repr(ifcopenshell::geometry::taxonomy::item::ptr i) { %include "../serializers/XmlSerializer.h" %include "../serializers/GltfSerializer.h" -%template(material_vector) std::vector; -%template(edge_vector) std::vector; - %extend ifcopenshell::geometry::taxonomy::style { size_t instance_id() const { if (self->instance == nullptr) { @@ -251,7 +248,7 @@ std::string taxonomy_item_repr(ifcopenshell::geometry::taxonomy::item::ptr i) { %extend ifcopenshell::geometry::taxonomy::loop { - std::vector children_() const { + const std::vector& children_() const { return $self->children; } @@ -871,36 +868,7 @@ struct ShapeRTTI : public boost::static_visitor %} %typemap(out) ifcopenshell::geometry::taxonomy::item::ptr { - using namespace ifcopenshell::geometry::taxonomy; - auto kind = $1->kind(); - // @todo this is not automatically generated :( - // we can probably use the dispatch mechanism for this we already have in the kernel - if (kind == BSPLINE_CURVE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__bspline_curve_t, 0 | SWIG_POINTER_OWN); } - else if (kind == BSPLINE_SURFACE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__bspline_surface_t, 0 | SWIG_POINTER_OWN); } - else if (kind == CIRCLE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__circle_t, 0 | SWIG_POINTER_OWN); } - else if (kind == COLLECTION) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__collection_t, 0 | SWIG_POINTER_OWN); } - else if (kind == COLOUR) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__colour_t, 0 | SWIG_POINTER_OWN); } - else if (kind == CYLINDER) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__cylinder_t, 0 | SWIG_POINTER_OWN); } - else if (kind == DIRECTION3) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__direction3_t, 0 | SWIG_POINTER_OWN); } - else if (kind == EDGE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__edge_t, 0 | SWIG_POINTER_OWN); } - else if (kind == ELLIPSE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__ellipse_t, 0 | SWIG_POINTER_OWN); } - else if (kind == EXTRUSION) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__extrusion_t, 0 | SWIG_POINTER_OWN); } - else if (kind == FACE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__face_t, 0 | SWIG_POINTER_OWN); } - else if (kind == LINE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__line_t, 0 | SWIG_POINTER_OWN); } - else if (kind == LOFT) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__loft_t, 0 | SWIG_POINTER_OWN); } - else if (kind == LOOP) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__loop_t, 0 | SWIG_POINTER_OWN); } - else if (kind == MATRIX4) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__matrix4_t, 0 | SWIG_POINTER_OWN); } - else if (kind == NODE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__node_t, 0 | SWIG_POINTER_OWN); } - else if (kind == OFFSET_CURVE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__offset_curve_t, 0 | SWIG_POINTER_OWN); } - else if (kind == PIECEWISE_FUNCTION) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__piecewise_function_t, 0 | SWIG_POINTER_OWN); } - else if (kind == PLANE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__plane_t, 0 | SWIG_POINTER_OWN); } - else if (kind == POINT3) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__point3_t, 0 | SWIG_POINTER_OWN); } - else if (kind == REVOLVE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__revolve_t, 0 | SWIG_POINTER_OWN); } - else if (kind == SHELL) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__shell_t, 0 | SWIG_POINTER_OWN); } - else if (kind == SOLID) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__solid_t, 0 | SWIG_POINTER_OWN); } - else if (kind == SPHERE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::static_pointer_cast($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__sphere_t, 0 | SWIG_POINTER_OWN); } - else if (kind == STYLE) { $result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr