39 #ifndef PCL_PCL_BASE_H_
40 #define PCL_PCL_BASE_H_
52 #include <boost/shared_ptr.hpp>
63 typedef boost::shared_ptr <std::vector<int> >
IndicesPtr;
70 template <
typename Po
intT>
82 PCLBase () : input_ (), indices_ (), use_indices_ (false), fake_indices_ (false) {}
86 : input_ (base.input_)
87 , indices_ (base.indices_)
88 , use_indices_ (base.use_indices_)
89 , fake_indices_ (base.fake_indices_)
116 fake_indices_ =
false;
126 indices_.reset (
new std::vector<int> (*indices));
127 fake_indices_ =
false;
137 indices_.reset (
new std::vector<int> (indices->indices));
138 fake_indices_ =
false;
151 setIndices (
size_t row_start,
size_t col_start,
size_t nb_rows,
size_t nb_cols)
153 if ((nb_rows > input_->height) || (row_start > input_->height))
155 PCL_ERROR (
"[PCLBase::setIndices] cloud is only %d height", input_->height);
159 if ((nb_cols > input_->width) || (col_start > input_->width))
161 PCL_ERROR (
"[PCLBase::setIndices] cloud is only %d width", input_->width);
165 size_t row_end = row_start + nb_rows;
166 if (row_end > input_->height)
168 PCL_ERROR (
"[PCLBase::setIndices] %d is out of rows range %d", row_end, input_->height);
172 size_t col_end = col_start + nb_cols;
173 if (col_end > input_->width)
175 PCL_ERROR (
"[PCLBase::setIndices] %d is out of columns range %d", col_end, input_->width);
179 indices_.reset (
new std::vector<int>);
180 indices_->reserve (nb_cols * nb_rows);
181 for(
size_t i = row_start; i < row_end; i++)
182 for(
size_t j = col_start; j < col_end; j++)
183 indices_->push_back (static_cast<int> ((i * input_->width) + j));
184 fake_indices_ =
false;
199 return ((*input_)[(*indices_)[pos]]);
234 fake_indices_ =
true;
235 indices_.reset (
new std::vector<int>);
238 indices_->resize (input_->points.size ());
240 catch (std::bad_alloc)
242 PCL_ERROR (
"[initCompute] Failed to allocate %zu indices.\n", input_->points.size ());
244 for (
size_t i = 0; i < indices_->size (); ++i) { (*indices_)[i] =
static_cast<int>(i); }
248 if (fake_indices_ && indices_->size () != input_->points.size ())
250 size_t indices_size = indices_->size ();
251 indices_->resize (input_->points.size ());
252 for (
size_t i = indices_size; i < indices_->size (); ++i) { (*indices_)[i] =
static_cast<int>(i); }
267 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
283 PCLBase () : input_ (), indices_ (), use_indices_ (false), fake_indices_ (false),
284 field_sizes_ (0), x_idx_ (-1), y_idx_ (-1), z_idx_ (-1),
285 x_field_name_ (
"x"), y_field_name_ (
"y"), z_field_name_ (
"z")
312 fake_indices_ =
false;
322 indices_.reset (
new std::vector<int> (indices->indices));
323 fake_indices_ =
false;
345 std::vector<int> field_sizes_;
348 int x_idx_, y_idx_, z_idx_;
351 std::string x_field_name_, y_field_name_, z_field_name_;
354 bool deinitCompute ();
356 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
360 #endif //#ifndef PCL_PCL_BASE_H_