Naive implementation of loading chunked models in C++

This commit is contained in:
Dion Moult
2024-02-21 17:30:33 +11:00
parent 847f5ff4c8
commit 6065c0e2fc
3 changed files with 230 additions and 0 deletions
+45
View File
@@ -17,6 +17,11 @@
* *
********************************************************************************/
%{
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include "numpy/arrayobject.h"
%}
%begin %{
#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
/* https://github.com/swig/swig/issues/325 */
@@ -203,7 +208,47 @@
%include "IfcGeomWrapper.i"
%include "IfcParseWrapper.i"
%include "std_vector.i"
%include "numpy.i"
%init %{
import_array();
%}
namespace std {
%template(float_array_3) array<double, 3>;
%template(FloatVector) vector<float>;
%template(IntVector) std::vector<int>;
%template(DoubleVector) std::vector<double>;
%template(FloatVectorVector) std::vector<std::vector<float>>;
%template(H5ShapeVector) std::vector<IfcGeom::h5_shape>;
}
%extend IfcGeom::h5_shape {
PyObject* IfcGeom::h5_shape::get_verts() {
npy_intp dims[1] = { (npy_intp)$self->verts.size() };
PyObject* array = PyArray_SimpleNewFromData(1, dims, NPY_FLOAT, (void*)$self->verts.data());
PyArray_CLEARFLAGS((PyArrayObject*)array, NPY_ARRAY_WRITEABLE); // Make the array read-only
return array;
}
PyObject* get_faces() {
npy_intp dims[1] = { (npy_intp)$self->faces.size() };
PyObject* array = PyArray_SimpleNewFromData(1, dims, NPY_INT, (void*)$self->faces.data());
PyArray_CLEARFLAGS((PyArrayObject*)array, NPY_ARRAY_WRITEABLE); // Make the array read-only
return array;
}
PyObject* get_materials() {
npy_intp dims[1] = { (npy_intp)$self->materials.size() };
PyObject* array = PyArray_SimpleNewFromData(1, dims, NPY_INT, (void*)$self->materials.data());
PyArray_CLEARFLAGS((PyArrayObject*)array, NPY_ARRAY_WRITEABLE); // Make the array read-only
return array;
}
PyObject* get_material_ids() {
npy_intp dims[1] = { (npy_intp)$self->material_ids.size() };
PyObject* array = PyArray_SimpleNewFromData(1, dims, NPY_INT, (void*)$self->material_ids.data());
PyArray_CLEARFLAGS((PyArrayObject*)array, NPY_ARRAY_WRITEABLE); // Make the array read-only
return array;
}
}