mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-18 11:20:21 +00:00
triangulation-type setting for non-triangulated polyhedral from iterator
This commit is contained in:
@@ -681,7 +681,17 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
||||
|
||||
%pythoncode %{
|
||||
# Hide the getters with read-only property implementations
|
||||
faces = property(faces)
|
||||
faces_tri = property(faces)
|
||||
polyhedral_faces_without_holes = property(polyhedral_faces_without_holes)
|
||||
polyhedral_faces_with_holes = property(polyhedral_faces_with_holes)
|
||||
def get_faces(self):
|
||||
if self.faces_tri:
|
||||
return self.faces_tri
|
||||
elif self.polyhedral_faces_without_holes:
|
||||
return self.polyhedral_faces_without_holes
|
||||
else:
|
||||
return self.polyhedral_faces_with_holes
|
||||
faces = property(get_faces)
|
||||
edges = property(edges)
|
||||
material_ids = property(material_ids)
|
||||
materials = property(materials)
|
||||
|
||||
@@ -56,24 +56,6 @@ private:
|
||||
%rename("add") addEntity;
|
||||
%rename("remove") removeEntity;
|
||||
|
||||
%{
|
||||
|
||||
template<typename T>
|
||||
struct is_std_vector : std::false_type {};
|
||||
template<typename T, typename Alloc>
|
||||
struct is_std_vector<std::vector<T, Alloc>> : std::true_type {};
|
||||
template<typename T>
|
||||
constexpr bool is_std_vector_v = is_std_vector<T>::value;
|
||||
|
||||
template<typename T>
|
||||
struct is_std_vector_vector : std::false_type {};
|
||||
template<typename T, typename Alloc, typename Alloc2>
|
||||
struct is_std_vector_vector<std::vector<std::vector<T, Alloc>, Alloc2>> : std::true_type {};
|
||||
template<typename T>
|
||||
constexpr bool is_std_vector_vector_v = is_std_vector_vector<T>::value;
|
||||
|
||||
%}
|
||||
|
||||
class attribute_value_derived {};
|
||||
%{
|
||||
class attribute_value_derived {};
|
||||
@@ -780,9 +762,7 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
|
||||
PyObject* convert_cpp_attribute_to_python(AttributeValue arg) {
|
||||
return arg.array_->apply_visitor([](auto& v){
|
||||
using U = std::decay_t<decltype(v)>;
|
||||
if constexpr (is_std_vector_vector_v<U>) {
|
||||
return pythonize_vector2(v);
|
||||
} else if constexpr (is_std_vector_v<U>) {
|
||||
if constexpr (is_std_vector_v<U>) {
|
||||
return pythonize_vector(v);
|
||||
} else if constexpr (std::is_same_v<U, EnumerationReference>) {
|
||||
return pythonize(std::string(v.value()));
|
||||
|
||||
@@ -148,6 +148,24 @@
|
||||
#endif
|
||||
%}
|
||||
|
||||
%{
|
||||
|
||||
template<typename T>
|
||||
struct is_std_vector : std::false_type {};
|
||||
template<typename T, typename Alloc>
|
||||
struct is_std_vector<std::vector<T, Alloc>> : std::true_type {};
|
||||
template<typename T>
|
||||
constexpr bool is_std_vector_v = is_std_vector<T>::value;
|
||||
|
||||
template<typename T>
|
||||
struct is_std_vector_vector : std::false_type {};
|
||||
template<typename T, typename Alloc, typename Alloc2>
|
||||
struct is_std_vector_vector<std::vector<std::vector<T, Alloc>, Alloc2>> : std::true_type {};
|
||||
template<typename T>
|
||||
constexpr bool is_std_vector_vector_v = is_std_vector_vector<T>::value;
|
||||
|
||||
%}
|
||||
|
||||
// Create docstrings for generated python code.
|
||||
%feature("autodoc", "1");
|
||||
|
||||
|
||||
@@ -189,21 +189,15 @@
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
PyObject* pythonize_vector(const std::vector<T>& v) {
|
||||
PyObject* pythonize_vector(const T& v) {
|
||||
const size_t size = v.size();
|
||||
PyObject* pyobj = PyTuple_New(size);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
PyTuple_SetItem(pyobj, i, pythonize(v[i]));
|
||||
}
|
||||
return pyobj;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
PyObject* pythonize_vector2(const std::vector< std::vector<T> >& v) {
|
||||
const size_t size = v.size();
|
||||
PyObject* pyobj = PyTuple_New(size);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
PyTuple_SetItem(pyobj, i, pythonize_vector(v[i]));
|
||||
if constexpr (is_std_vector_v<typename T::value_type>) {
|
||||
PyTuple_SetItem(pyobj, i, pythonize_vector(v[i]));
|
||||
} else {
|
||||
PyTuple_SetItem(pyobj, i, pythonize(v[i]));
|
||||
}
|
||||
}
|
||||
return pyobj;
|
||||
}
|
||||
|
||||
@@ -38,9 +38,7 @@
|
||||
try {
|
||||
$result = $1.array_->apply_visitor([](auto& v){
|
||||
using U = std::decay_t<decltype(v)>;
|
||||
if constexpr (is_std_vector_vector_v<U>) {
|
||||
return pythonize_vector2(v);
|
||||
} else if constexpr (is_std_vector_v<U>) {
|
||||
if constexpr (is_std_vector_v<U>) {
|
||||
return pythonize_vector(v);
|
||||
} else if constexpr (std::is_same_v<U, EnumerationReference>) {
|
||||
return pythonize(std::string(v.value()));
|
||||
@@ -70,10 +68,22 @@
|
||||
|
||||
%define CREATE_VECTOR_TYPEMAP_OUT(template_type)
|
||||
%typemap(out) std::vector<template_type> {
|
||||
$result = pythonize_vector<template_type>($1);
|
||||
$result = pythonize_vector<std::vector<template_type>>($1);
|
||||
}
|
||||
%typemap(out) const std::vector<template_type>& {
|
||||
$result = pythonize_vector<template_type>(*$1);
|
||||
$result = pythonize_vector<std::vector<template_type>>(*$1);
|
||||
}
|
||||
%typemap(out) std::vector<std::vector<template_type>> {
|
||||
$result = pythonize_vector<std::vector<std::vector<template_type>>>($1);
|
||||
}
|
||||
%typemap(out) const std::vector<std::vector<template_type>>& {
|
||||
$result = pythonize_vector<std::vector<std::vector<template_type>>>(*$1);
|
||||
}
|
||||
%typemap(out) std::vector<std::vector<std::vector<template_type>>> {
|
||||
$result = pythonize_vector<std::vector<std::vector<std::vector<template_type>>>>($1);
|
||||
}
|
||||
%typemap(out) const std::vector<std::vector<std::vector<template_type>>>& {
|
||||
$result = pythonize_vector<std::vector<std::vector<std::vector<template_type>>>>(*$1);
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
||||
Reference in New Issue
Block a user