You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.4 KiB
69 lines
2.4 KiB
3 years ago
|
From 6900f7cf650e6c0df2aef45e0011833905b0ba9e Mon Sep 17 00:00:00 2001
|
||
|
From: Markus Vieth <39675748+mvieth@users.noreply.github.com>
|
||
|
Date: Fri, 6 Nov 2020 19:13:16 +0100
|
||
|
Subject: [PATCH] Change conversions of Vertices for new PCL versions (#313)
|
||
|
|
||
|
In https://github.com/PointCloudLibrary/pcl/commit/ad00c7bee2fad0391649479d90eee4461a2e74e7, the vertices field of pcl::Vertices changed from std::vector<std::uint32_t> to std::vector<pcl::index_t>, where index_t is an index type with configurable size (currently by default int). This commit makes conversions from and to pcl_msgs::Vertices possible again, moving the vector contents if possible.
|
||
|
---
|
||
|
.../include/pcl_conversions/pcl_conversions.h | 23 +++++++++++++++----
|
||
|
1 file changed, 19 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/pcl_conversions/include/pcl_conversions/pcl_conversions.h b/pcl_conversions/include/pcl_conversions/pcl_conversions.h
|
||
|
index a5671c25..5ac0a41a 100644
|
||
|
--- a/include/pcl_conversions/pcl_conversions.h
|
||
|
+++ b/include/pcl_conversions/pcl_conversions.h
|
||
|
@@ -350,10 +350,25 @@ namespace pcl_conversions {
|
||
|
|
||
|
/** pcl::Vertices <=> pcl_msgs::Vertices **/
|
||
|
|
||
|
+ namespace internal
|
||
|
+ {
|
||
|
+ template <class T>
|
||
|
+ inline void move(std::vector<T> &a, std::vector<T> &b)
|
||
|
+ {
|
||
|
+ b.swap(a);
|
||
|
+ }
|
||
|
+
|
||
|
+ template <class T1, class T2>
|
||
|
+ inline void move(std::vector<T1> &a, std::vector<T2> &b)
|
||
|
+ {
|
||
|
+ b.assign(a.cbegin(), a.cend());
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
inline
|
||
|
void fromPCL(const pcl::Vertices &pcl_vert, pcl_msgs::Vertices &vert)
|
||
|
{
|
||
|
- vert.vertices = pcl_vert.vertices;
|
||
|
+ vert.vertices.assign(pcl_vert.vertices.cbegin(), pcl_vert.vertices.cend());
|
||
|
}
|
||
|
|
||
|
inline
|
||
|
@@ -370,7 +385,7 @@ namespace pcl_conversions {
|
||
|
inline
|
||
|
void moveFromPCL(pcl::Vertices &pcl_vert, pcl_msgs::Vertices &vert)
|
||
|
{
|
||
|
- vert.vertices.swap(pcl_vert.vertices);
|
||
|
+ internal::move(pcl_vert.vertices, vert.vertices);
|
||
|
}
|
||
|
|
||
|
inline
|
||
|
@@ -387,7 +402,7 @@ namespace pcl_conversions {
|
||
|
inline
|
||
|
void toPCL(const pcl_msgs::Vertices &vert, pcl::Vertices &pcl_vert)
|
||
|
{
|
||
|
- pcl_vert.vertices = vert.vertices;
|
||
|
+ pcl_vert.vertices.assign(vert.vertices.cbegin(), vert.vertices.cend());
|
||
|
}
|
||
|
|
||
|
inline
|
||
|
@@ -404,7 +419,7 @@ namespace pcl_conversions {
|
||
|
inline
|
||
|
void moveToPCL(pcl_msgs::Vertices &vert, pcl::Vertices &pcl_vert)
|
||
|
{
|
||
|
- pcl_vert.vertices.swap(vert.vertices);
|
||
|
+ internal::move(vert.vertices, pcl_vert.vertices);
|
||
|
}
|
||
|
|
||
|
inline
|