1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
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
|