diff --git a/python/collision-geometries.cc b/python/collision-geometries.cc index 1b442aecc15fad8cd01f9d88c4ca5961c248c424..230cb7b178fda76c9c65e2ac8e0684dbcc5fa932 100644 --- a/python/collision-geometries.cc +++ b/python/collision-geometries.cc @@ -47,18 +47,15 @@ using namespace hpp::fcl; using boost::shared_ptr; using boost::noncopyable; -template <typename BV> -struct BVHModelWrapper +struct BVHModelBaseWrapper { - typedef BVHModel<BV> BVHModel_t; - - static Vec3f vertices (const BVHModel_t& bvh, int i) + static Vec3f vertices (const BVHModelBase& bvh, int i) { if (i >= bvh.num_vertices) throw std::out_of_range("index is out of range"); return bvh.vertices[i]; } - static Triangle tri_indices (const BVHModel_t& bvh, int i) + static Triangle tri_indices (const BVHModelBase& bvh, int i) { if (i >= bvh.num_tris) throw std::out_of_range("index is out of range"); return bvh.tri_indices[i]; @@ -69,19 +66,10 @@ template <typename BV> void exposeBVHModel (const std::string& bvname) { typedef BVHModel<BV> BVHModel_t; - typedef BVHModelWrapper<BV> Wrapper_t; std::string type = "BVHModel" + bvname; - class_ <BVHModel_t, bases<CollisionGeometry>, shared_ptr<BVHModel_t> > + class_ <BVHModel_t, bases<BVHModelBase>, shared_ptr<BVHModel_t> > (type.c_str(), init<>()) - .def ("vertices", &Wrapper_t::vertices) - .def ("tri_indices", &Wrapper_t::tri_indices) - .def_readonly ("num_vertices", &BVHModel_t::num_vertices) - .def_readonly ("num_tris", &BVHModel_t::num_tris) - - .def_readonly ("convex", &BVHModel_t::convex) - - .def ("buildConvexRepresentation", &BVHModel_t::buildConvexRepresentation) ; } @@ -236,6 +224,17 @@ void exposeCollisionGeometries () exposeShapes(); + class_ <BVHModelBase, bases<CollisionGeometry>, BVHModelPtr_t, noncopyable> + ("BVHModelBase", no_init) + .def ("vertices", &BVHModelBaseWrapper::vertices) + .def ("tri_indices", &BVHModelBaseWrapper::tri_indices) + .def_readonly ("num_vertices", &BVHModelBase::num_vertices) + .def_readonly ("num_tris", &BVHModelBase::num_tris) + + .def_readonly ("convex", &BVHModelBase::convex) + + .def ("buildConvexRepresentation", &BVHModelBase::buildConvexRepresentation) + ; exposeBVHModel<OBB >("OBB" ); exposeBVHModel<OBBRSS >("OBBRSS" ); } diff --git a/python/fcl.cc b/python/fcl.cc index 6d43a499be47b5d7971e082c602d3d9e8750567f..6769235d9d3cf3b53ecca7df00561e04dd7d436f 100644 --- a/python/fcl.cc +++ b/python/fcl.cc @@ -53,7 +53,7 @@ using boost::noncopyable; void exposeMeshLoader () { class_ <MeshLoader> ("MeshLoader", init< optional< NODE_TYPE> >()) - .def ("load", static_cast <CollisionGeometryPtr_t (MeshLoader::*) (const std::string&, const Vec3f&)> (&MeshLoader::load)) + .def ("load", static_cast <BVHModelPtr_t (MeshLoader::*) (const std::string&, const Vec3f&)> (&MeshLoader::load)) ; class_ <CachedMeshLoader, bases<MeshLoader> > ("CachedMeshLoader", init< optional< NODE_TYPE> >())