mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 10:51:13 +00:00
Use custom typemaps for geometry related classes as well
This commit is contained in:
@@ -66,12 +66,6 @@ namespace IfcUtil {
|
|||||||
%rename("entity_instance") IfcLateBoundEntity;
|
%rename("entity_instance") IfcLateBoundEntity;
|
||||||
%rename("file") IfcFile;
|
%rename("file") IfcFile;
|
||||||
|
|
||||||
%include "utils/type_conversion.i"
|
|
||||||
|
|
||||||
%include "utils/typemaps_in.i"
|
|
||||||
|
|
||||||
%include "utils/typemaps_out.i"
|
|
||||||
|
|
||||||
%extend IfcParse::IfcFile {
|
%extend IfcParse::IfcFile {
|
||||||
IfcParse::IfcLateBoundEntity* by_id(unsigned id) {
|
IfcParse::IfcLateBoundEntity* by_id(unsigned id) {
|
||||||
return (IfcParse::IfcLateBoundEntity*) $self->entityById(id);
|
return (IfcParse::IfcLateBoundEntity*) $self->entityById(id);
|
||||||
|
|||||||
+5
-41
@@ -17,7 +17,6 @@
|
|||||||
* *
|
* *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
%include "std_vector.i"
|
|
||||||
%include "std_string.i"
|
%include "std_string.i"
|
||||||
%include "exception.i"
|
%include "exception.i"
|
||||||
|
|
||||||
@@ -49,46 +48,11 @@
|
|||||||
#endif
|
#endif
|
||||||
%}
|
%}
|
||||||
|
|
||||||
// The following typemaps are an alternative for the read-only std::vector
|
%include "utils/type_conversion.i"
|
||||||
// implementations provided by SWIG, as passing STL objects across dynamic
|
|
||||||
// library boundaries can be problematic.
|
%include "utils/typemaps_in.i"
|
||||||
%typemap(out) std::pair<const float*, unsigned> {
|
|
||||||
$result = PyTuple_New($1.second);
|
%include "utils/typemaps_out.i"
|
||||||
for (unsigned i = 0; i < $1.second; ++i) {
|
|
||||||
PyTuple_SetItem($result, i, PyFloat_FromDouble($1.first[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%typemap(out) std::pair<const double*, unsigned> {
|
|
||||||
$result = PyTuple_New($1.second);
|
|
||||||
for (unsigned i = 0; i < $1.second; ++i) {
|
|
||||||
PyTuple_SetItem($result, i, PyFloat_FromDouble($1.first[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%typemap(out) std::pair<const int*, unsigned> {
|
|
||||||
$result = PyTuple_New($1.second);
|
|
||||||
for (unsigned i = 0; i < $1.second; ++i) {
|
|
||||||
PyTuple_SetItem($result, i, PyLong_FromLong($1.first[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%typemap(out) std::pair<const std::string*, unsigned> {
|
|
||||||
$result = PyTuple_New($1.second);
|
|
||||||
for (unsigned i = 0; i < $1.second; ++i) {
|
|
||||||
PyTuple_SetItem($result, i, PyUnicode_FromString($1.first[i]->c_str()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%typemap(out) std::pair<const IfcGeom::Material*, unsigned> {
|
|
||||||
$result = PyTuple_New($1.second);
|
|
||||||
for (unsigned i = 0; i < $1.second; ++i) {
|
|
||||||
PyTuple_SetItem($result, i, SWIG_NewPointerObj(SWIG_as_voidptr(&$1.first[i]), SWIGTYPE_p_IfcGeom__Material, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%typemap(out) std::vector<unsigned> {
|
|
||||||
$result = PyTuple_New($1.size());
|
|
||||||
unsigned i = 0;
|
|
||||||
for (std::vector<unsigned>::const_iterator it = $1.begin(); it != $1.end(); ++it) {
|
|
||||||
PyTuple_SetItem($result, i++, PyLong_FromLong(*it));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
%include "IfcGeomWrapper.i"
|
%include "IfcGeomWrapper.i"
|
||||||
%include "IfcParseWrapper.i"
|
%include "IfcParseWrapper.i"
|
||||||
|
|||||||
@@ -107,6 +107,7 @@
|
|||||||
// Conversion functions to convert STL vectors into Python objects
|
// Conversion functions to convert STL vectors into Python objects
|
||||||
%{
|
%{
|
||||||
PyObject* pythonize(const int& t) { return PyInt_FromLong(t); }
|
PyObject* pythonize(const int& t) { return PyInt_FromLong(t); }
|
||||||
|
PyObject* pythonize(const unsigned int& t) { return PyInt_FromLong(t); }
|
||||||
PyObject* pythonize(const bool& t) { return PyBool_FromLong(t); }
|
PyObject* pythonize(const bool& t) { return PyBool_FromLong(t); }
|
||||||
PyObject* pythonize(const double& t) { return PyFloat_FromDouble(t); }
|
PyObject* pythonize(const double& t) { return PyFloat_FromDouble(t); }
|
||||||
PyObject* pythonize(const std::string& t) { return PyString_FromString(t.c_str()); }
|
PyObject* pythonize(const std::string& t) { return PyString_FromString(t.c_str()); }
|
||||||
|
|||||||
@@ -97,10 +97,11 @@
|
|||||||
$result = pythonize_vector<template_type>($1);
|
$result = pythonize_vector<template_type>($1);
|
||||||
}
|
}
|
||||||
%typemap(out) const std::vector<template_type>& {
|
%typemap(out) const std::vector<template_type>& {
|
||||||
$result = pythonize_vector<template_type>($1);
|
$result = pythonize_vector<template_type>(*$1);
|
||||||
}
|
}
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
CREATE_VECTOR_TYPEMAP_OUT(int)
|
CREATE_VECTOR_TYPEMAP_OUT(int)
|
||||||
|
CREATE_VECTOR_TYPEMAP_OUT(unsigned int)
|
||||||
CREATE_VECTOR_TYPEMAP_OUT(double)
|
CREATE_VECTOR_TYPEMAP_OUT(double)
|
||||||
CREATE_VECTOR_TYPEMAP_OUT(std::string)
|
CREATE_VECTOR_TYPEMAP_OUT(std::string)
|
||||||
|
|||||||
Reference in New Issue
Block a user