268 const std::vector<pcl::PointIndices> &indices,
271 const auto nr_p = std::accumulate(indices.begin (), indices.end (), 0,
272 [](
const auto& acc,
const auto& index) { return index.indices.size() + acc; });
275 if (nr_p == cloud_in.
size ())
284 cloud_out.
width = nr_p;
292 for (
const auto &cluster_index : indices)
295 for (
const auto &index : cluster_index.indices)
297 copyPoint (cloud_in[index], cloud_out[cp]);
309 using FieldList1 =
typename pcl::traits::fieldList<PointIn1T>::type;
310 using FieldList2 =
typename pcl::traits::fieldList<PointIn2T>::type;
312 if (cloud1_in.
size () != cloud2_in.
size ())
314 PCL_ERROR (
"[pcl::concatenateFields] The number of points in the two input datasets differs!\n");
329 for (std::size_t i = 0; i < cloud_out.
size (); ++i)
342 if (top < 0 || left < 0 || bottom < 0 || right < 0)
344 std::string faulty = (top < 0) ?
"top" : (left < 0) ?
"left" : (bottom < 0) ?
"bottom" :
"right";
349 if (top == 0 && left == 0 && bottom == 0 && right == 0)
350 cloud_out = cloud_in;
355 cloud_out.
width = cloud_in.
width + left + right;
365 const PointT* in = &(cloud_in[0]);
366 PointT* out = &(cloud_out[0]);
367 PointT* out_inner = out + cloud_out.
width*top + left;
368 for (std::uint32_t i = 0; i < cloud_in.
height; i++, out_inner += cloud_out.
width, in += cloud_in.
width)
371 memcpy (out_inner, in, cloud_in.
width * sizeof (PointT));
381 std::vector<int> padding (cloud_out.
width - cloud_in.
width);
382 int right = cloud_out.
width - cloud_in.
width - left;
385 for (
int i = 0; i < left; i++)
388 for (
int i = 0; i < right; i++)
391 const PointT* in = &(cloud_in[0]);
392 PointT* out = &(cloud_out[0]);
393 PointT* out_inner = out + cloud_out.
width*top + left;
395 for (std::uint32_t i = 0; i < cloud_in.
height; i++, out_inner += cloud_out.
width, in += cloud_in.
width)
398 memcpy (out_inner, in, cloud_in.
width * sizeof (PointT));
400 for (
int j = 0; j < left; j++)
401 out_inner[j - left] = in[padding[j]];
403 for (
int j = 0; j < right; j++)
404 out_inner[j + cloud_in.
width] = in[padding[j + left]];
407 for (
int i = 0; i < top; i++)
410 memcpy (out + i*cloud_out.
width,
411 out + (j+top) * cloud_out.
width,
412 sizeof (PointT) * cloud_out.
width);
415 for (
int i = 0; i < bottom; i++)
418 memcpy (out + (i + cloud_in.
height + top)*cloud_out.
width,
419 out + (j+top)*cloud_out.
width,
420 cloud_out.
width * sizeof (PointT));
425 PCL_ERROR (
"[pcl::copyPointCloud] Unhandled interpolation type %d!\n", border_type);
430 int right = cloud_out.
width - cloud_in.
width - left;
432 std::vector<PointT> buff (cloud_out.
width, value);
433 PointT* buff_ptr = &(buff[0]);
434 const PointT* in = &(cloud_in[0]);
435 PointT* out = &(cloud_out[0]);
436 PointT* out_inner = out + cloud_out.
width*top + left;
438 for (std::uint32_t i = 0; i < cloud_in.
height; i++, out_inner += cloud_out.
width, in += cloud_in.
width)
441 memcpy (out_inner, in, cloud_in.
width * sizeof (PointT));
443 memcpy (out_inner - left, buff_ptr, left *
sizeof (PointT));
444 memcpy (out_inner + cloud_in.
width, buff_ptr, right * sizeof (PointT));
447 for (
int i = 0; i < top; i++)
449 memcpy (out + i*cloud_out.
width, buff_ptr, cloud_out.
width * sizeof (PointT));
452 for (
int i = 0; i < bottom; i++)
454 memcpy (out + (i + cloud_in.
height + top)*cloud_out.
width,
456 cloud_out.
width * sizeof (PointT));
void concatenateFields(const pcl::PointCloud< PointIn1T > &cloud1_in, const pcl::PointCloud< PointIn2T > &cloud2_in, pcl::PointCloud< PointOutT > &cloud_out)
Concatenate two datasets representing different fields.
void copyPointCloud(const pcl::PointCloud< PointInT > &cloud_in, pcl::PointCloud< PointOutT > &cloud_out)
Copy all the fields from a given point cloud into a new point cloud.