Last minute refactoring

This commit is contained in:
Thomas Krijnen
2026-08-08 07:42:45 +02:00
parent 8870ffb018
commit af58eaf79f
300 changed files with 5230 additions and 5150 deletions
+65 -58
View File
@@ -34,26 +34,33 @@
return element->ob_type == get_python_type<T>();
}
inline bool convert_pyobject_to_base(PyObject* element, express::Base& value) {
inline bool convert_pyobject_to_base(PyObject* element, express::base& value) {
void* arg = nullptr;
int result = SWIG_ConvertPtr(element, &arg, SWIGTYPE_p_express__Base, 0);
int result = SWIG_ConvertPtr(element, &arg, SWIGTYPE_p_express__base, 0);
if (SWIG_IsOK(result) && arg) {
value = *static_cast<express::Base*>(arg);
value = *static_cast<express::base*>(arg);
return true;
}
value = express::Base{};
value = express::base{};
return false;
}
template <>
bool check_python_type<express::Base>(PyObject* element) {
express::Base value;
bool check_python_type<express::base>(PyObject* element) {
express::base value;
return convert_pyobject_to_base(element, value);
}
inline bool check_python_sequence(PyObject* aggregate) {
// A Python string is technically a sequence, but treating it as an STL
// aggregate makes overloaded setters select vector<string> before string.
return PySequence_Check(aggregate) &&
!PyUnicode_Check(aggregate) && !PyBytes_Check(aggregate);
}
bool check_aggregate_of_type(PyObject* aggregate, void* type_obj) {
if (!PySequence_Check(aggregate)) return false;
if (!check_python_sequence(aggregate)) return false;
if (PySequence_Size(aggregate) == -1) return false;
for(Py_ssize_t i = 0; i < PySequence_Size(aggregate); ++i) {
PyObject* element = PySequence_GetItem(aggregate, i);
@@ -79,7 +86,7 @@
}
bool check_aggregate_of_aggregate_of_type(PyObject* aggregate, void* type_obj) {
if (!PySequence_Check(aggregate)) return false;
if (!check_python_sequence(aggregate)) return false;
if (PySequence_Size(aggregate) == -1) return false;
for(Py_ssize_t i = 0; i < PySequence_Size(aggregate); ++i) {
PyObject* element = PySequence_GetItem(aggregate, i);
@@ -94,7 +101,7 @@
template <typename T>
bool check_aggregate_of_type(PyObject* aggregate) {
if (!PySequence_Check(aggregate)) return false;
if (!check_python_sequence(aggregate)) return false;
for(Py_ssize_t i = 0; i < PySequence_Size(aggregate); ++i) {
PyObject* element = PySequence_GetItem(aggregate, i);
bool valid = check_python_type<T>(element);
@@ -107,11 +114,11 @@
}
template <>
bool check_aggregate_of_type<express::Base>(PyObject* aggregate) {
if (!PySequence_Check(aggregate)) return false;
bool check_aggregate_of_type<express::base>(PyObject* aggregate) {
if (!check_python_sequence(aggregate)) return false;
for(Py_ssize_t i = 0; i < PySequence_Size(aggregate); ++i) {
PyObject* element = PySequence_GetItem(aggregate, i);
express::Base value;
express::base value;
bool valid = convert_pyobject_to_base(element, value);
Py_DECREF(element);
if (!valid) {
@@ -123,7 +130,7 @@
template <typename T>
bool check_aggregate_of_aggregate_of_type(PyObject* aggregate) {
if (!PySequence_Check(aggregate)) return false;
if (!check_python_sequence(aggregate)) return false;
for(Py_ssize_t i = 0; i < PySequence_Size(aggregate); ++i) {
PyObject* element = PySequence_GetItem(aggregate, i);
bool valid = check_aggregate_of_type<T>(element);
@@ -136,11 +143,11 @@
}
template <>
bool check_aggregate_of_aggregate_of_type<express::Base>(PyObject* aggregate) {
if (!PySequence_Check(aggregate)) return false;
bool check_aggregate_of_aggregate_of_type<express::base>(PyObject* aggregate) {
if (!check_python_sequence(aggregate)) return false;
for(Py_ssize_t i = 0; i < PySequence_Size(aggregate); ++i) {
PyObject* element = PySequence_GetItem(aggregate, i);
bool valid = check_aggregate_of_type<express::Base>(element);
bool valid = check_aggregate_of_type<express::base>(element);
Py_DECREF(element);
if (!valid) {
return false;
@@ -178,9 +185,9 @@
}
template <>
express::Base cast_pyobject(PyObject* element) {
express::Base value;
return convert_pyobject_to_base(element, value) ? value : express::Base{};
express::base cast_pyobject(PyObject* element) {
express::base value;
return convert_pyobject_to_base(element, value) ? value : express::base{};
}
template<typename T>
@@ -255,17 +262,17 @@
PyObject* pythonize(const boost::logic::tribool& t) { return boost::logic::indeterminate(t) ? PyUnicode_FromString("UNKNOWN") : PyBool_FromLong((bool)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 express::Base& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(new express::Base(t)), SWIGTYPE_p_express__Base, SWIG_POINTER_OWN); }
PyObject* pythonize(const express::base& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(new express::base(t)), SWIGTYPE_p_express__base, SWIG_POINTER_OWN); }
PyObject* pythonize(const ifcopenshell::attribute* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_ifcopenshell__attribute, 0); }
PyObject* pythonize(const ifcopenshell::inverse_attribute* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_ifcopenshell__inverse_attribute, 0); }
PyObject* pythonize(const ifcopenshell::entity* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_ifcopenshell__entity, 0); }
PyObject* pythonize(const ifcopenshell::declaration* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), declaration_type_to_swig(t), 0); }
PyObject* pythonize(const log_message& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(&t), SWIGTYPE_p_log_message, 0); }
// @nb ownership
PyObject* pythonize(const IfcGeom::ConversionResultShape* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcGeom__ConversionResultShape, SWIG_POINTER_OWN); }
// PyObject* pythonize(const IfcGeom::ConversionResultShape* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcGeom__ConversionResultShape, 0); }
PyObject* pythonize(const ifcopenshell::geom::conversion_result_shape* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_ifcopenshell__geom__conversion_result_shape, SWIG_POINTER_OWN); }
// PyObject* pythonize(const ifcopenshell::geom::conversion_result_shape* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_ifcopenshell__geom__conversion_result_shape, 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 ifcopenshell::geom::Material& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(&t), SWIGTYPE_p_ifcopenshell__geom__Material, 0); }
PyObject* pythonize(const boost::dynamic_bitset<>& t) {
std::string bitstring;
@@ -310,8 +317,8 @@
%{
PyObject* item_to_pyobject(const ifcopenshell::geometry::taxonomy::item::ptr& i) {
using namespace ifcopenshell::geometry::taxonomy;
PyObject* item_to_pyobject(const ifcopenshell::geom::taxonomy::item::ptr& i) {
using namespace ifcopenshell::geom::taxonomy;
if (i == nullptr) {
Py_INCREF(Py_None);
return Py_None;
@@ -319,39 +326,39 @@ PyObject* item_to_pyobject(const ifcopenshell::geometry::taxonomy::item::ptr& i)
auto kind = i->kind();
// @todo this is not automatically generated :(
// we can probably use the dispatch mechanism for this we already have in the kernel
if (kind == BOOLEAN_RESULT) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<boolean_result>(std::static_pointer_cast<boolean_result>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__boolean_result_t, 0 | SWIG_POINTER_OWN); }
else if (kind == BSPLINE_CURVE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<bspline_curve>(std::static_pointer_cast<bspline_curve>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__bspline_curve_t, 0 | SWIG_POINTER_OWN); }
else if (kind == BSPLINE_SURFACE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<bspline_surface>(std::static_pointer_cast<bspline_surface>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__bspline_surface_t, 0 | SWIG_POINTER_OWN); }
else if (kind == CIRCLE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<circle>(std::static_pointer_cast<circle>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__circle_t, 0 | SWIG_POINTER_OWN); }
else if (kind == COLLECTION) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<collection>(std::static_pointer_cast<collection>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__collection_t, 0 | SWIG_POINTER_OWN); }
else if (kind == COLOUR) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<colour>(std::static_pointer_cast<colour>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__colour_t, 0 | SWIG_POINTER_OWN); }
else if (kind == CYLINDER) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<cylinder>(std::static_pointer_cast<cylinder>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__cylinder_t, 0 | SWIG_POINTER_OWN); }
else if (kind == DIRECTION3) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<direction3>(std::static_pointer_cast<direction3>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__direction3_t, 0 | SWIG_POINTER_OWN); }
else if (kind == EDGE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<edge>(std::static_pointer_cast<edge>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__edge_t, 0 | SWIG_POINTER_OWN); }
else if (kind == ELLIPSE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<ellipse>(std::static_pointer_cast<ellipse>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__ellipse_t, 0 | SWIG_POINTER_OWN); }
else if (kind == EXTRUSION) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<extrusion>(std::static_pointer_cast<extrusion>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__extrusion_t, 0 | SWIG_POINTER_OWN); }
else if (kind == FACE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<face>(std::static_pointer_cast<face>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__face_t, 0 | SWIG_POINTER_OWN); }
else if (kind == LINE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<line>(std::static_pointer_cast<line>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__line_t, 0 | SWIG_POINTER_OWN); }
else if (kind == LOFT) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<loft>(std::static_pointer_cast<loft>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__loft_t, 0 | SWIG_POINTER_OWN); }
else if (kind == LOOP) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<loop>(std::static_pointer_cast<loop>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__loop_t, 0 | SWIG_POINTER_OWN); }
else if (kind == MATRIX4) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<matrix4>(std::static_pointer_cast<matrix4>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__matrix4_t, 0 | SWIG_POINTER_OWN); }
else if (kind == NODE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<node>(std::static_pointer_cast<node>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__node_t, 0 | SWIG_POINTER_OWN); }
else if (kind == OFFSET_CURVE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<offset_curve>(std::static_pointer_cast<offset_curve>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__offset_curve_t, 0 | SWIG_POINTER_OWN); }
else if (kind == FUNCTION_ITEM) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<function_item>(std::static_pointer_cast<function_item>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__function_item_t, 0 | SWIG_POINTER_OWN); }
else if (kind == FUNCTOR_ITEM) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<functor_item>(std::static_pointer_cast<functor_item>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__functor_item_t, 0 | SWIG_POINTER_OWN); }
else if (kind == PIECEWISE_FUNCTION) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<piecewise_function>(std::static_pointer_cast<piecewise_function>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__piecewise_function_t, 0 | SWIG_POINTER_OWN); }
else if (kind == GRADIENT_FUNCTION) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<gradient_function>(std::static_pointer_cast<gradient_function>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__gradient_function_t, 0 | SWIG_POINTER_OWN); }
else if (kind == CANT_FUNCTION) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<cant_function>(std::static_pointer_cast<cant_function>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__cant_function_t, 0 | SWIG_POINTER_OWN); }
else if (kind == OFFSET_FUNCTION) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<offset_function>(std::static_pointer_cast<offset_function>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__offset_function_t, 0 | SWIG_POINTER_OWN); }
else if (kind == PLANE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<plane>(std::static_pointer_cast<plane>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__plane_t, 0 | SWIG_POINTER_OWN); }
else if (kind == POINT3) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<point3>(std::static_pointer_cast<point3>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__point3_t, 0 | SWIG_POINTER_OWN); }
else if (kind == REVOLVE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<revolve>(std::static_pointer_cast<revolve>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__revolve_t, 0 | SWIG_POINTER_OWN); }
else if (kind == SHELL) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<shell>(std::static_pointer_cast<shell>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__shell_t, 0 | SWIG_POINTER_OWN); }
else if (kind == SOLID) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<solid>(std::static_pointer_cast<solid>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__solid_t, 0 | SWIG_POINTER_OWN); }
else if (kind == SPHERE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<sphere>(std::static_pointer_cast<sphere>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__sphere_t, 0 | SWIG_POINTER_OWN); }
else if (kind == TORUS) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<torus>(std::static_pointer_cast<torus>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__torus_t, 0 | SWIG_POINTER_OWN); }
else if (kind == STYLE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<style>(std::static_pointer_cast<style>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__style_t, 0 | SWIG_POINTER_OWN); }
else if (kind == SWEEP_ALONG_CURVE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<sweep_along_curve>(std::static_pointer_cast<sweep_along_curve>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__sweep_along_curve_t, 0 | SWIG_POINTER_OWN); }
if (kind == BOOLEAN_RESULT) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<boolean_result>(std::static_pointer_cast<boolean_result>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__boolean_result_t, 0 | SWIG_POINTER_OWN); }
else if (kind == BSPLINE_CURVE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<bspline_curve>(std::static_pointer_cast<bspline_curve>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__bspline_curve_t, 0 | SWIG_POINTER_OWN); }
else if (kind == BSPLINE_SURFACE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<bspline_surface>(std::static_pointer_cast<bspline_surface>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__bspline_surface_t, 0 | SWIG_POINTER_OWN); }
else if (kind == CIRCLE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<circle>(std::static_pointer_cast<circle>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__circle_t, 0 | SWIG_POINTER_OWN); }
else if (kind == COLLECTION) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<collection>(std::static_pointer_cast<collection>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__collection_t, 0 | SWIG_POINTER_OWN); }
else if (kind == COLOUR) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<colour>(std::static_pointer_cast<colour>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__colour_t, 0 | SWIG_POINTER_OWN); }
else if (kind == CYLINDER) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<cylinder>(std::static_pointer_cast<cylinder>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__cylinder_t, 0 | SWIG_POINTER_OWN); }
else if (kind == DIRECTION3) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<direction3>(std::static_pointer_cast<direction3>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__direction3_t, 0 | SWIG_POINTER_OWN); }
else if (kind == EDGE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<edge>(std::static_pointer_cast<edge>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__edge_t, 0 | SWIG_POINTER_OWN); }
else if (kind == ELLIPSE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<ellipse>(std::static_pointer_cast<ellipse>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__ellipse_t, 0 | SWIG_POINTER_OWN); }
else if (kind == EXTRUSION) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<extrusion>(std::static_pointer_cast<extrusion>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__extrusion_t, 0 | SWIG_POINTER_OWN); }
else if (kind == FACE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<face>(std::static_pointer_cast<face>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__face_t, 0 | SWIG_POINTER_OWN); }
else if (kind == LINE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<line>(std::static_pointer_cast<line>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__line_t, 0 | SWIG_POINTER_OWN); }
else if (kind == LOFT) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<loft>(std::static_pointer_cast<loft>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__loft_t, 0 | SWIG_POINTER_OWN); }
else if (kind == LOOP) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<loop>(std::static_pointer_cast<loop>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__loop_t, 0 | SWIG_POINTER_OWN); }
else if (kind == MATRIX4) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<matrix4>(std::static_pointer_cast<matrix4>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__matrix4_t, 0 | SWIG_POINTER_OWN); }
else if (kind == NODE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<node>(std::static_pointer_cast<node>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__node_t, 0 | SWIG_POINTER_OWN); }
else if (kind == OFFSET_CURVE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<offset_curve>(std::static_pointer_cast<offset_curve>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__offset_curve_t, 0 | SWIG_POINTER_OWN); }
else if (kind == FUNCTION_ITEM) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<function_item>(std::static_pointer_cast<function_item>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__function_item_t, 0 | SWIG_POINTER_OWN); }
else if (kind == FUNCTOR_ITEM) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<functor_item>(std::static_pointer_cast<functor_item>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__functor_item_t, 0 | SWIG_POINTER_OWN); }
else if (kind == PIECEWISE_FUNCTION) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<piecewise_function>(std::static_pointer_cast<piecewise_function>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__piecewise_function_t, 0 | SWIG_POINTER_OWN); }
else if (kind == GRADIENT_FUNCTION) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<gradient_function>(std::static_pointer_cast<gradient_function>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__gradient_function_t, 0 | SWIG_POINTER_OWN); }
else if (kind == CANT_FUNCTION) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<cant_function>(std::static_pointer_cast<cant_function>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__cant_function_t, 0 | SWIG_POINTER_OWN); }
else if (kind == OFFSET_FUNCTION) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<offset_function>(std::static_pointer_cast<offset_function>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__offset_function_t, 0 | SWIG_POINTER_OWN); }
else if (kind == PLANE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<plane>(std::static_pointer_cast<plane>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__plane_t, 0 | SWIG_POINTER_OWN); }
else if (kind == POINT3) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<point3>(std::static_pointer_cast<point3>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__point3_t, 0 | SWIG_POINTER_OWN); }
else if (kind == REVOLVE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<revolve>(std::static_pointer_cast<revolve>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__revolve_t, 0 | SWIG_POINTER_OWN); }
else if (kind == SHELL) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<shell>(std::static_pointer_cast<shell>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__shell_t, 0 | SWIG_POINTER_OWN); }
else if (kind == SOLID) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<solid>(std::static_pointer_cast<solid>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__solid_t, 0 | SWIG_POINTER_OWN); }
else if (kind == SPHERE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<sphere>(std::static_pointer_cast<sphere>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__sphere_t, 0 | SWIG_POINTER_OWN); }
else if (kind == TORUS) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<torus>(std::static_pointer_cast<torus>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__torus_t, 0 | SWIG_POINTER_OWN); }
else if (kind == STYLE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<style>(std::static_pointer_cast<style>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__style_t, 0 | SWIG_POINTER_OWN); }
else if (kind == SWEEP_ALONG_CURVE) { return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<sweep_along_curve>(std::static_pointer_cast<sweep_along_curve>(i))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__sweep_along_curve_t, 0 | SWIG_POINTER_OWN); }
else {
Py_INCREF(Py_None);
return Py_None;
+11 -11
View File
@@ -70,7 +70,7 @@
CREATE_VECTOR_TYPEMAP_IN(int, INTEGER, int)
CREATE_VECTOR_TYPEMAP_IN(double, REAL, float)
CREATE_VECTOR_TYPEMAP_IN(std::string, STRING, str)
CREATE_VECTOR_TYPEMAP_IN(express::Base, ENTITY INSTANCE, entity instance)
CREATE_VECTOR_TYPEMAP_IN(express::base, ENTITY INSTANCE, entity instance)
// @todo use macros.
@@ -299,7 +299,7 @@ CREATE_OPTIONAL_TYPEMAP_IN(std::string, string, str)
void* argp1 = nullptr;
auto res1 = SWIG_ConvertPtr(element, &argp1, type_obj, 0);
if (SWIG_IsOK(res1)) {
auto arg1 = reinterpret_cast<IfcGeom::OpaqueCoordinate<4>*>(argp1);
auto arg1 = reinterpret_cast<ifcopenshell::geom::opaque_coordinate<4>*>(argp1);
result_vector.push_back(*arg1);
}
}
@@ -307,19 +307,19 @@ CREATE_OPTIONAL_TYPEMAP_IN(std::string, string, str)
}
%}
%typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) const std::vector<IfcGeom::OpaqueCoordinate<4>>& {
$1 = check_aggregate_of_swig_type($input, SWIGTYPE_p_IfcGeom__OpaqueCoordinateT_4_t) ? 1 : 0;
%typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) const std::vector<ifcopenshell::geom::opaque_coordinate<4>>& {
$1 = check_aggregate_of_swig_type($input, SWIGTYPE_p_ifcopenshell__geom__opaque_coordinateT_4_t) ? 1 : 0;
}
%typemap(arginit) const std::vector<IfcGeom::OpaqueCoordinate<4>>& {
$1 = new std::vector<IfcGeom::OpaqueCoordinate<4>>();
%typemap(arginit) const std::vector<ifcopenshell::geom::opaque_coordinate<4>>& {
$1 = new std::vector<ifcopenshell::geom::opaque_coordinate<4>>();
}
%typemap(in) const std::vector<IfcGeom::OpaqueCoordinate<4>>& {
if (!check_aggregate_of_swig_type($input, SWIGTYPE_p_IfcGeom__OpaqueCoordinateT_4_t)) {
%typemap(in) const std::vector<ifcopenshell::geom::opaque_coordinate<4>>& {
if (!check_aggregate_of_swig_type($input, SWIGTYPE_p_ifcopenshell__geom__opaque_coordinateT_4_t)) {
SWIG_exception(SWIG_TypeError, "");
}
*$1 = python_sequence_as_swig_object_vector<IfcGeom::OpaqueCoordinate<4>>($input, SWIGTYPE_p_IfcGeom__OpaqueCoordinateT_4_t);
*$1 = python_sequence_as_swig_object_vector<ifcopenshell::geom::opaque_coordinate<4>>($input, SWIGTYPE_p_ifcopenshell__geom__opaque_coordinateT_4_t);
}
%typemap(freearg) const std::vector<IfcGeom::OpaqueCoordinate<4>>& {
%typemap(freearg) const std::vector<ifcopenshell::geom::opaque_coordinate<4>>& {
delete $1;
}
@@ -373,4 +373,4 @@ CREATE_SET_TYPEMAP_IN(std::string)
tmp[3] = '\0';
$1 = &tmp;
}
}
+39 -47
View File
@@ -33,22 +33,19 @@
// is wrapped in a try-catch block manually.
try {
$result = $1.apply_visitor([](const auto& v){
using U = std::decay_t<decltype(v)>;
if constexpr (is_std_vector_v<U>) {
using u = std::decay_t<decltype(v)>;
if constexpr (is_std_vector_v<u>) {
return pythonize_vector(v);
} else if constexpr (std::is_same_v<U, enumeration_reference>) {
} else if constexpr (std::is_same_v<u, enumeration_reference>) {
return pythonize(std::string(v.value()));
} else if constexpr (std::is_same_v<U, derived>) {
} else if constexpr (std::is_same_v<u, derived>) {
if (feature_use_attribute_value_derived) {
return SWIG_NewPointerObj(new attribute_value_derived, SWIGTYPE_p_attribute_value_derived, SWIG_POINTER_OWN);
} else {
Py_INCREF(Py_None);
return static_cast<PyObject*>(Py_None);
}
} else if constexpr (std::is_same_v<U, empty_aggregate_t> || std::is_same_v<U, empty_aggregate_of_aggregate_t> || std::is_same_v<U, blank>) {
Py_INCREF(Py_None);
return static_cast<PyObject*>(Py_None);
} else if constexpr (std::is_same_v<U, empty_aggregate_t> || std::is_same_v<U, empty_aggregate_of_aggregate_t> || std::is_same_v<U, derived> || std::is_same_v<U, blank>) {
} else if constexpr (std::is_same_v<u, empty_aggregate_t> || std::is_same_v<u, empty_aggregate_of_aggregate_t> || std::is_same_v<u, blank>) {
Py_INCREF(Py_None);
return static_cast<PyObject*>(Py_None);
} else {
@@ -83,26 +80,21 @@
}
%enddef
CREATE_VECTOR_TYPEMAP_OUT(express::Base)
CREATE_VECTOR_TYPEMAP_OUT(express::base)
CREATE_VECTOR_TYPEMAP_OUT(bool)
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)
// CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::geom::Material)
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::attribute const *)
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::inverse_attribute const *)
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::entity const *)
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::declaration const *)
CREATE_VECTOR_TYPEMAP_OUT(IfcGeom::ConversionResultShape *)
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::geom::conversion_result_shape *)
CREATE_VECTOR_TYPEMAP_OUT(log_message)
%typemap(out) ifcopenshell::geometry::Settings::value_variant_t {
pythonizing_visitor vis;
$result = std::visit(vis, $1);
}
%typemap(out) ifcopenshell::geometry::SerializerSettings::value_variant_t {
%typemap(out) ifcopenshell::geom::settings::value_variant_t {
pythonizing_visitor vis;
$result = std::visit(vis, $1);
}
@@ -134,33 +126,33 @@ CREATE_VECTOR_TYPEMAP_OUT(log_message)
%enddef
vector_of_item(ifcopenshell::geometry::taxonomy::item)
vector_of_item(ifcopenshell::geometry::taxonomy::boolean_result)
vector_of_item(ifcopenshell::geometry::taxonomy::bspline_curve)
vector_of_item(ifcopenshell::geometry::taxonomy::bspline_surface)
vector_of_item(ifcopenshell::geometry::taxonomy::circle)
vector_of_item(ifcopenshell::geometry::taxonomy::collection)
vector_of_item(ifcopenshell::geometry::taxonomy::colour)
vector_of_item(ifcopenshell::geometry::taxonomy::cylinder)
vector_of_item(ifcopenshell::geometry::taxonomy::direction3)
vector_of_item(ifcopenshell::geometry::taxonomy::edge)
vector_of_item(ifcopenshell::geometry::taxonomy::ellipse)
vector_of_item(ifcopenshell::geometry::taxonomy::extrusion)
vector_of_item(ifcopenshell::geometry::taxonomy::face)
vector_of_item(ifcopenshell::geometry::taxonomy::line)
vector_of_item(ifcopenshell::geometry::taxonomy::loft)
vector_of_item(ifcopenshell::geometry::taxonomy::loop)
vector_of_item(ifcopenshell::geometry::taxonomy::matrix4)
vector_of_item(ifcopenshell::geometry::taxonomy::node)
vector_of_item(ifcopenshell::geometry::taxonomy::offset_curve)
vector_of_item(ifcopenshell::geometry::taxonomy::piecewise_function)
vector_of_item(ifcopenshell::geometry::taxonomy::plane)
vector_of_item(ifcopenshell::geometry::taxonomy::point3)
vector_of_item(ifcopenshell::geometry::taxonomy::revolve)
vector_of_item(ifcopenshell::geometry::taxonomy::shell)
vector_of_item(ifcopenshell::geometry::taxonomy::solid)
vector_of_item(ifcopenshell::geometry::taxonomy::sphere)
vector_of_item(ifcopenshell::geometry::taxonomy::torus)
vector_of_item(ifcopenshell::geometry::taxonomy::style)
vector_of_item(ifcopenshell::geometry::taxonomy::sweep_along_curve)
vector_of_item(ifcopenshell::geometry::taxonomy::geom_item)
vector_of_item(ifcopenshell::geom::taxonomy::item)
vector_of_item(ifcopenshell::geom::taxonomy::boolean_result)
vector_of_item(ifcopenshell::geom::taxonomy::bspline_curve)
vector_of_item(ifcopenshell::geom::taxonomy::bspline_surface)
vector_of_item(ifcopenshell::geom::taxonomy::circle)
vector_of_item(ifcopenshell::geom::taxonomy::collection)
vector_of_item(ifcopenshell::geom::taxonomy::colour)
vector_of_item(ifcopenshell::geom::taxonomy::cylinder)
vector_of_item(ifcopenshell::geom::taxonomy::direction3)
vector_of_item(ifcopenshell::geom::taxonomy::edge)
vector_of_item(ifcopenshell::geom::taxonomy::ellipse)
vector_of_item(ifcopenshell::geom::taxonomy::extrusion)
vector_of_item(ifcopenshell::geom::taxonomy::face)
vector_of_item(ifcopenshell::geom::taxonomy::line)
vector_of_item(ifcopenshell::geom::taxonomy::loft)
vector_of_item(ifcopenshell::geom::taxonomy::loop)
vector_of_item(ifcopenshell::geom::taxonomy::matrix4)
vector_of_item(ifcopenshell::geom::taxonomy::node)
vector_of_item(ifcopenshell::geom::taxonomy::offset_curve)
vector_of_item(ifcopenshell::geom::taxonomy::piecewise_function)
vector_of_item(ifcopenshell::geom::taxonomy::plane)
vector_of_item(ifcopenshell::geom::taxonomy::point3)
vector_of_item(ifcopenshell::geom::taxonomy::revolve)
vector_of_item(ifcopenshell::geom::taxonomy::shell)
vector_of_item(ifcopenshell::geom::taxonomy::solid)
vector_of_item(ifcopenshell::geom::taxonomy::sphere)
vector_of_item(ifcopenshell::geom::taxonomy::torus)
vector_of_item(ifcopenshell::geom::taxonomy::style)
vector_of_item(ifcopenshell::geom::taxonomy::sweep_along_curve)
vector_of_item(ifcopenshell::geom::taxonomy::geom_item)