Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
containers
include
pcl
gpu
containers
impl
repacks.hpp
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Copyright (c) 2011, Willow Garage, Inc.
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
9
* are met:
10
*
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* * Redistributions in binary form must reproduce the above
14
* copyright notice, this list of conditions and the following
15
* disclaimer in the documentation and/or other materials provided
16
* with the distribution.
17
* * Neither the name of Willow Garage, Inc. nor the names of its
18
* contributors may be used to endorse or promote products derived
19
* from this software without specific prior written permission.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
* POSSIBILITY OF SUCH DAMAGE.
33
*
34
* Author: Anatoly Baskeheev, Itseez Ltd, (myname.mysurname@mycompany.com)
35
*/
36
37
#ifndef __PCL_GPU_UTILS_REPACKS_HPP__
38
#define __PCL_GPU_UTILS_REPACKS_HPP__
39
40
#include <pcl/gpu/containers/device_array.h>
41
#include <
pcl/pcl_macros.h
>
42
#include <
pcl/point_types.h
>
43
44
namespace
pcl
{
45
namespace
gpu
{
46
///////////////////////////////////////
47
/// This is an experimental code ///
48
///////////////////////////////////////
49
50
const
int
NoCP
= 0xFFFFFFFF;
51
52
/** \brief Returns field copy operation code. */
53
inline
int
54
cp
(
int
from,
int
to)
55
{
56
return
((to & 0xF) << 4) + (from & 0xF);
57
}
58
59
/* Combines several field copy operations to one int (called rule) */
60
inline
int
61
rule
(
int
cp1,
int
cp2 =
NoCP
,
int
cp3 =
NoCP
,
int
cp4 =
NoCP
)
62
{
63
return
(cp1 & 0xFF) + ((cp2 & 0xFF) << 8) + ((cp3 & 0xFF) << 16) +
64
((cp4 & 0xFF) << 24);
65
}
66
67
/* Combines performs all field copy operations in given rule array (can be 0, 1, or 16
68
* copies) */
69
void
70
copyFieldsImpl
(
71
int
in_size,
int
out_size,
int
rules[4],
int
size,
const
void
* input,
void
* output);
72
73
template
<
typename
Po
int
In,
typename
Po
int
Out>
74
void
75
copyFieldsEx
(
const
DeviceArray<PointIn>
& src,
76
DeviceArray<PointOut>
& dst,
77
int
rule1,
78
int
rule2 =
NoCP
,
79
int
rule3 =
NoCP
,
80
int
rule4 =
NoCP
)
81
{
82
int
rules[4] = {rule1, rule2, rule3, rule4};
83
dst.
create
(src.
size
());
84
copyFieldsImpl
(
sizeof
(PointIn) /
sizeof
(
int
),
85
sizeof
(PointOut) /
sizeof
(
int
),
86
rules,
87
(
int
)src.
size
(),
88
src.
ptr
(),
89
dst.
ptr
());
90
}
91
92
void
93
copyFields
(
const
DeviceArray<PointXYZ>
& src,
DeviceArray<PointNormal>
& dst)
94
{
95
// PointXYZ.x (0) -> PointNormal.x (0)
96
// PointXYZ.y (1) -> PointNormal.y (1)
97
// PointXYZ.z (2) -> PointNormal.z (2)
98
copyFieldsEx
(src, dst,
rule
(
cp
(0, 0),
cp
(1, 1),
cp
(2, 2)));
99
};
100
101
void
102
copyFields
(
const
DeviceArray<Normal>
& src,
DeviceArray<PointNormal>
& dst)
103
{
104
// PointXYZ.normal_x (0) -> PointNormal.normal_x (4)
105
// PointXYZ.normal_y (1) -> PointNormal.normal_y (5)
106
// PointXYZ.normal_z (2) -> PointNormal.normal_z (6)
107
// PointXYZ.curvature (4) -> PointNormal.curvature (8)
108
copyFieldsEx
(src, dst,
rule
(
cp
(0, 4),
cp
(1, 5),
cp
(2, 6),
cp
(4, 8)));
109
};
110
111
void
112
copyFields
(
const
DeviceArray<PointXYZRGBL>
& src,
DeviceArray<PointXYZ>
& dst)
113
{
114
// PointXYZRGBL.x (0) -> PointXYZ.x (0)
115
// PointXYZRGBL.y (1) -> PointXYZ.y (1)
116
// PointXYZRGBL.z (2) -> PointXYZ.z (2)
117
copyFieldsEx
(src, dst,
rule
(
cp
(0, 0),
cp
(1, 1),
cp
(2, 2)));
118
};
119
120
void
121
copyFields
(
const
DeviceArray<PointXYZRGB>
& src,
DeviceArray<PointXYZ>
& dst)
122
{
123
// PointXYZRGB.x (0) -> PointXYZ.x (0)
124
// PointXYZRGB.y (1) -> PointXYZ.y (1)
125
// PointXYZRGB.z (2) -> PointXYZ.z (2)
126
copyFieldsEx
(src, dst,
rule
(
cp
(0, 0),
cp
(1, 1),
cp
(2, 2)));
127
};
128
129
void
130
copyFields
(
const
DeviceArray<PointXYZRGBA>
& src,
DeviceArray<PointXYZ>
& dst)
131
{
132
// PointXYZRGBA.x (0) -> PointXYZ.x (0)
133
// PointXYZRGBA.y (1) -> PointXYZ.y (1)
134
// PointXYZRGBA.z (2) -> PointXYZ.z (2)
135
copyFieldsEx
(src, dst,
rule
(
cp
(0, 0),
cp
(1, 1),
cp
(2, 2)));
136
};
137
138
void
139
copyFieldsZ
(
const
DeviceArray<PointXYZ>
& src,
DeviceArray<float>
& dst)
140
{
141
// PointXYZRGBL.z (2) -> float (1)
142
copyFieldsEx
(src, dst,
rule
(
cp
(2, 0)));
143
};
144
145
void
146
copyFieldsZ
(
const
DeviceArray<PointXYZRGB>
& src,
DeviceArray<float>
& dst)
147
{
148
// PointXYZRGBL.z (2) -> float (1)
149
copyFieldsEx
(src, dst,
rule
(
cp
(2, 0)));
150
};
151
}
// namespace gpu
152
}
// namespace pcl
153
154
#endif
/* __PCL_GPU_UTILS_REPACKS_HPP__ */
pcl::gpu::DeviceArray
DeviceArray class
Definition
device_array.h:54
pcl::gpu::DeviceArray::size
std::size_t size() const
Returns size in elements.
Definition
device_array.hpp:149
pcl::gpu::DeviceArray::create
void create(std::size_t size)
Allocates internal buffer in GPU memory.
Definition
device_array.hpp:73
pcl::gpu::DeviceArray::ptr
T * ptr()
Returns pointer for internal buffer in GPU memory.
Definition
device_array.hpp:156
point_types.h
Defines all the PCL implemented PointT point type structures.
pcl::gpu
Definition
device_array.h:45
pcl::gpu::copyFieldsEx
void copyFieldsEx(const DeviceArray< PointIn > &src, DeviceArray< PointOut > &dst, int rule1, int rule2=NoCP, int rule3=NoCP, int rule4=NoCP)
Definition
repacks.hpp:75
pcl::gpu::cp
int cp(int from, int to)
Returns field copy operation code.
Definition
repacks.hpp:54
pcl::gpu::rule
int rule(int cp1, int cp2=NoCP, int cp3=NoCP, int cp4=NoCP)
Definition
repacks.hpp:61
pcl::gpu::copyFieldsZ
void copyFieldsZ(const DeviceArray< PointXYZ > &src, DeviceArray< float > &dst)
Definition
repacks.hpp:139
pcl::gpu::NoCP
const int NoCP
This is an experimental code ///.
Definition
repacks.hpp:50
pcl::gpu::copyFields
void copyFields(const DeviceArray< PointXYZ > &src, DeviceArray< PointNormal > &dst)
Definition
repacks.hpp:93
pcl::gpu::copyFieldsImpl
void copyFieldsImpl(int in_size, int out_size, int rules[4], int size, const void *input, void *output)
pcl
Definition
convolution.h:46
pcl_macros.h
Defines all the PCL and non-PCL macros used.