diff --git a/CMakeLists.txt b/CMakeLists.txt index c98f6819cd995d5fa2ed623d3cca06b75338e605..db7ab2491316a2019573c55967ec7046fa34bfa1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,11 @@ if (OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARY_DIRS) include_directories(${OCTOMAP_INCLUDE_DIRS}) link_directories(${OCTOMAP_LIBRARY_DIRS}) set(FCL_HAVE_OCTOMAP 1) + string(REPLACE "." ";" VERSION_LIST ${OCTOMAP_VERSION}) + list(GET VERSION_LIST 0 OCTOMAP_MAJOR_VERSION) + list(GET VERSION_LIST 1 OCTOMAP_MINOR_VERSION) + list(GET VERSION_LIST 2 OCTOMAP_PATCH_VERSION) + message(STATUS "FCL uses Octomap") else() message(STATUS "FCL does not use Octomap") diff --git a/include/hpp/fcl/math/vec_3f.h b/include/hpp/fcl/math/vec_3f.h index 4322ecdbeaae6771187c71fc438bec658f8a81d9..cdd6d770f1eb92c2fdb2876808e870e25535cea7 100644 --- a/include/hpp/fcl/math/vec_3f.h +++ b/include/hpp/fcl/math/vec_3f.h @@ -56,4 +56,20 @@ namespace fcl } +#if FCL_HAVE_OCTOMAP + #define OCTOMAP_MAJOR_VERSION @OCTOMAP_MAJOR_VERSION@ + #define OCTOMAP_MINOR_VERSION @OCTOMAP_MINOR_VERSION@ + #define OCTOMAP_PATCH_VERSION @OCTOMAP_PATCH_VERSION@ + + #define OCTOMAP_VERSION_AT_LEAST(x,y,z) \ + (OCTOMAP_MAJOR_VERSION > x || (OCTOMAP_MAJOR_VERSION >= x && \ + (OCTOMAP_MINOR_VERSION > y || (OCTOMAP_MINOR_VERSION >= y && \ + OCTOMAP_PATCH_VERSION >= z)))) + + #define OCTOMAP_VERSION_AT_MOST(x,y,z) \ + (OCTOMAP_MAJOR_VERSION < x || (OCTOMAP_MAJOR_VERSION <= x && \ + (OCTOMAP_MINOR_VERSION < y || (OCTOMAP_MINOR_VERSION <= y && \ + OCTOMAP_PATCH_VERSION <= z)))) +#endif // FCL_HAVE_OCTOMAP + #endif diff --git a/include/hpp/fcl/octree.h b/include/hpp/fcl/octree.h index 56b123bab1b13898380999ae3872115c82d267b7..86d3755a9f8c5e6fae0fa013f6917e65f2addb43 100644 --- a/include/hpp/fcl/octree.h +++ b/include/hpp/fcl/octree.h @@ -190,25 +190,41 @@ public: /// @return ptr to child number childIdx of node OcTreeNode* getNodeChild(OcTreeNode* node, unsigned int childIdx) { +#if OCTOMAP_VERSION_AT_LEAST(1,8,0) return tree->getNodeChild(node, childIdx); +#else + return node->getChild(childIdx); +#endif } /// @return const ptr to child number childIdx of node const OcTreeNode* getNodeChild(const OcTreeNode* node, unsigned int childIdx) const { +#if OCTOMAP_VERSION_AT_LEAST(1,8,0) return tree->getNodeChild(node, childIdx); +#else + return node->getChild(childIdx); +#endif } /// @brief return true if the child at childIdx exists bool nodeChildExists(const OcTreeNode* node, unsigned int childIdx) const { +#if OCTOMAP_VERSION_AT_LEAST(1,8,0) return tree->nodeChildExists(node, childIdx); +#else + return node->childExists(childIdx); +#endif } /// @brief return true if node has at least one child bool nodeHasChildren(const OcTreeNode* node) const { +#if OCTOMAP_VERSION_AT_LEAST(1,8,0) return tree->nodeHasChildren(node); +#else + return node->hasChildren(); +#endif } /// @brief return object type, it is an octree