From 04ff6cbfe417534d0df3ec994e8e33223aa59c1d Mon Sep 17 00:00:00 2001 From: Francois Bonneau Date: Mon, 1 Jul 2024 19:35:40 +0200 Subject: [PATCH] fix(binding): add GenericMapping. --- bindings/python/src/model/model.cpp | 2 ++ .../src/model/representation/core/mapping.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/bindings/python/src/model/model.cpp b/bindings/python/src/model/model.cpp index df05b8fd0..7967db945 100644 --- a/bindings/python/src/model/model.cpp +++ b/bindings/python/src/model/model.cpp @@ -69,6 +69,7 @@ namespace geode void define_brep( pybind11::module& ); void define_section( pybind11::module& ); void define_copy_mapping( pybind11::module& ); + void define_generic_mapping( pybind11::module& ); void define_brep_builder( pybind11::module& ); void define_section_builder( pybind11::module& ); @@ -143,6 +144,7 @@ PYBIND11_MODULE( opengeode_py_model, module ) geode::define_brep( module ); geode::define_section( module ); geode::define_copy_mapping( module ); + geode::define_generic_mapping( module ); geode::define_brep_builder( module ); geode::define_section_builder( module ); diff --git a/bindings/python/src/model/representation/core/mapping.cpp b/bindings/python/src/model/representation/core/mapping.cpp index d4c19e72c..213b007d8 100644 --- a/bindings/python/src/model/representation/core/mapping.cpp +++ b/bindings/python/src/model/representation/core/mapping.cpp @@ -40,4 +40,17 @@ namespace geode &ModelCopyMapping::at ), pybind11::return_value_policy::reference ); } + void define_generic_mapping( pybind11::module& module ) + { + pybind11::class_< ModelGenericMapping >( module, "ModelGenericMapping" ) + .def( pybind11::init<>() ) + .def( pybind11::init( []( ModelGenericMapping& mapping ) { + return ModelGenericMapping{ std::move( mapping ) }; + } ) ) + .def( "at", + static_cast< ModelGenericMapping::Mapping& ( + ModelGenericMapping::*) ( const ComponentType& ) >( + &ModelGenericMapping::at ), + pybind11::return_value_policy::reference ); + } } // namespace geode