Point Cloud Library (PCL)
1.12.1
Toggle main menu visibility
Loading...
Searching...
No Matches
utils
include
pcl
gpu
utils
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/pcl_macros.h
>
41
#include <
pcl/point_types.h
>
42
43
#include <pcl/gpu/containers/device_array.h>
44
45
namespace
pcl
46
{
47
namespace
gpu
48
{
49
///////////////////////////////////////
50
/// This is an experimental code ///
51
///////////////////////////////////////
52
53
const
int
NoCP
= 0xFFFFFFFF;
54
55
/** \brief Returns field copy operation code. */
56
inline
int
cp
(
int
from,
int
to)
57
{
58
return
((to & 0xF) << 4) + (from & 0xF);
59
}
60
61
/* Combines several field copy operations to one int (called rule) */
62
inline
int
rule
(
int
cp1,
int
cp2 =
NoCP
,
int
cp3 =
NoCP
,
int
cp4 =
NoCP
)
63
{
64
return
(cp1 & 0xFF) + ((cp2 & 0xFF) << 8) + ((cp3 & 0xFF) << 16) + ((cp4 & 0xFF) << 24);
65
}
66
67
/* Combines performs all field copy operations in given rule array (can be 0, 1, or 16 copies) */
68
void
copyFieldsImpl
(
int
in_size,
int
out_size,
int
rules[4],
int
size,
const
void
* input,
void
* output);
69
70
template
<
typename
Po
int
In,
typename
Po
int
Out>
71
void
copyFieldsEx
(
const
DeviceArray<PointIn>
& src,
DeviceArray<PointOut>
& dst,
int
rule1,
int
rule2 =
NoCP
,
int
rule3 =
NoCP
,
int
rule4 =
NoCP
)
72
{
73
int
rules[4] = { rule1, rule2, rule3, rule4 };
74
dst.
create
(src.
size
());
75
copyFieldsImpl
(
sizeof
(PointIn)/
sizeof
(
int
),
sizeof
(PointOut)/
sizeof
(
int
), rules, (
int
)src.
size
(), src.
ptr
(), dst.
ptr
());
76
}
77
78
void
copyFields
(
const
DeviceArray<PointXYZ>
& src,
DeviceArray<PointNormal>
& dst)
79
{
80
//PointXYZ.x (0) -> PointNormal.x (0)
81
//PointXYZ.y (1) -> PointNormal.y (1)
82
//PointXYZ.z (2) -> PointNormal.z (2)
83
copyFieldsEx
(src, dst,
rule
(
cp
(0, 0),
cp
(1, 1),
cp
(2, 2)));
84
};
85
86
void
copyFields
(
const
DeviceArray<Normal>
& src,
DeviceArray<PointNormal>
& dst)
87
{
88
//PointXYZ.normal_x (0) -> PointNormal.normal_x (4)
89
//PointXYZ.normal_y (1) -> PointNormal.normal_y (5)
90
//PointXYZ.normal_z (2) -> PointNormal.normal_z (6)
91
//PointXYZ.curvature (4) -> PointNormal.curvature (8)
92
copyFieldsEx
(src, dst,
rule
(
cp
(0, 4),
cp
(1, 5),
cp
(2, 6),
cp
(4,8)));
93
};
94
95
void
copyFields
(
const
DeviceArray<PointXYZRGBL>
& src,
DeviceArray<PointXYZ>
& dst)
96
{
97
//PointXYZRGBL.x (0) -> PointXYZ.x (0)
98
//PointXYZRGBL.y (1) -> PointXYZ.y (1)
99
//PointXYZRGBL.z (2) -> PointXYZ.z (2)
100
copyFieldsEx
(src, dst,
rule
(
cp
(0, 0),
cp
(1, 1),
cp
(2, 2)));
101
};
102
103
void
copyFields
(
const
DeviceArray<PointXYZRGB>
& src,
DeviceArray<PointXYZ>
& dst)
104
{
105
//PointXYZRGB.x (0) -> PointXYZ.x (0)
106
//PointXYZRGB.y (1) -> PointXYZ.y (1)
107
//PointXYZRGB.z (2) -> PointXYZ.z (2)
108
copyFieldsEx
(src, dst,
rule
(
cp
(0, 0),
cp
(1, 1),
cp
(2, 2)));
109
};
110
111
void
copyFields
(
const
DeviceArray<PointXYZRGBA>
& src,
DeviceArray<PointXYZ>
& dst)
112
{
113
//PointXYZRGBA.x (0) -> PointXYZ.x (0)
114
//PointXYZRGBA.y (1) -> PointXYZ.y (1)
115
//PointXYZRGBA.z (2) -> PointXYZ.z (2)
116
copyFieldsEx
(src, dst,
rule
(
cp
(0, 0),
cp
(1, 1),
cp
(2, 2)));
117
};
118
119
void
copyFieldsZ
(
const
DeviceArray<PointXYZ>
& src,
DeviceArray<float>
& dst)
120
{
121
//PointXYZRGBL.z (2) -> float (1)
122
copyFieldsEx
(src, dst,
rule
(
cp
(2, 0)));
123
};
124
125
void
copyFieldsZ
(
const
DeviceArray<PointXYZRGB>
& src,
DeviceArray<float>
& dst)
126
{
127
//PointXYZRGBL.z (2) -> float (1)
128
copyFieldsEx
(src, dst,
rule
(
cp
(2, 0)));
129
};
130
}
131
}
132
133
#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:71
pcl::gpu::cp
int cp(int from, int to)
Returns field copy operation code.
Definition
repacks.hpp:56
pcl::gpu::rule
int rule(int cp1, int cp2=NoCP, int cp3=NoCP, int cp4=NoCP)
Definition
repacks.hpp:62
pcl::gpu::copyFieldsZ
void copyFieldsZ(const DeviceArray< PointXYZ > &src, DeviceArray< float > &dst)
Definition
repacks.hpp:119
pcl::gpu::NoCP
const int NoCP
This is an experimental code ///.
Definition
repacks.hpp:53
pcl::gpu::copyFields
void copyFields(const DeviceArray< PointXYZ > &src, DeviceArray< PointNormal > &dst)
Definition
repacks.hpp:78
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.