mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Naive implementation of loading chunked models in C++
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user