Point Cloud Library (PCL)
1.11.1-dev
octree
src
utils
priority_octree_iterator.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_OCTREE_PRIORITY_ITERATOR
38
#define PCL_GPU_OCTREE_PRIORITY_ITERATOR
39
40
namespace
pcl
41
{
42
namespace
device
43
{
44
struct
OctreePriorityIteratorDevice
45
{
46
int
level
;
47
int
node_idx
;
48
int
length
;
49
const
OctreeGlobalWithBox
&
octree
;
50
51
__device__ __forceinline__
OctreePriorityIteratorDevice
(
const
OctreeGlobalWithBox
& octree_arg) :
octree
(octree_arg)
52
{
53
node_idx
= 0;
54
level
= 0;
55
length
= 1;
56
}
57
58
__device__ __forceinline__
void
gotoNextLevel
(
int
first,
int
len)
59
{
60
node_idx
= first;
61
length
= len;
62
++
level
;
63
}
64
65
__device__ __forceinline__
int
operator*
()
const
66
{
67
return
node_idx
;
68
}
69
70
__device__ __forceinline__
void
operator++
()
71
{
72
#if 1
73
while
(
level
>= 0)
74
{
75
if
(
length
> 1)
76
{
77
length
--;
78
node_idx
++;
79
break
;
80
}
81
82
if
(
node_idx
== 0)
83
{
84
level
= -1;
85
return
;
86
}
87
88
node_idx
=
octree
.
parent
[
node_idx
];
89
--
level
;
90
if
(
node_idx
== 0)
91
{
92
level
= -1;
93
return
;
94
}
95
96
int
parent =
octree
.
nodes
[
octree
.
parent
[
node_idx
]];
97
int
parent_first = parent >> 8;
98
int
parent_len = __popc(parent & 0xFF);
99
100
int
pos =
node_idx
- parent_first;
101
102
length
= parent_len - pos;
103
}
104
#endif
105
}
106
107
};
108
}
109
}
110
111
#endif
/* PCL_GPU_OCTREE_PRIORITY_ITERATOR */
pcl
Definition:
convolution.h:46
pcl::device::OctreePriorityIteratorDevice::operator*
__device__ __forceinline__ int operator*() const
Definition:
priority_octree_iterator.hpp:65
pcl::device::OctreePriorityIteratorDevice
Definition:
priority_octree_iterator.hpp:44
pcl::device::OctreePriorityIteratorDevice::node_idx
int node_idx
Definition:
priority_octree_iterator.hpp:47
pcl::device::OctreeGlobal::nodes
int * nodes
Definition:
internal.hpp:50
pcl::device::OctreeGlobal::parent
int * parent
Definition:
internal.hpp:57
pcl::device::OctreePriorityIteratorDevice::octree
const OctreeGlobalWithBox & octree
Definition:
priority_octree_iterator.hpp:49
pcl::device::OctreePriorityIteratorDevice::gotoNextLevel
__device__ __forceinline__ void gotoNextLevel(int first, int len)
Definition:
priority_octree_iterator.hpp:58
pcl::device::OctreePriorityIteratorDevice::level
int level
Definition:
priority_octree_iterator.hpp:46
pcl::device::OctreePriorityIteratorDevice::OctreePriorityIteratorDevice
__device__ __forceinline__ OctreePriorityIteratorDevice(const OctreeGlobalWithBox &octree_arg)
Definition:
priority_octree_iterator.hpp:51
pcl::device::OctreePriorityIteratorDevice::operator++
__device__ __forceinline__ void operator++()
Definition:
priority_octree_iterator.hpp:70
pcl::device::OctreePriorityIteratorDevice::length
int length
Definition:
priority_octree_iterator.hpp:48
pcl::device::OctreeGlobalWithBox
Definition:
internal.hpp:62