Unverified Commit 097a23c7 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by GitHub
Browse files

Merge pull request #161 from jmirabel/devel

[Python] Bind functions to create BVHModel.
parents 28ca0e58 cae9fb73
......@@ -102,6 +102,13 @@ public:
static inline size_type size() { return 3; }
bool operator== (const Triangle& other) const
{
return vids[0] == other.vids[0]
&& vids[1] == other.vids[1]
&& vids[2] == other.vids[2];
}
private:
/// @brief indices for each vertex of triangle
index_type vids[3];
......
......@@ -320,8 +320,10 @@ namespace fcl
mutable Vec3f cached_guess;
};
#if __cplusplus < 201103L
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wc99-extensions"
#endif
/// \name Shape intersection specializations
/// \{
......@@ -439,7 +441,9 @@ namespace fcl
#undef HPP_FCL_DECLARE_SHAPE_DISTANCE_PAIR
/// \}
#if __cplusplus < 201103L
#pragma GCC diagnostic pop
#endif
}
} // namespace hpp
......
......@@ -97,6 +97,7 @@ void exposeBVHModel (const std::string& bvname)
class_ <BVHModel_t, bases<BVHModelBase>, shared_ptr<BVHModel_t> >
(type.c_str(), doxygen::class_doc<BVHModel_t>(), no_init)
.def (dv::init<BVHModel_t>())
.def (dv::init<BVHModel_t, BVHModel_t>())
;
}
......@@ -359,6 +360,9 @@ void exposeCollisionGeometries ()
exposeShapes();
typedef std::vector<Vec3f> Vec3fs;
typedef std::vector<Triangle> Triangles;
class_ <BVHModelBase, bases<CollisionGeometry>, BVHModelPtr_t, noncopyable>
("BVHModelBase", no_init)
.def ("vertices", &BVHModelBaseWrapper::vertices,
......@@ -371,6 +375,20 @@ void exposeCollisionGeometries ()
.def_readonly ("convex", &BVHModelBase::convex)
.def ("buildConvexRepresentation", &BVHModelBase::buildConvexRepresentation)
// Expose function to build a BVH
.def(dv::member_func("beginModel", &BVHModelBase::beginModel))
.def(dv::member_func("addVertex", &BVHModelBase::addVertex))
.def(dv::member_func("addTriangle", &BVHModelBase::addTriangle))
.def(dv::member_func<int (BVHModelBase::*)(const Vec3fs&, const Triangles&)>("addSubModel", &BVHModelBase::addSubModel))
.def(dv::member_func<int (BVHModelBase::*)(const Vec3fs& )>("addSubModel", &BVHModelBase::addSubModel))
.def(dv::member_func("endModel", &BVHModelBase::endModel))
// Expose function to replace a BVH
.def(dv::member_func("beginReplaceModel", &BVHModelBase::beginReplaceModel))
.def(dv::member_func("replaceVertex", &BVHModelBase::replaceVertex))
.def(dv::member_func("replaceTriangle", &BVHModelBase::replaceTriangle))
.def(dv::member_func("replaceSubModel", &BVHModelBase::replaceSubModel))
.def(dv::member_func("endReplaceModel", &BVHModelBase::endReplaceModel))
;
exposeBVHModel<OBB >("OBB" );
exposeBVHModel<OBBRSS >("OBBRSS" );
......
......@@ -56,7 +56,10 @@
using namespace hpp::fcl;
namespace dv = doxygen::visitor;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(load_overloads,MeshLoader::load,1,2)
#pragma GCC diagnostic pop
void exposeMeshLoader ()
{
......
......@@ -33,6 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE.
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <eigenpy/eigenpy.hpp>
#include <eigenpy/geometry.hpp>
......@@ -116,4 +117,17 @@ void exposeMaths ()
.def ("__getitem__", &TriangleWrapper::getitem)
.def ("__setitem__", &TriangleWrapper::setitem)
;
if(!eigenpy::register_symbolic_link_to_registered_type< std::vector<Vec3f> >())
{
class_< std::vector<Vec3f> >("StdVec_Vec3f")
.def(vector_indexing_suite< std::vector<Vec3f> >())
;
}
if(!eigenpy::register_symbolic_link_to_registered_type< std::vector<Triangle> >())
{
class_< std::vector<Triangle> >("StdVec_Triangle")
.def(vector_indexing_suite< std::vector<Triangle> >())
;
}
}
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