37 #ifndef PCL_PCL_IMPL_BASE_HPP_
38 #define PCL_PCL_IMPL_BASE_HPP_
40 #include <pcl/pcl_base.h>
41 #include <pcl/console/print.h>
45 template <
typename Po
intT>
48 , use_indices_ (false)
49 , fake_indices_ (false)
54 template <
typename Po
intT>
56 : input_ (base.input_)
57 , indices_ (base.indices_)
58 , use_indices_ (base.use_indices_)
59 , fake_indices_ (base.fake_indices_)
64 template <
typename Po
intT>
void
71 template <
typename Po
intT>
void
75 fake_indices_ =
false;
80 template <
typename Po
intT>
void
84 fake_indices_ =
false;
89 template <
typename Po
intT>
void
92 indices_.reset (
new Indices (indices->indices));
93 fake_indices_ =
false;
98 template <
typename Po
intT>
void
101 if ((nb_rows > input_->height) || (row_start > input_->height))
103 PCL_ERROR (
"[PCLBase::setIndices] cloud is only %d height\n", input_->height);
107 if ((nb_cols > input_->width) || (col_start > input_->width))
109 PCL_ERROR (
"[PCLBase::setIndices] cloud is only %d width\n", input_->width);
113 std::size_t row_end = row_start + nb_rows;
114 if (row_end > input_->height)
116 PCL_ERROR (
"[PCLBase::setIndices] %d is out of rows range %d\n", row_end, input_->height);
120 std::size_t col_end = col_start + nb_cols;
121 if (col_end > input_->width)
123 PCL_ERROR (
"[PCLBase::setIndices] %d is out of columns range %d\n", col_end, input_->width);
128 indices_->reserve (nb_cols * nb_rows);
129 for(std::size_t i = row_start; i < row_end; i++)
130 for(std::size_t j = col_start; j < col_end; j++)
131 indices_->push_back (
static_cast<int> ((i * input_->width) + j));
132 fake_indices_ =
false;
137 template <
typename Po
intT>
bool
143 PCL_ERROR (
"[initCompute] No input set.\n");
150 fake_indices_ =
true;
155 if (fake_indices_ && indices_->size () != input_->size ())
157 const auto indices_size = indices_->size ();
160 indices_->resize (input_->size ());
162 catch (
const std::bad_alloc&)
164 PCL_ERROR (
"[initCompute] Failed to allocate %lu indices.\n", input_->size ());
167 for (
auto i = indices_size; i < indices_->size (); ++i) { (*indices_)[i] =
static_cast<int>(i); }
174 template <
typename Po
intT>
bool
180 #define PCL_INSTANTIATE_PCLBase(T) template class PCL_EXPORTS pcl::PCLBase<T>;
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
typename PointCloud::ConstPtr PointCloudConstPtr
virtual void setIndices(const IndicesPtr &indices)
Provide a pointer to the vector of indices that represents the input data.
bool initCompute()
This method should get called before starting the actual computation.
PointIndices::ConstPtr PointIndicesConstPtr
PCLBase()
Empty constructor.
bool deinitCompute()
This method should get called after finishing the actual computation.
shared_ptr< const Indices > IndicesConstPtr
IndicesAllocator<> Indices
Type used for indices in PCL.
shared_ptr< Indices > IndicesPtr