From 508ecb8e0c550c9473a4e2ef69b87ea6da9271a4 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sun, 29 Mar 2020 05:46:03 +0900 Subject: [PATCH 1/5] index revolution begins --- common/include/pcl/PointIndices.h | 11 ++++++----- common/include/pcl/pcl_base.h | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common/include/pcl/PointIndices.h b/common/include/pcl/PointIndices.h index 031699f64bd..2d1273098d8 100644 --- a/common/include/pcl/PointIndices.h +++ b/common/include/pcl/PointIndices.h @@ -6,21 +6,22 @@ // Include the correct Header path here #include +#include namespace pcl { struct PointIndices { + using Indices = std::vector; + using Ptr = shared_ptr< ::pcl::PointIndices>; + using ConstPtr = shared_ptr; + PointIndices () {} ::pcl::PCLHeader header; - std::vector indices; - - public: - using Ptr = shared_ptr< ::pcl::PointIndices>; - using ConstPtr = shared_ptr; + Indices indices; }; // struct PointIndices using PointIndicesPtr = PointIndices::Ptr; diff --git a/common/include/pcl/pcl_base.h b/common/include/pcl/pcl_base.h index e1a51909606..63e7eaf65d6 100644 --- a/common/include/pcl/pcl_base.h +++ b/common/include/pcl/pcl_base.h @@ -54,11 +54,12 @@ #include #include #include +#include namespace pcl { // definitions used everywhere - using Indices = std::vector; + using Indices = PointIndices::Indices; using IndicesPtr = shared_ptr; using IndicesConstPtr = shared_ptr; From 72b5b04228bccc1cb9c175375124faed3ab0fae7 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sun, 29 Mar 2020 09:53:57 +0900 Subject: [PATCH 2/5] Adding debug assert --- common/include/pcl/types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/include/pcl/types.h b/common/include/pcl/types.h index c26e4c6033a..efefa9d99be 100644 --- a/common/include/pcl/types.h +++ b/common/include/pcl/types.h @@ -131,5 +131,6 @@ namespace pcl * Default index_t = int for PCL 1.11, std::int32_t for PCL >= 1.12 */ using index_t = detail::int_type_t; + static_assert(!std::is_void::value, "Index can't be void"); } // namespace pcl From 7fa2c879f688d08e217080f27f11f516e8489ae2 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sun, 29 Mar 2020 16:35:00 +0900 Subject: [PATCH 3/5] Found the error --- common/include/pcl/types.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/include/pcl/types.h b/common/include/pcl/types.h index efefa9d99be..8ca79681ec0 100644 --- a/common/include/pcl/types.h +++ b/common/include/pcl/types.h @@ -63,7 +63,8 @@ namespace pcl // Aim is to remove macros and instead allow multiple index types to coexist together #ifndef PCL_INDEX_SIZE #if PCL_MINOR_VERSION <= 11 -#define PCL_INDEX_SIZE sizeof(int) +// sizeof returns bytes, while we measure size by bits in the template +#define PCL_INDEX_SIZE (sizeof(int) * 8) #else #define PCL_INDEX_SIZE 32 #endif // PCL_MINOR_VERSION From 75482804e0eddb088a1462d3223810f9fdc0c606 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sun, 29 Mar 2020 22:49:41 +0900 Subject: [PATCH 4/5] Slightly better error message --- common/include/pcl/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/include/pcl/types.h b/common/include/pcl/types.h index 8ca79681ec0..7143de9114c 100644 --- a/common/include/pcl/types.h +++ b/common/include/pcl/types.h @@ -132,6 +132,6 @@ namespace pcl * Default index_t = int for PCL 1.11, std::int32_t for PCL >= 1.12 */ using index_t = detail::int_type_t; - static_assert(!std::is_void::value, "Index can't be void"); + static_assert(!std::is_void::value, "`index_t` can't have type `void`"); } // namespace pcl From e78e0bc32c3ab1a7506e516c192882eceba7370c Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Mon, 30 Mar 2020 01:34:20 +0900 Subject: [PATCH 5/5] Adding Indices to types.h instead --- common/include/pcl/PointIndices.h | 1 - common/include/pcl/pcl_base.h | 1 - common/include/pcl/types.h | 9 ++++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/common/include/pcl/PointIndices.h b/common/include/pcl/PointIndices.h index 2d1273098d8..2a648aa29ff 100644 --- a/common/include/pcl/PointIndices.h +++ b/common/include/pcl/PointIndices.h @@ -12,7 +12,6 @@ namespace pcl { struct PointIndices { - using Indices = std::vector; using Ptr = shared_ptr< ::pcl::PointIndices>; using ConstPtr = shared_ptr; diff --git a/common/include/pcl/pcl_base.h b/common/include/pcl/pcl_base.h index 63e7eaf65d6..fdf60116dc2 100644 --- a/common/include/pcl/pcl_base.h +++ b/common/include/pcl/pcl_base.h @@ -59,7 +59,6 @@ namespace pcl { // definitions used everywhere - using Indices = PointIndices::Indices; using IndicesPtr = shared_ptr; using IndicesConstPtr = shared_ptr; diff --git a/common/include/pcl/types.h b/common/include/pcl/types.h index 7143de9114c..5f83f73ff3a 100644 --- a/common/include/pcl/types.h +++ b/common/include/pcl/types.h @@ -45,6 +45,8 @@ #include +#include + #include namespace pcl @@ -127,11 +129,16 @@ namespace pcl } // namespace detail /** - * \brief Type used for indices in PCL + * \brief Type used for an index in PCL * * Default index_t = int for PCL 1.11, std::int32_t for PCL >= 1.12 */ using index_t = detail::int_type_t; static_assert(!std::is_void::value, "`index_t` can't have type `void`"); + + /** + * \brief Type used for indices in PCL + */ + using Indices = std::vector; } // namespace pcl