From 3e0fbd7ac8a5d58e1818c43c1a0712dd6508ba2e Mon Sep 17 00:00:00 2001
From: Florent Lamiraux <florent@laas.fr>
Date: Tue, 18 Dec 2018 09:05:27 +0100
Subject: [PATCH] [CollisionGeometry] Reintroduce member cost_density.

  - This member is used to convert a octomap to a set of boxes.
---
 include/hpp/fcl/collision_object.h | 15 +++++++---
 src/CMakeLists.txt                 |  1 +
 src/collision_object.cpp           | 45 ++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 4 deletions(-)
 create mode 100644 src/collision_object.cpp

diff --git a/include/hpp/fcl/collision_object.h b/include/hpp/fcl/collision_object.h
index 9b20a22b..12ae18a2 100644
--- a/include/hpp/fcl/collision_object.h
+++ b/include/hpp/fcl/collision_object.h
@@ -58,7 +58,9 @@ enum NODE_TYPE {BV_UNKNOWN, BV_AABB, BV_OBB, BV_RSS, BV_kIOS, BV_OBBRSS, BV_KDOP
 class CollisionGeometry
 {
 public:
-  CollisionGeometry()
+  CollisionGeometry() : cost_density(1),
+                        threshold_occupied(1),
+                        threshold_free(0)
   {
   }
 
@@ -86,13 +88,15 @@ public:
   }
 
   /// @brief whether the object is completely occupied
-  inline bool isOccupied() const HPP_FCL_DEPRECATED { return true; }
+  inline bool isOccupied() const HPP_FCL_DEPRECATED
+  { return cost_density >= threshold_occupied; }
 
   /// @brief whether the object is completely free
-  inline bool isFree() const { return false; }
+  inline bool isFree() const HPP_FCL_DEPRECATED
+  { return cost_density <= threshold_free; }
 
   /// @brief whether the object has some uncertainty
-  inline bool isUncertain() const { return false; }
+  bool isUncertain() const HPP_FCL_DEPRECATED;
 
   /// @brief AABB center in local coordinate
   Vec3f aabb_center;
@@ -106,6 +110,9 @@ public:
   /// @brief pointer to user defined data specific to this object
   void *user_data;
 
+  /// @brief collision cost for unit volume
+  FCL_REAL cost_density;
+
   /// @brief threshold for occupied ( >= is occupied)
   FCL_REAL threshold_occupied;
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fb9bd5ef..fffa3787 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -38,6 +38,7 @@ set(${LIBRARY_NAME}_SOURCES
   distance_func_matrix.cpp
   collision_data.cpp
   collision_node.cpp
+  collision_object.cpp
   BV/RSS.cpp
   BV/AABB.cpp
   BV/kIOS.cpp
diff --git a/src/collision_object.cpp b/src/collision_object.cpp
new file mode 100644
index 00000000..9173483d
--- /dev/null
+++ b/src/collision_object.cpp
@@ -0,0 +1,45 @@
+/*
+ * Software License Agreement (BSD License)
+ *
+ *  Copyright (c) 2011-2014, Willow Garage, Inc.
+ *  Copyright (c) 2014-2015, Open Source Robotics Foundation
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *   * Neither the name of Open Source Robotics Foundation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** \author Florent Lamiraux */
+
+#include <hpp/fcl/collision_object.h>
+
+namespace fcl {
+  bool CollisionGeometry::isUncertain() const
+  {
+    return !isOccupied() && !isFree();
+  }
+} // namespace fcl
-- 
GitLab