Point Cloud Library (PCL) 1.13.1
Loading...
Searching...
No Matches
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
48namespace 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 PointT>
63 {
64 public:
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
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
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
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
157
160
161 //the actual container
162 //std::deque<PointT> container;
163
164 /** \brief linear container to hold the points */
166
167 static std::mutex rng_mutex_;
168 static std::mt19937 rng_;
169 };
170 }
171}
std::vector< PointT, Eigen::aligned_allocator< PointT > > AlignedPointTVector
Storage container class which the outofcore octree base is templated against.
std::uint64_t size() const
returns the size of the vector of points stored in this class
OutofcoreOctreeRamContainer(const OutofcoreOctreeRamContainer &)
OutofcoreOctreeRamContainer(const boost::filesystem::path &)
empty constructor (with a path parameter?)
void readRange(const std::uint64_t start, const std::uint64_t count, AlignedPointTVector &v)
AlignedPointTVector container_
linear container to hold the points
void convertToXYZ(const boost::filesystem::path &path)
Writes ascii x,y,z point data to path.string().c_str()
void readRangeSubSample(const std::uint64_t start, const std::uint64_t count, const double percent, AlignedPointTVector &v)
grab percent*count random points.
void insertRange(const PointT *start, const std::uint64_t count)
inserts count number of points into container; uses the container_ type's insert function
void insertRange(const AlignedPointTVector &)
PointT operator[](std::uint64_t index) const
typename OutofcoreAbstractNodeContainer< PointT >::AlignedPointTVector AlignedPointTVector
OutofcoreOctreeRamContainer & operator=(const OutofcoreOctreeRamContainer &)
void clear()
clears the vector of points in this class
A point structure representing Euclidean xyz coordinates, and the RGB color.