From 06a01fd96fcbede6b3bf73a5d766f1d2b7f7bed4 Mon Sep 17 00:00:00 2001 From: Wim Haeck Date: Fri, 2 Apr 2021 14:58:08 -0600 Subject: [PATCH] Started adding python bindings for GNDS 1.9 standard components --- CMakeLists.txt | 2 + python/src/GNDStk.python.cpp | 20 ++++++++- python/src/v1.9/gpdc.python.cpp | 32 ++++++++++++++ python/src/v1.9/gpdc/Axis.python.cpp | 63 ++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 python/src/v1.9/gpdc.python.cpp create mode 100644 python/src/v1.9/gpdc/Axis.python.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e8731fb9..6db5fb813 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,8 @@ pybind11_add_module( GNDStk.python EXCLUDE_FROM_ALL python/src/GNDStk.python.cpp python/src/core/Node.python.cpp + python/src/v1.9/gpdc.python.cpp + python/src/v1.9/gpdc/Axis.python.cpp ) target_link_libraries( GNDStk.python PRIVATE GNDStk ) target_compile_options( GNDStk.python PRIVATE "-fPIC" ) diff --git a/python/src/GNDStk.python.cpp b/python/src/GNDStk.python.cpp index a93ce4d54..8c4fcd4ce 100644 --- a/python/src/GNDStk.python.cpp +++ b/python/src/GNDStk.python.cpp @@ -13,6 +13,12 @@ namespace core { void wrapNode( python::module& ); } +// v1.9 interface declarations +namespace v1_9 { + + void wrapGeneralPurposeDataContainers( python::module& ); +} + /** * @brief GNDStk python bindings * @@ -22,12 +28,22 @@ namespace core { PYBIND11_MODULE( GNDStk, module ) { // create the core submodule - python::module submodule = module.def_submodule( + python::module coremodule = module.def_submodule( "core", "core - GNDS core interface components" ); // wrap core components - core::wrapNode( submodule ); + core::wrapNode( coremodule ); + + // create the core submodule + python::module v1_9_module = module.def_submodule( + + "v1_9", + "v1.9 - GNDS v1.9 standard components" + ); + + // wrap GNDS v1.9 standard components + v1_9::wrapGeneralPurposeDataContainers( v1_9_module ); } diff --git a/python/src/v1.9/gpdc.python.cpp b/python/src/v1.9/gpdc.python.cpp new file mode 100644 index 000000000..a5ab891c8 --- /dev/null +++ b/python/src/v1.9/gpdc.python.cpp @@ -0,0 +1,32 @@ +// system includes +#include +#include + +// other includes + +// namespace aliases +namespace python = pybind11; + +// v1.9 interface declarations +namespace v1_9 { + +// gpdc declarations +namespace gpdc { + + void wrapAxis( python::module& ); +} + +void wrapGeneralPurposeDataContainers( python::module& module ) { + + // create the gpdc submodule + python::module submodule = module.def_submodule( + + "gpdc", + "v1.9 gpdc - GNDS general purpose data containers" + ); + + // wrap core components + gpdc::wrapAxis( submodule ); +} + +} // v1_9 namespace diff --git a/python/src/v1.9/gpdc/Axis.python.cpp b/python/src/v1.9/gpdc/Axis.python.cpp new file mode 100644 index 000000000..533cb29db --- /dev/null +++ b/python/src/v1.9/gpdc/Axis.python.cpp @@ -0,0 +1,63 @@ +// system includes +#include +#include + +// local includes +#include "GNDStk/v1.9/gpdc/Axis.hpp" + +// namespace aliases +namespace python = pybind11; + +namespace v1_9 { +namespace gpdc { + +void wrapAxis( python::module& module ) { + + // type aliases + using Component = njoy::GNDStk::v1_9::gpdc::Axis; + + // create the component + python::class_< Component > component( + + module, + "Axis", + "Container component - an axis with index, label and unit" + ); + + // wrap the component + component + .def( + + python::init< const std::optional&, + const std::optional&, + const std::optional& >(), + python::arg( "index" ), python::arg( "label" ), python::arg( "unit" ), + "Initialise the component\n\n" + "Arguments:\n" + " self the component\n" + " index the axis index\n" + " label the axis label\n" + " unit the axis unit" + ) + .def_property_readonly( + + "index", + &Component::index, + "The axis index" + ) + .def_property_readonly( + + "label", + &Component::label, + "The axis label" + ) + .def_property_readonly( + + "unit", + &Component::unit, + "The unit index" + ); +} + +} // namespace gpdc +} // namespace v1_9