Skip to content
Snippets Groups Projects
Commit 2c716202 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Add node type as attribute of MeshLoader.

parent a48e934b
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@
#include <boost/shared_ptr.hpp>
#include <hpp/fcl/fwd.hh>
#include <hpp/fcl/config.hh>
#include <hpp/fcl/math/vec_3f.h>
#include <hpp/fcl/collision_object.h>
......@@ -52,9 +53,23 @@ namespace fcl {
public:
virtual ~MeshLoader() {}
virtual CollisionGeometryPtr_t load (const std::string& filename,
/// \param bvType ignored
/// \deprecated Use MeshLoader::load(const std::string&, const Vec3f&)
CollisionGeometryPtr_t load (const std::string& filename,
const Vec3f& scale,
const NODE_TYPE& bvType);
const NODE_TYPE& bvType) HPP_FCL_DEPRECATED
{
(void) bvType;
return load (filename, scale);
}
virtual CollisionGeometryPtr_t load (const std::string& filename,
const Vec3f& scale);
MeshLoader (const NODE_TYPE& bvType = BV_OBBRSS) : bvType_ (bvType) {}
private:
const NODE_TYPE bvType_;
};
/// Class for building polyhedron from files with cache mechanism.
......@@ -66,17 +81,27 @@ namespace fcl {
public:
virtual ~CachedMeshLoader() {}
virtual CollisionGeometryPtr_t load (const std::string& filename,
CachedMeshLoader (const NODE_TYPE& bvType = BV_OBBRSS) : MeshLoader (bvType) {}
/// \param bvType ignored
/// \deprecated Use MeshLoader::load(const std::string&, const Vec3f&)
CollisionGeometryPtr_t load (const std::string& filename,
const Vec3f& scale,
const NODE_TYPE& bvType);
const NODE_TYPE& bvType) HPP_FCL_DEPRECATED
{
(void) bvType;
return load(filename, scale);
}
virtual CollisionGeometryPtr_t load (const std::string& filename,
const Vec3f& scale);
struct Key {
std::string filename;
Vec3f scale;
NODE_TYPE bvType;
Key (const std::string& f, const Vec3f& s, const NODE_TYPE& t)
: filename (f), scale (s), bvType (t) {}
Key (const std::string& f, const Vec3f& s)
: filename (f), scale (s) {}
bool operator< (const CachedMeshLoader::Key& b) const;
};
......
......@@ -45,8 +45,6 @@ namespace fcl {
bool CachedMeshLoader::Key::operator< (const CachedMeshLoader::Key& b) const
{
const CachedMeshLoader::Key& a = *this;
if (a.bvType < b.bvType) return true;
if (a.bvType > b.bvType) return false;
for (int i = 0; i < 3; ++i) {
if (a.scale[i] < b.scale[i]) return true;
else if (a.scale[i] > b.scale[i]) return false;
......@@ -63,10 +61,9 @@ namespace fcl {
}
CollisionGeometryPtr_t MeshLoader::load (const std::string& filename,
const Vec3f& scale,
const NODE_TYPE& bvType)
const Vec3f& scale)
{
switch (bvType) {
switch (bvType_) {
case BV_AABB : return _load <AABB > (filename, scale);
case BV_OBB : return _load <OBB > (filename, scale);
case BV_RSS : return _load <RSS > (filename, scale);
......@@ -81,13 +78,12 @@ namespace fcl {
}
CollisionGeometryPtr_t CachedMeshLoader::load (const std::string& filename,
const Vec3f& scale,
const NODE_TYPE& bvType)
const Vec3f& scale)
{
Key key (filename, scale, bvType);
Key key (filename, scale);
Cache_t::const_iterator _cached = cache_.find (key);
if (_cached == cache_.end()) {
CollisionGeometryPtr_t geom = MeshLoader::load (filename, scale, bvType);
CollisionGeometryPtr_t geom = MeshLoader::load (filename, scale);
cache_.insert (std::make_pair(key, geom));
return geom;
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment