Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
outofcore
octree_ram_container.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2010-2012, Willow Garage, Inc.
6
* Copyright (c) 2012, Urban Robotics, Inc.
7
*
8
* All rights reserved.
9
*
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions
12
* are met:
13
*
14
* * Redistributions of source code must retain the above copyright
15
* notice, this list of conditions and the following disclaimer.
16
* * Redistributions in binary form must reproduce the above
17
* copyright notice, this list of conditions and the following
18
* disclaimer in the documentation and/or other materials provided
19
* with the distribution.
20
* * Neither the name of Willow Garage, Inc. nor the names of its
21
* contributors may be used to endorse or promote products derived
22
* from this software without specific prior written permission.
23
*
24
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
* POSSIBILITY OF SUCH DAMAGE.
36
*
37
* $Id$
38
*/
39
40
#pragma once
41
42
// C++
43
#include <mutex>
44
#include <random>
45
46
#include <pcl/outofcore/octree_abstract_node_container.h>
47
48
namespace
pcl
49
{
50
namespace
outofcore
51
{
52
/** \class OutofcoreOctreeRamContainer
53
* \brief Storage container class which the outofcore octree base is templated against
54
* \note Code was adapted from the Urban Robotics out of core octree implementation.
55
* Contact Jacob Schloss <jacob.schloss@urbanrobotics.net> with any questions.
56
* http://www.urbanrobotics.net/
57
*
58
* \ingroup outofcore
59
* \author Jacob Schloss (jacob.scloss@urbanrobotics.net)
60
*/
61
template
<
typename
Po
int
T>
62
class
OutofcoreOctreeRamContainer
:
public
OutofcoreAbstractNodeContainer
<PointT>
63
{
64
public
:
65
using
AlignedPointTVector
=
typename
OutofcoreAbstractNodeContainer<PointT>::AlignedPointTVector
;
66
67
/** \brief empty constructor (with a path parameter?)
68
*/
69
OutofcoreOctreeRamContainer
(
const
boost::filesystem::path&) :
container_
() { }
70
71
/** \brief inserts count number of points into container; uses the container_ type's insert function
72
* \param[in] start - address of first point in array
73
* \param[in] count - the maximum offset from start of points inserted
74
*/
75
void
76
insertRange
(
const
PointT* start,
const
std::uint64_t count);
77
78
/** \brief inserts count points into container
79
* \param[in] start - address of first point in array
80
* \param[in] count - the maximum offset from start of points inserted
81
*/
82
void
83
insertRange
(
const
PointT*
const
* start,
const
std::uint64_t count);
84
85
void
86
insertRange
(
AlignedPointTVector
&
/*p*/
)
87
{
88
PCL_ERROR (
"[pcl::outofcore::OutofcoreOctreeRamContainer] Inserting eigen-aligned point vectors is not implemented using the ram containers\n"
);
89
//insertRange (&(p.begin ()), p.size ());
90
}
91
92
void
93
insertRange
(
const
AlignedPointTVector
&
/*p*/
)
94
{
95
PCL_ERROR (
"[pcl::outofcore::OutofcoreOctreeRamContainer] Inserting eigen-aligned point vectors is not implemented using the ram containers\n"
);
96
}
97
98
/** \brief
99
* \param[in] start Index of first point to return from container
100
* \param[in] count Offset (start + count) of the last point to return from container
101
* \param[out] v Array of points read from the input range
102
*/
103
void
104
readRange
(
const
std::uint64_t start,
const
std::uint64_t count,
AlignedPointTVector
&v);
105
106
/** \brief grab percent*count random points. points are NOT
107
* guaranteed to be unique (could have multiple identical points!)
108
*
109
* \param[in] start Index of first point in range to subsample
110
* \param[in] count Offset (start+count) of last point in range to subsample
111
* \param[in] percent Percentage of range to return
112
* \param[out] v Vector with percent*count uniformly random sampled
113
* points from given input rangerange
114
*/
115
void
116
readRangeSubSample
(
const
std::uint64_t start,
const
std::uint64_t count,
const
double
percent,
AlignedPointTVector
&v);
117
118
/** \brief returns the size of the vector of points stored in this class */
119
inline
std::uint64_t
120
size
()
const
121
{
122
return
container_
.size ();
123
}
124
125
inline
bool
126
empty
()
const
127
{
128
return
container_
.empty ();
129
}
130
131
132
/** \brief clears the vector of points in this class */
133
inline
void
134
clear
()
135
{
136
//clear the elements in the vector of points
137
container_
.clear ();
138
}
139
140
/** \brief Writes ascii x,y,z point data to path.string().c_str()
141
* \param path The path/filename destination of the ascii xyz data
142
*/
143
void
144
convertToXYZ
(
const
boost::filesystem::path &path);
145
146
inline
PointT
147
operator[]
(std::uint64_t index)
const
148
{
149
assert ( index <
container_
.size () );
150
return
(
container_
[index] );
151
}
152
153
154
protected
:
155
//no copy construction
156
OutofcoreOctreeRamContainer
(
const
OutofcoreOctreeRamContainer
&
/*rval*/
) { }
157
158
OutofcoreOctreeRamContainer
&
159
operator=
(
const
OutofcoreOctreeRamContainer
&
/*rval*/
) { }
160
161
//the actual container
162
//std::deque<PointT> container;
163
164
/** \brief linear container to hold the points */
165
AlignedPointTVector
container_
;
166
167
static
std::mutex
rng_mutex_
;
168
static
std::mt19937
rng_
;
169
};
170
}
171
}
pcl::outofcore::OutofcoreAbstractNodeContainer::OutofcoreAbstractNodeContainer
OutofcoreAbstractNodeContainer()
Definition
octree_abstract_node_container.h:57
pcl::outofcore::OutofcoreAbstractNodeContainer::AlignedPointTVector
std::vector< PointT, Eigen::aligned_allocator< PointT > > AlignedPointTVector
Definition
octree_abstract_node_container.h:55
pcl::outofcore::OutofcoreOctreeRamContainer
Storage container class which the outofcore octree base is templated against.
Definition
octree_ram_container.h:63
pcl::outofcore::OutofcoreOctreeRamContainer::size
std::uint64_t size() const
returns the size of the vector of points stored in this class
Definition
octree_ram_container.h:120
pcl::outofcore::OutofcoreOctreeRamContainer::OutofcoreOctreeRamContainer
OutofcoreOctreeRamContainer(const OutofcoreOctreeRamContainer &)
Definition
octree_ram_container.h:156
pcl::outofcore::OutofcoreOctreeRamContainer::OutofcoreOctreeRamContainer
OutofcoreOctreeRamContainer(const boost::filesystem::path &)
empty constructor (with a path parameter?)
Definition
octree_ram_container.h:69
pcl::outofcore::OutofcoreOctreeRamContainer::insertRange
void insertRange(AlignedPointTVector &)
Definition
octree_ram_container.h:86
pcl::outofcore::OutofcoreOctreeRamContainer::readRange
void readRange(const std::uint64_t start, const std::uint64_t count, AlignedPointTVector &v)
Definition
octree_ram_container.hpp:108
pcl::outofcore::OutofcoreOctreeRamContainer::container_
AlignedPointTVector container_
linear container to hold the points
Definition
octree_ram_container.h:165
pcl::outofcore::OutofcoreOctreeRamContainer::convertToXYZ
void convertToXYZ(const boost::filesystem::path &path)
Writes ascii x,y,z point data to path.string().c_str().
Definition
octree_ram_container.hpp:60
pcl::outofcore::OutofcoreOctreeRamContainer::readRangeSubSample
void readRangeSubSample(const std::uint64_t start, const std::uint64_t count, const double percent, AlignedPointTVector &v)
grab percent*count random points.
Definition
octree_ram_container.hpp:118
pcl::outofcore::OutofcoreOctreeRamContainer::insertRange
void insertRange(const PointT *start, const std::uint64_t count)
inserts count number of points into container; uses the container_ type's insert function
Definition
octree_ram_container.hpp:86
pcl::outofcore::OutofcoreOctreeRamContainer::rng_mutex_
static std::mutex rng_mutex_
Definition
octree_ram_container.h:167
pcl::outofcore::OutofcoreOctreeRamContainer::insertRange
void insertRange(const AlignedPointTVector &)
Definition
octree_ram_container.h:93
pcl::outofcore::OutofcoreOctreeRamContainer::operator[]
PointT operator[](std::uint64_t index) const
Definition
octree_ram_container.h:147
pcl::outofcore::OutofcoreOctreeRamContainer::AlignedPointTVector
typename OutofcoreAbstractNodeContainer< PointT >::AlignedPointTVector AlignedPointTVector
Definition
octree_ram_container.h:65
pcl::outofcore::OutofcoreOctreeRamContainer::empty
bool empty() const
Definition
octree_ram_container.h:126
pcl::outofcore::OutofcoreOctreeRamContainer::operator=
OutofcoreOctreeRamContainer & operator=(const OutofcoreOctreeRamContainer &)
Definition
octree_ram_container.h:159
pcl::outofcore::OutofcoreOctreeRamContainer::rng_
static std::mt19937 rng_
Definition
octree_ram_container.h:168
pcl::outofcore::OutofcoreOctreeRamContainer::clear
void clear()
clears the vector of points in this class
Definition
octree_ram_container.h:134
pcl::outofcore
Definition
octree_base.hpp:67
pcl
Definition
convolution.h:46