diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index cf39c9e1cfe1bc002783de4df87f37bdbdfea414..270080ff5fba46aa5dcd260be20af0046b1519a5 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -39,6 +39,7 @@ SET(LIBRARY_NAME hppfcl) INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}" ${PYTHON_INCLUDE_DIRS}) ADD_LIBRARY(${LIBRARY_NAME} SHARED + version.cc math.cc collision-geometries.cc collision.cc diff --git a/python/fcl.cc b/python/fcl.cc index 6769235d9d3cf3b53ecca7df00561e04dd7d436f..0aa4b104fb09dd6ff8a033237d409bd230483789 100644 --- a/python/fcl.cc +++ b/python/fcl.cc @@ -62,6 +62,7 @@ void exposeMeshLoader () BOOST_PYTHON_MODULE(hppfcl) { + exposeVersion(); exposeMaths(); exposeCollisionGeometries(); exposeMeshLoader(); diff --git a/python/fcl.hh b/python/fcl.hh index 258960ef54f9b99c0db1214cc31f8f071a32660e..f56b9d19ac5b479cfde2b25be9fc4e8ba492c951 100644 --- a/python/fcl.hh +++ b/python/fcl.hh @@ -1,9 +1,11 @@ -void exposeMaths (); +void exposeVersion(); -void exposeCollisionGeometries (); +void exposeMaths(); -void exposeMeshLoader (); +void exposeCollisionGeometries(); -void exposeCollisionAPI (); +void exposeMeshLoader(); -void exposeDistanceAPI (); +void exposeCollisionAPI(); + +void exposeDistanceAPI(); diff --git a/python/version.cc b/python/version.cc new file mode 100644 index 0000000000000000000000000000000000000000..0f70a18252c3ab817775eb9acb637ddb941a20c2 --- /dev/null +++ b/python/version.cc @@ -0,0 +1,41 @@ +// +// Copyright (c) 2019 CNRS +// + +#include "hpp/fcl/config.hh" +#include <boost/python.hpp> + +namespace bp = boost::python; + +inline bool checkVersionAtLeast(unsigned int major, + unsigned int minor, + unsigned int patch) +{ + return HPP_FCL_VERSION_AT_LEAST(major, minor, patch); +} + +inline bool checkVersionAtMost(unsigned int major, + unsigned int minor, + unsigned int patch) +{ + return HPP_FCL_VERSION_AT_MOST(major, minor, patch); +} + +void exposeVersion() +{ + // Define release numbers of the current hpp-fcl version. + bp::scope().attr("__version__") = HPP_FCL_VERSION; + bp::scope().attr("HPP_FCL_MAJOR_VERSION") = HPP_FCL_MAJOR_VERSION; + bp::scope().attr("HPP_FCL_MINOR_VERSION") = HPP_FCL_MINOR_VERSION; + bp::scope().attr("HPP_FCL_PATCH_VERSION") = HPP_FCL_PATCH_VERSION; + + bp::def("checkVersionAtLeast",&checkVersionAtLeast, + bp::args("major","minor","patch"), + "Checks if the current version of hpp-fcl is at least" + " the version provided by the input arguments."); + + bp::def("checkVersionAtMost",&checkVersionAtMost, + bp::args("major","minor","patch"), + "Checks if the current version of hpp-fcl is at most" + " the version provided by the input arguments."); +}