Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Convex exposition #244

Merged
merged 2 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions python/collision-geometries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
using namespace boost::python;
using namespace hpp::fcl;
namespace dv = doxygen::visitor;
namespace bp = boost::python;

using boost::noncopyable;

Expand Down Expand Up @@ -122,11 +123,20 @@ void exposeBVHModel (const std::string& bvname)

struct ConvexBaseWrapper
{
static Vec3f points (const ConvexBase& convex, int i)
typedef Eigen::Matrix<double,Eigen::Dynamic,3,Eigen::RowMajor> RowMatrixX3;
typedef Eigen::Map<RowMatrixX3> MapRowMatrixX3;
typedef Eigen::Ref<RowMatrixX3> RefRowMatrixX3;

static Vec3f & point (const ConvexBase& convex, int i)
{
if (i >= convex.num_points) throw std::out_of_range("index is out of range");
return convex.points[i];
}

static RefRowMatrixX3 points (const ConvexBase& convex)
{
return MapRowMatrixX3(convex.points[0].data(),convex.num_points,3);
}

static list neighbors (const ConvexBase& convex, int i)
{
Expand Down Expand Up @@ -232,7 +242,18 @@ void exposeShapes ()
("ConvexBase", doxygen::class_doc<ConvexBase>(), no_init)
.DEF_RO_CLASS_ATTRIB (ConvexBase, center)
.DEF_RO_CLASS_ATTRIB (ConvexBase, num_points)
.def ("points", &ConvexBaseWrapper::points)
.def ("point", &ConvexBaseWrapper::point,
bp::args("self","index"),"Retrieve the point given by its index.",
bp::return_internal_reference<>())
.def ("points", &ConvexBaseWrapper::point,
bp::args("self","index"),"Retrieve the point given by its index.",
::hpp::fcl::python::deprecated_member< bp::return_internal_reference<> >())
.def ("points", &ConvexBaseWrapper::points,
bp::args("self"),"Retrieve all the points.",
bp::with_custodian_and_ward_postcall<0,1>())
// .add_property ("points",
// bp::make_function(&ConvexBaseWrapper::points,bp::with_custodian_and_ward_postcall<0,1>()),
// "Points of the convex.")
.def ("neighbors", &ConvexBaseWrapper::neighbors)
.def ("convexHull", &ConvexBaseWrapper::convexHull,
doxygen::member_func_doc(&ConvexBase::convexHull),
Expand Down Expand Up @@ -370,8 +391,6 @@ void exposeCollisionGeometries ()
;
}

namespace bp = boost::python;

class_<AABB>("AABB",
"A class describing the AABB collision structure, which is a box in 3D space determined by two diagonal points",
no_init)
Expand Down
5 changes: 4 additions & 1 deletion python/fcl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ void exposeMeshLoader ()

BOOST_PYTHON_MODULE(hppfcl)
{
boost::python::import("warnings");
namespace bp = boost::python;

PyImport_ImportModule("warnings");

exposeVersion();
exposeMaths();
exposeCollisionGeometries();
Expand Down