Unverified Commit b85128ec authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #243 from jcarpent/devel

Fix exposition of vertices
parents b3490b3b f2a8cf8d
Pipeline #16071 passed with stage
in 37 minutes and 48 seconds
Subproject commit 9078d521dc23fabae72e3fe8d7c0068c68364eef Subproject commit ee7a773c5c23f83dd21eb0ccfa96277e068b0456
...@@ -42,6 +42,7 @@ SET(LIBRARY_NAME hppfcl) ...@@ -42,6 +42,7 @@ SET(LIBRARY_NAME hppfcl)
SET(${LIBRARY_NAME}_HEADERS SET(${LIBRARY_NAME}_HEADERS
fcl.hh fcl.hh
deprecation.hh
) )
SET(ENABLE_PYTHON_DOXYGEN_AUTODOC TRUE CACHE BOOL "Enable automatic documentation of Python bindings from Doxygen documentation") SET(ENABLE_PYTHON_DOXYGEN_AUTODOC TRUE CACHE BOOL "Enable automatic documentation of Python bindings from Doxygen documentation")
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <eigenpy/eigen-to-python.hpp> #include <eigenpy/eigen-to-python.hpp>
#include "fcl.hh" #include "fcl.hh"
#include "deprecation.hh"
#include <hpp/fcl/fwd.hh> #include <hpp/fcl/fwd.hh>
#include <hpp/fcl/shape/geometric_shapes.h> #include <hpp/fcl/shape/geometric_shapes.h>
...@@ -82,7 +83,7 @@ struct BVHModelBaseWrapper ...@@ -82,7 +83,7 @@ struct BVHModelBaseWrapper
typedef Eigen::Map<RowMatrixX3> MapRowMatrixX3; typedef Eigen::Map<RowMatrixX3> MapRowMatrixX3;
typedef Eigen::Ref<RowMatrixX3> RefRowMatrixX3; typedef Eigen::Ref<RowMatrixX3> RefRowMatrixX3;
static Vec3f & vertice (BVHModelBase & bvh, int i) static Vec3f & vertex (BVHModelBase & bvh, int i)
{ {
if (i >= bvh.num_vertices) throw std::out_of_range("index is out of range"); if (i >= bvh.num_vertices) throw std::out_of_range("index is out of range");
return bvh.vertices[i]; return bvh.vertices[i];
...@@ -471,12 +472,18 @@ void exposeCollisionGeometries () ...@@ -471,12 +472,18 @@ void exposeCollisionGeometries ()
class_ <BVHModelBase, bases<CollisionGeometry>, BVHModelPtr_t, noncopyable> class_ <BVHModelBase, bases<CollisionGeometry>, BVHModelPtr_t, noncopyable>
("BVHModelBase", no_init) ("BVHModelBase", no_init)
.def ("vertice", &BVHModelBaseWrapper::vertice, .def ("vertex", &BVHModelBaseWrapper::vertex,
bp::args("self","index"),"Retrieve the vertex given by its index.", bp::args("self","index"),"Retrieve the vertex given by its index.",
bp::return_internal_reference<>()) bp::return_internal_reference<>())
.def ("vertices", &BVHModelBaseWrapper::vertex,
bp::args("self","index"),"Retrieve the vertex given by its index.",
::hpp::fcl::python::deprecated_member< bp::return_internal_reference<> >())
.def ("vertices", &BVHModelBaseWrapper::vertices, .def ("vertices", &BVHModelBaseWrapper::vertices,
bp::args("self"),"Retrieve the vertex given by its index.", bp::args("self"),"Retrieve all the vertices.",
bp::with_custodian_and_ward_postcall<0,1>()) bp::with_custodian_and_ward_postcall<0,1>())
// .add_property ("vertices",
// bp::make_function(&BVHModelBaseWrapper::vertices,bp::with_custodian_and_ward_postcall<0,1>()),
// "Vertices of the BVH.")
.def ("tri_indices", &BVHModelBaseWrapper::tri_indices, .def ("tri_indices", &BVHModelBaseWrapper::tri_indices,
bp::args("self","index"),"Retrieve the triangle given by its index.") bp::args("self","index"),"Retrieve the triangle given by its index.")
.def_readonly ("num_vertices", &BVHModelBase::num_vertices) .def_readonly ("num_vertices", &BVHModelBase::num_vertices)
......
//
// Copyright (c) 2020-2021 INRIA
//
#ifndef HPP_FCL_PYTHON_UTILS_DEPRECATION_H
#define HPP_FCL_PYTHON_UTILS_DEPRECATION_H
#include <Python.h>
#include <boost/python.hpp>
#include <string>
namespace hpp {
namespace fcl {
namespace python {
template<class Policy = boost::python::default_call_policies>
struct deprecated_warning_policy : Policy
{
deprecated_warning_policy(const std::string & warning_message = "")
: Policy()
, m_warning_message(warning_message)
{}
template <class ArgumentPackage>
bool precall(ArgumentPackage const & args) const
{
PyErr_WarnEx(PyExc_UserWarning,m_warning_message.c_str(),1);
return static_cast<const Policy*>(this)->precall(args);
}
typedef typename Policy::result_converter result_converter;
typedef typename Policy::argument_package argument_package;
protected:
const std::string m_warning_message;
};
template<class Policy = boost::python::default_call_policies>
struct deprecated_member : deprecated_warning_policy<Policy>
{
deprecated_member(const std::string & warning_message
= "This class member has been marked as deprecated and will be removed in a future release.")
: deprecated_warning_policy<Policy>(warning_message)
{}
};
template<class Policy = boost::python::default_call_policies>
struct deprecated_function : deprecated_warning_policy<Policy>
{
deprecated_function(const std::string & warning_message
= "This function has been marked as deprecated and will be removed in a future release.")
: deprecated_warning_policy<Policy>(warning_message)
{}
};
}
}
}
#endif // ifndef HPP_FCL_PYTHON_UTILS_DEPRECATION_H
...@@ -89,6 +89,7 @@ void exposeMeshLoader () ...@@ -89,6 +89,7 @@ void exposeMeshLoader ()
BOOST_PYTHON_MODULE(hppfcl) BOOST_PYTHON_MODULE(hppfcl)
{ {
boost::python::import("warnings");
exposeVersion(); exposeVersion();
exposeMaths(); exposeMaths();
exposeCollisionGeometries(); exposeCollisionGeometries();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment