diff --git a/.gitattributes b/.gitattributes index 7664152c72..720b232cbb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -30,6 +30,7 @@ *.gitkeep *.h text *.html text +*.i text *.ifc text *.json text *.md text @@ -43,7 +44,6 @@ # files not normalized ATM # bnf # blend -# i # ico # mo # mpass diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 5935c48718..4c6e131e03 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -1,1418 +1,1418 @@ -/******************************************************************************** - * * - * This file is part of IfcOpenShell. * - * * - * IfcOpenShell is free software: you can redistribute it and/or modify * - * it under the terms of the Lesser GNU General Public License as published by * - * the Free Software Foundation, either version 3.0 of the License, or * - * (at your option) any later version. * - * * - * IfcOpenShell is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * Lesser GNU General Public License for more details. * - * * - * You should have received a copy of the Lesser GNU General Public License * - * along with this program. If not, see . * - * * - ********************************************************************************/ - -%rename("buffer") stream_or_filename; - -%ignore stream_or_filename::stream; -%ignore boost::hash_value; -%ignore IfcGeom::BRepElement::geometry_pointer; -%ignore IfcGeom::TriangulationElement::geometry_pointer; - -// This is only used for RGB colours, hence the size of 3 -%typemap(out) const double* { - $result = PyTuple_New(3); - for (int i = 0; i < 3; ++i) { - PyTuple_SetItem($result, i, PyFloat_FromDouble($1[i])); - } -} - -%typemap(out) Eigen::Matrix4d { - $result = PyTuple_New(4); - for (int i = 0; i < 4; ++i) { - auto row = PyTuple_New(4); - for (int j = 0; j < 4; ++j) { - PyTuple_SetItem(row, j, PyFloat_FromDouble($1(i, j))); - } - PyTuple_SetItem($result, i, row); - } -} - -// SWIG does not support bool references in a meaningful way, so the -// ifcopenshell::geometry::Settings functions degrade to return a read only value -%typemap(out) double& { - $result = SWIG_From_double(*$1); -} -%typemap(out) bool& { - $result = PyBool_FromLong(static_cast(*$1)); -} - -%typemap(out) IfcGeom::OpaqueNumber { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(new IfcGeom::OpaqueNumber($1)), SWIGTYPE_p_IfcGeom__OpaqueNumber, SWIG_POINTER_OWN); -} - -%typemap(in) const IfcGeom::OpaqueNumber& (IfcGeom::OpaqueNumber temp) { - void* argp = nullptr; - int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_IfcGeom__OpaqueNumber, 0); - if (!SWIG_IsOK(res) || !argp) { - SWIG_exception_fail(SWIG_ArgError(res), "Expected IfcGeom::OpaqueNumber"); - } - temp = *reinterpret_cast(argp); - $1 = &temp; -} - -// Using RTTI return a more specialized type of Element -// Note that these elements are not to be owned by SWIG/Python as they will be freed automatically upon the next iteration -// except for the IfcGeom::Element instances which are returned by Iterator::getObject() calls -%typemap(out) IfcGeom::Element* { - IfcGeom::SerializedElement* serialized_elem = dynamic_cast($1); - IfcGeom::TriangulationElement* triangulation_elem = dynamic_cast($1); - IfcGeom::BRepElement* brep_elem = dynamic_cast($1); - if (triangulation_elem) { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(triangulation_elem), SWIGTYPE_p_IfcGeom__TriangulationElement, 0); - } else if (serialized_elem) { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(serialized_elem), SWIGTYPE_p_IfcGeom__SerializedElement, 0); - } else if (brep_elem) { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(brep_elem), SWIGTYPE_p_IfcGeom__BRepElement, 0); - } else { - $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIGTYPE_p_IfcGeom__Element, SWIG_POINTER_OWN); - } -} - -%newobject IfcGeom::Representation::BRep::item; -%newobject IfcGeom::Representation::BRep::as_compound; - -%newobject IfcGeom::ConversionResultShape::halfspaces; -%newobject IfcGeom::ConversionResultShape::box; -%newobject IfcGeom::ConversionResultShape::solid; -%newobject IfcGeom::ConversionResultShape::add; -%newobject IfcGeom::ConversionResultShape::subtract; -%newobject IfcGeom::ConversionResultShape::intersect; -%newobject IfcGeom::ConversionResultShape::concat; -%newobject IfcGeom::ConversionResultShape::moved; -%newobject IfcGeom::ConversionResultShape::wrap_in_compound; - - -%newobject nary_union; - - -%inline %{ -template -std::pair vector_to_buffer(const T& t) { - using V = typename std::remove_reference::type; - return { reinterpret_cast(t.data()), t.size() * sizeof(typename V::value_type) }; -} -%} - -%ignore ifcopenshell::geometry::taxonomy::item::print; - -%typemap(out) std::variant { - if ($1.index() == 0) { - Py_INCREF(Py_None); - return Py_None; - } else if ($1.index() == 1) { - return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::get($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__point3_t, 0 | SWIG_POINTER_OWN); - } else { - return PyFloat_FromDouble(std::get($1)); - } -} - -%typemap(out) std::optional { - if ($1) { - $result = PyBool_FromLong(*$1 ? 1 : 0); - } else { - Py_INCREF(Py_None); - $result = Py_None; - } -} - -%typemap(in) ifcopenshell::geometry::taxonomy::item::ptr { - // @this is really annoying, but apparently inheritance - // is lost in swig in the shared_ptr type hiearchy - using namespace ifcopenshell::geometry::taxonomy; - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__boolean_result_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__bspline_curve_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__bspline_surface_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__circle_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__collection_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__colour_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__cylinder_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__direction3_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__edge_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__ellipse_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__extrusion_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__face_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__line_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__loft_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__loop_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__matrix4_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__node_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__offset_curve_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__function_item_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__functor_item_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__piecewise_function_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__gradient_function_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__cant_function_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__offset_function_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__plane_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__point3_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__revolve_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__shell_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__solid_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__sphere_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__torus_t); - if (!$1) $1 = try_upcast