mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-17 10:59:17 +00:00
Last minute refactoring
This commit is contained in:
+340
-351
File diff suppressed because it is too large
Load Diff
@@ -51,13 +51,13 @@
|
||||
%ignore ifcopenshell::instance_streamer<ifcopenshell::file_reader<ifcopenshell::full_buffer_impl>>::read_instance;
|
||||
%ignore ifcopenshell::instance_streamer<ifcopenshell::file_reader<ifcopenshell::full_buffer_impl>>::steal_instances;
|
||||
|
||||
%ignore express::Entity;
|
||||
%ignore express::Select;
|
||||
%ignore express::DeclaredType;
|
||||
%ignore express::entity;
|
||||
%ignore express::select;
|
||||
%ignore express::declared_type;
|
||||
|
||||
// operator< takes a reference, so SWIG's auto __lt__ crashes on None.
|
||||
// entity_instance_mixin already has a safe __lt__; let it inherit through.
|
||||
%ignore express::Base::operator<;
|
||||
%ignore express::base::operator<;
|
||||
|
||||
%ignore in_memory_file_storage;
|
||||
%ignore rocks_db_file_storage;
|
||||
@@ -93,17 +93,17 @@
|
||||
|
||||
%ignore ifcopenshell::file::type_iterator;
|
||||
|
||||
%ignore express::Base::is;
|
||||
%ignore express::Base::operator==;
|
||||
%ignore express::Base::operator!=;
|
||||
%ignore express::Base::Base(std::nullopt_t);
|
||||
%ignore express::base::is;
|
||||
%ignore express::base::operator==;
|
||||
%ignore express::base::operator!=;
|
||||
%ignore express::base::base(std::nullopt_t);
|
||||
|
||||
%rename("by_id") instance_by_id;
|
||||
%rename("by_guid") instance_by_guid;
|
||||
%rename("_by_type") instances_by_type;
|
||||
%rename("_by_type_excl_subtypes") instances_by_type_excl_subtypes;
|
||||
%rename("get_inverses_by_declaration") get_inverse;
|
||||
%rename("entity_instance") express::Base;
|
||||
%rename("entity_instance") express::base;
|
||||
%rename("file") file;
|
||||
// _add() because mixin defined add which adds transaction logic
|
||||
%rename("_add") add_entity;
|
||||
@@ -191,7 +191,7 @@ static const std::string& helper_fn_declaration_get_name(const ifcopenshell::dec
|
||||
return decl->name();
|
||||
}
|
||||
|
||||
static ifcopenshell::argument_type helper_fn_attribute_type(const express::Base* instp, unsigned i) {
|
||||
static ifcopenshell::argument_type helper_fn_attribute_type(const express::base* instp, unsigned i) {
|
||||
const auto& inst = *instp;
|
||||
const ifcopenshell::parameter_type* pt = 0;
|
||||
if (inst.declaration().as_entity()) {
|
||||
@@ -295,22 +295,22 @@ private:
|
||||
return new ifcopenshell::file(ifcopenshell::uninitialized_tag{}, logger_or_root(logger));
|
||||
}
|
||||
|
||||
std::vector<express::Base> _get_inverse(const express::Base& e) {
|
||||
if (auto e_ = e.as<express::Entity>()) {
|
||||
return cast_vector<express::Base>($self->get_inverse(e_.id(), 0, -1));
|
||||
std::vector<express::base> _get_inverse(const express::base& e) {
|
||||
if (auto e_ = e.as<express::entity>()) {
|
||||
return cast_vector<express::base>($self->get_inverse(e_.id(), 0, -1));
|
||||
}
|
||||
throw ifcopenshell::exception("Only entities with ids are supported for get_inverse. Provided entity: '" + e.declaration().name() + "'.");
|
||||
}
|
||||
|
||||
std::vector<int> _get_inverse_indices(const express::Base& e) {
|
||||
if (auto e_ = e.as<express::Entity>()) {
|
||||
std::vector<int> _get_inverse_indices(const express::base& e) {
|
||||
if (auto e_ = e.as<express::entity>()) {
|
||||
return $self->get_inverse_indices_by_id(e_.id());
|
||||
}
|
||||
throw ifcopenshell::exception("Only entities with ids are supported for get_inverse_indices. Provided entity: '" + e.declaration().name() + "'.");
|
||||
}
|
||||
|
||||
int get_total_inverses(const express::Base& e) {
|
||||
if (auto e_ = e.as<express::Entity>()) {
|
||||
int get_total_inverses(const express::base& e) {
|
||||
if (auto e_ = e.as<express::entity>()) {
|
||||
return $self->get_inverse_indices_by_id(e_.id()).size();
|
||||
}
|
||||
throw ifcopenshell::exception("Only entities with ids are supported for get_total_inverses. Provided entity: '" + e.declaration().name() + "'.");
|
||||
@@ -329,7 +329,7 @@ private:
|
||||
return s.str();
|
||||
}
|
||||
|
||||
express::Base create(const std::string& entity_name, int id=-1) {
|
||||
express::base create(const std::string& entity_name, int id=-1) {
|
||||
const ifcopenshell::declaration* decl = $self->schema()->declaration_by_name(entity_name);
|
||||
if (!decl || !(decl->as_entity() || decl->as_type_declaration())) {
|
||||
throw ifcopenshell::exception("No such entity or type declaration: '" + entity_name + "' in schema '" + $self->schema()->name());
|
||||
@@ -433,7 +433,7 @@ private:
|
||||
%}
|
||||
}
|
||||
|
||||
%extend express::Base {
|
||||
%extend express::base {
|
||||
|
||||
// 0 = not found
|
||||
// 1 = regular forward attribute
|
||||
@@ -478,8 +478,8 @@ private:
|
||||
// to expose it to the Python wrapper it is simply duplicated here.
|
||||
// Same applies to the two methods reimplemented below.
|
||||
int id() const {
|
||||
return $self->as<express::Base>() != nullptr
|
||||
? $self->as<express::Base>()->id()
|
||||
return $self->as<express::base>() != nullptr
|
||||
? $self->as<express::base>()->id()
|
||||
: 0;
|
||||
}
|
||||
*/
|
||||
@@ -583,9 +583,9 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<express::Base> _get_inverse(const std::string& a) {
|
||||
std::vector<express::base> _get_inverse(const std::string& a) {
|
||||
if ($self->declaration().as_entity()) {
|
||||
return cast_vector<express::Base>($self->as<express::Entity>().get_inverse(a));
|
||||
return cast_vector<express::base>($self->as<express::entity>().get_inverse(a));
|
||||
} else {
|
||||
throw ifcopenshell::exception(a + " not found on " + $self->declaration().name());
|
||||
}
|
||||
@@ -596,7 +596,15 @@ private:
|
||||
}
|
||||
|
||||
const char* const attribute_type(const std::string& name) const {
|
||||
return ifcopenshell::argument_type_to_string(helper_fn_attribute_type($self, express_Base_get_argument_index($self, name)));
|
||||
unsigned int index;
|
||||
if ($self->declaration().as_entity()) {
|
||||
index = $self->declaration().as_entity()->attribute_index(name);
|
||||
} else if (name == "wrappedValue") {
|
||||
index = 0;
|
||||
} else {
|
||||
throw ifcopenshell::exception(name + " not found on " + $self->declaration().name());
|
||||
}
|
||||
return ifcopenshell::argument_type_to_string(helper_fn_attribute_type($self, index));
|
||||
}
|
||||
|
||||
const std::string& attribute_name(unsigned int i) const {
|
||||
@@ -734,35 +742,35 @@ private:
|
||||
return out;
|
||||
};
|
||||
|
||||
auto to_base = [&](PyObject* o) -> express::Base {
|
||||
auto to_base = [&](PyObject* o) -> express::base {
|
||||
void* vp = nullptr;
|
||||
|
||||
// Try non-const pointer first
|
||||
if (swig_type_info* ti = SWIG_TypeQuery("express::Base *")) {
|
||||
if (swig_type_info* ti = SWIG_TypeQuery("express::base *")) {
|
||||
int res = SWIG_ConvertPtr(o, &vp, ti, 0);
|
||||
if (res >= 0 && vp) {
|
||||
return *static_cast<express::Base*>(vp);
|
||||
return *static_cast<express::base*>(vp);
|
||||
}
|
||||
}
|
||||
|
||||
// Then try const pointer
|
||||
vp = nullptr;
|
||||
if (swig_type_info* ti = SWIG_TypeQuery("express::Base const *")) {
|
||||
if (swig_type_info* ti = SWIG_TypeQuery("express::base const *")) {
|
||||
int res = SWIG_ConvertPtr(o, &vp, ti, 0);
|
||||
if (res >= 0 && vp) {
|
||||
return *static_cast<const express::Base*>(vp);
|
||||
return *static_cast<const express::base*>(vp);
|
||||
}
|
||||
}
|
||||
|
||||
throw ifcopenshell::exception("Attribute not set");
|
||||
};
|
||||
|
||||
auto to_vec_base = [&](PyObject* o) -> std::vector<express::Base> {
|
||||
auto to_vec_base = [&](PyObject* o) -> std::vector<express::base> {
|
||||
PyObject* fast = seq_fast(o);
|
||||
Py_ssize_t n = PySequence_Fast_GET_SIZE(fast);
|
||||
PyObject** items = PySequence_Fast_ITEMS(fast);
|
||||
|
||||
std::vector<express::Base> out;
|
||||
std::vector<express::base> out;
|
||||
out.reserve(static_cast<size_t>(n));
|
||||
for (Py_ssize_t k = 0; k < n; ++k) {
|
||||
out.push_back(to_base(items[k]));
|
||||
@@ -802,12 +810,12 @@ private:
|
||||
return out;
|
||||
};
|
||||
|
||||
auto to_vec_vec_base = [&](PyObject* o) -> std::vector<std::vector<express::Base>> {
|
||||
auto to_vec_vec_base = [&](PyObject* o) -> std::vector<std::vector<express::base>> {
|
||||
PyObject* fast = seq_fast(o);
|
||||
Py_ssize_t n = PySequence_Fast_GET_SIZE(fast);
|
||||
PyObject** items = PySequence_Fast_ITEMS(fast);
|
||||
|
||||
std::vector<std::vector<express::Base>> out;
|
||||
std::vector<std::vector<express::base>> out;
|
||||
out.reserve(static_cast<size_t>(n));
|
||||
for (Py_ssize_t k = 0; k < n; ++k) {
|
||||
out.push_back(to_vec_base(items[k]));
|
||||
@@ -936,13 +944,13 @@ private:
|
||||
%extend ifcopenshell::spf_header {
|
||||
// Upcast to header instances for SWIG, because
|
||||
// it has no idea about the schema definitions.
|
||||
express::Base file_description_py() {
|
||||
express::base file_description_py() {
|
||||
return $self->file_description();
|
||||
}
|
||||
express::Base file_name_py() {
|
||||
express::base file_name_py() {
|
||||
return $self->file_name();
|
||||
}
|
||||
express::Base file_schema_py() {
|
||||
express::base file_schema_py() {
|
||||
return $self->file_schema();
|
||||
}
|
||||
|
||||
@@ -969,7 +977,7 @@ from .file import file_mixin as file_mixin
|
||||
%pythoncode %{
|
||||
from .entity_instance import entity_instance_mixin
|
||||
%}
|
||||
%feature("python:abc", "entity_instance_mixin") express::Base;
|
||||
%feature("python:abc", "entity_instance_mixin") express::base;
|
||||
|
||||
%include "../ifcparse/express.h"
|
||||
|
||||
@@ -1011,7 +1019,7 @@ from .entity_instance import entity_instance_mixin
|
||||
return IFCOPENSHELL_VERSION;
|
||||
}
|
||||
|
||||
express::Base new_IfcBaseClass(ifcopenshell::file& file, const std::string& name) {
|
||||
express::base new_IfcBaseClass(ifcopenshell::file& file, const std::string& name) {
|
||||
return file.create(file.schema()->declaration_by_name(name));
|
||||
}
|
||||
%}
|
||||
@@ -1171,29 +1179,29 @@ from .entity_instance import entity_instance_mixin
|
||||
%}
|
||||
|
||||
%{
|
||||
PyObject* get_info_cpp(const express::Base& v, bool recursive, bool include_identifier);
|
||||
PyObject* get_info_cpp(const express::base& v, bool recursive, bool include_identifier);
|
||||
|
||||
// @todo refactor this to remove duplication with the typemap.
|
||||
// except this is calls the above function in case of instances.
|
||||
PyObject* convert_cpp_attribute_to_python(const express::Base& instance, size_t attribute_index, bool recursive, bool include_identifier) {
|
||||
PyObject* convert_cpp_attribute_to_python(const express::base& instance, size_t attribute_index, bool recursive, bool include_identifier) {
|
||||
return instance.get_attribute_value(attribute_index).apply_visitor([recursive, include_identifier](const auto& v){
|
||||
using U = std::decay_t<decltype(v)>;
|
||||
if constexpr (std::is_same_v<U, enumeration_reference>) {
|
||||
using u = std::decay_t<decltype(v)>;
|
||||
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, express::Base>) {
|
||||
} else if constexpr (std::is_same_v<u, express::base>) {
|
||||
if (recursive) {
|
||||
return get_info_cpp(v, recursive, include_identifier);
|
||||
} else {
|
||||
return pythonize(v);
|
||||
}
|
||||
} else if constexpr (std::is_same_v<U, std::vector<express::Base>>) {
|
||||
} else if constexpr (std::is_same_v<u, std::vector<express::base>>) {
|
||||
if (recursive) {
|
||||
PyObject* t = PyTuple_New(v.size());
|
||||
for (size_t i = 0; i < v.size(); ++i) {
|
||||
@@ -1204,7 +1212,7 @@ from .entity_instance import entity_instance_mixin
|
||||
} else {
|
||||
return pythonize_vector(v);
|
||||
}
|
||||
} else if constexpr (std::is_same_v<U, std::vector<std::vector<express::Base>>>) {
|
||||
} else if constexpr (std::is_same_v<u, std::vector<std::vector<express::base>>>) {
|
||||
if (recursive) {
|
||||
PyObject* outer = PyTuple_New(v.size());
|
||||
for (size_t i = 0; i < v.size(); ++i) {
|
||||
@@ -1220,10 +1228,10 @@ from .entity_instance import entity_instance_mixin
|
||||
} else {
|
||||
return pythonize_vector(v);
|
||||
}
|
||||
} 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>) {
|
||||
} 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 (is_std_vector_v<U>) {
|
||||
} else if constexpr (is_std_vector_v<u>) {
|
||||
// only for non-entity-instance vectors
|
||||
return pythonize_vector(v);
|
||||
} else {
|
||||
@@ -1233,7 +1241,7 @@ from .entity_instance import entity_instance_mixin
|
||||
}
|
||||
%}
|
||||
%inline %{
|
||||
PyObject* get_info_cpp(const express::Base& v, bool recursive, bool include_identifier) {
|
||||
PyObject* get_info_cpp(const express::base& v, bool recursive, bool include_identifier) {
|
||||
PyObject *d = PyDict_New();
|
||||
|
||||
if (v.declaration().as_entity()) {
|
||||
@@ -1273,24 +1281,24 @@ from .entity_instance import entity_instance_mixin
|
||||
|
||||
%extend ifcopenshell::instance_streamer<ifcopenshell::file_reader<ifcopenshell::full_buffer_impl>> {
|
||||
PyObject* read_instance_py(bool type_as_declaration_instance=false) {
|
||||
auto simply_type_to_dictionary = [&](const express::Base& t) -> PyObject* {
|
||||
auto simply_type_to_dictionary = [&](const express::base& t) -> PyObject* {
|
||||
const auto& nm = t.declaration().name();
|
||||
auto ifc_val = t.get_attribute_value(0);
|
||||
auto attribute_val_py = ifc_val.apply_visitor([&](const auto& t) {
|
||||
using U = std::decay_t<decltype(t)>;
|
||||
using u = std::decay_t<decltype(t)>;
|
||||
|
||||
if constexpr (is_std_vector_v<U>) {
|
||||
if constexpr (is_std_vector_v<u>) {
|
||||
return pythonize_vector(t);
|
||||
} else if constexpr (std::is_same_v<U, enumeration_reference>) {
|
||||
} else if constexpr (std::is_same_v<u, enumeration_reference>) {
|
||||
return pythonize(std::string(t.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>) {
|
||||
} 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 {
|
||||
@@ -1370,25 +1378,23 @@ from .entity_instance import entity_instance_mixin
|
||||
|
||||
// sets dict member, returns void
|
||||
val.apply_visitor([&](const auto& t) -> void {
|
||||
using T = std::decay_t<decltype(t)>;
|
||||
using value_type = std::decay_t<decltype(t)>;
|
||||
PyObject* attribute_val_py;
|
||||
if constexpr (std::is_same_v<T, express::Base>) {
|
||||
if constexpr (std::is_same_v<value_type, express::base>) {
|
||||
attribute_val_py = simply_type_to_dictionary(t);
|
||||
} else {
|
||||
using U = std::decay_t<decltype(t)>;
|
||||
|
||||
if constexpr (is_std_vector_v<U>) {
|
||||
if constexpr (is_std_vector_v<value_type>) {
|
||||
attribute_val_py = pythonize_vector(t);
|
||||
} else if constexpr (std::is_same_v<U, enumeration_reference>) {
|
||||
} else if constexpr (std::is_same_v<value_type, enumeration_reference>) {
|
||||
attribute_val_py = pythonize(std::string(t.value()));
|
||||
} else if constexpr (std::is_same_v<U, derived>) {
|
||||
} else if constexpr (std::is_same_v<value_type, derived>) {
|
||||
if (feature_use_attribute_value_derived) {
|
||||
attribute_val_py = SWIG_NewPointerObj(new attribute_value_derived, SWIGTYPE_p_attribute_value_derived, SWIG_POINTER_OWN);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
attribute_val_py = 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>) {
|
||||
} else if constexpr (std::is_same_v<value_type, empty_aggregate_t> || std::is_same_v<value_type, empty_aggregate_of_aggregate_t> || std::is_same_v<value_type, blank>) {
|
||||
Py_INCREF(Py_None);
|
||||
attribute_val_py = static_cast<PyObject*>(Py_None);
|
||||
} else {
|
||||
@@ -1411,32 +1417,32 @@ from .entity_instance import entity_instance_mixin
|
||||
|
||||
std::visit([&](const auto& v) -> void {
|
||||
PyObject* attribute_val_py = nullptr;
|
||||
using T = std::decay_t<decltype(v)>;
|
||||
using t = std::decay_t<decltype(v)>;
|
||||
|
||||
if constexpr (std::is_same_v<T, ifcopenshell::reference_or_simple_type>) {
|
||||
if (auto* inst = std::get_if<express::Base>(&v)) {
|
||||
if constexpr (std::is_same_v<t, ifcopenshell::reference_or_simple_type>) {
|
||||
if (auto* inst = std::get_if<express::base>(&v)) {
|
||||
// So this never happens?
|
||||
} else if (auto* name = std::get_if<ifcopenshell::instance_reference>(&v)) {
|
||||
attribute_val_py = instance_reference_to_dict(*name);
|
||||
}
|
||||
} else if constexpr (std::is_same_v<T, std::vector<ifcopenshell::reference_or_simple_type>>) {
|
||||
} else if constexpr (std::is_same_v<t, std::vector<ifcopenshell::reference_or_simple_type>>) {
|
||||
attribute_val_py = PyTuple_New(v.size());
|
||||
size_t idx = 0;
|
||||
for (auto const& inner : v) {
|
||||
if (auto* inst = std::get_if<express::Base>(&inner)) {
|
||||
if (auto* inst = std::get_if<express::base>(&inner)) {
|
||||
PyTuple_SetItem(attribute_val_py, idx++, simply_type_to_dictionary(*inst));
|
||||
} else if (auto* name = std::get_if<ifcopenshell::instance_reference>(&inner)) {
|
||||
PyTuple_SetItem(attribute_val_py, idx++, instance_reference_to_dict(*name));
|
||||
}
|
||||
}
|
||||
} else if constexpr (std::is_same_v<T, std::vector<std::vector<ifcopenshell::reference_or_simple_type>>>) {
|
||||
} else if constexpr (std::is_same_v<t, std::vector<std::vector<ifcopenshell::reference_or_simple_type>>>) {
|
||||
attribute_val_py = PyTuple_New(v.size());
|
||||
size_t outer_idx = 0;
|
||||
for (auto const& inner : v) {
|
||||
PyObject* inner_py = PyTuple_New(inner.size());
|
||||
size_t idx = 0;
|
||||
for (auto const& innermost : inner) {
|
||||
if (auto* inst = std::get_if<express::Base>(&innermost)) {
|
||||
if (auto* inst = std::get_if<express::base>(&innermost)) {
|
||||
PyTuple_SetItem(inner_py, idx++, simply_type_to_dictionary(*inst));
|
||||
} else if (auto* name = std::get_if<ifcopenshell::instance_reference>(&innermost)) {
|
||||
PyTuple_SetItem(inner_py, idx++, instance_reference_to_dict(*name));
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
%}
|
||||
%template(DoubleArray3) std::array<double, 3>;
|
||||
|
||||
%ignore ifcopenshell::geometry::Converter;
|
||||
%ignore ifcopenshell::geom::converter;
|
||||
|
||||
// Not relevant for python: new_IfcBaseClass() calls instantiate()
|
||||
%ignore schema_definition::instantiate;
|
||||
@@ -75,8 +75,8 @@
|
||||
%ignore ifcopenshell::load_schema_plugins;
|
||||
|
||||
// Not relevant for python usage
|
||||
%ignore express::Base::data;
|
||||
%ignore express::Base::data_weak;
|
||||
%ignore express::base::data;
|
||||
%ignore express::base::data_weak;
|
||||
%ignore *::references_to_resolve;
|
||||
|
||||
// SVG serializer internal
|
||||
@@ -99,9 +99,9 @@
|
||||
%ignore curve_to_face_upgrade_impl;
|
||||
%ignore loop_to_function_item_upgrade_impl;
|
||||
|
||||
%ignore IfcGeom::geometry_exception;
|
||||
%ignore IfcGeom::too_many_faces_exception;
|
||||
%ignore ifcopenshell::geometry::taxonomy::topology_error;
|
||||
%ignore ifcopenshell::geom::geometry_exception;
|
||||
%ignore ifcopenshell::geom::too_many_faces_exception;
|
||||
%ignore ifcopenshell::geom::taxonomy::topology_error;
|
||||
|
||||
// settings, can this done more generally?
|
||||
// GeometrySerializer.h
|
||||
@@ -212,7 +212,7 @@
|
||||
%ignore guess_file_type;
|
||||
|
||||
// Triangulated representation helper struct
|
||||
%ignore EdgeKey;
|
||||
%ignore edge_key;
|
||||
|
||||
// General python-specific rename rules for comparison operators.
|
||||
// Mostly to silence warnings, but might be of use some time.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user