concatenate_clouds.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <pcl/io/pcd_io.h>
00003 #include <pcl/point_types.h>
00004 
00005 int
00006   main (int argc, char** argv)
00007 {
00008   if (argc != 2)
00009   {
00010     std::cerr << "please specify command line arg '-f' or '-p'" << std::endl;
00011     exit(0);
00012   }
00013   pcl::PointCloud<pcl::PointXYZ> cloud_a, cloud_b, cloud_c;
00014   pcl::PointCloud<pcl::Normal> n_cloud_b;
00015   pcl::PointCloud<pcl::PointNormal> p_n_cloud_c;
00016 
00017   // Fill in the cloud data
00018   cloud_a.width  = 5;
00019   cloud_a.height = cloud_b.height = n_cloud_b.height = 1;
00020     cloud_a.points.resize (cloud_a.width * cloud_a.height);
00021   if (strcmp(argv[1], "-p") == 0)
00022   {
00023     cloud_b.width  = 3;
00024     cloud_b.points.resize (cloud_b.width * cloud_b.height);
00025   }
00026   else{
00027     n_cloud_b.width = 5;
00028     n_cloud_b.points.resize (n_cloud_b.width * n_cloud_b.height);
00029   }
00030 
00031   for (size_t i = 0; i < cloud_a.points.size (); ++i)
00032   {
00033     cloud_a.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
00034     cloud_a.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
00035     cloud_a.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
00036   }
00037   if (strcmp(argv[1], "-p") == 0)
00038     for (size_t i = 0; i < cloud_b.points.size (); ++i)
00039     {
00040       cloud_b.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
00041       cloud_b.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
00042       cloud_b.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
00043     }
00044   else
00045     for (size_t i = 0; i < n_cloud_b.points.size (); ++i)
00046     {
00047       n_cloud_b.points[i].normal[0] = 1024 * rand () / (RAND_MAX + 1.0f);
00048       n_cloud_b.points[i].normal[1] = 1024 * rand () / (RAND_MAX + 1.0f);
00049       n_cloud_b.points[i].normal[2] = 1024 * rand () / (RAND_MAX + 1.0f);
00050     }
00051   std::cerr << "Cloud A: " << std::endl;
00052   for (size_t i = 0; i < cloud_a.points.size (); ++i)
00053     std::cerr << "    " << cloud_a.points[i].x << " " << cloud_a.points[i].y << " " << cloud_a.points[i].z << std::endl;
00054 
00055   std::cerr << "Cloud B: " << std::endl;
00056   if (strcmp(argv[1], "-p") == 0)
00057     for (size_t i = 0; i < cloud_b.points.size (); ++i)
00058       std::cerr << "    " << cloud_b.points[i].x << " " << cloud_b.points[i].y << " " << cloud_b.points[i].z << std::endl;
00059   else
00060     for (size_t i = 0; i < n_cloud_b.points.size (); ++i)
00061       std::cerr << "    " << n_cloud_b.points[i].normal[0] << " " << n_cloud_b.points[i].normal[1] << " " << n_cloud_b.points[i].normal[2] << std::endl;
00062 
00063   // Copy the point cloud data
00064   if (strcmp(argv[1], "-p") == 0)
00065   {
00066     cloud_c  = cloud_a;
00067     cloud_c += cloud_b;
00068     std::cerr << "Cloud C: " << std::endl;
00069     for (size_t i = 0; i < cloud_c.points.size (); ++i)
00070       std::cerr << "    " << cloud_c.points[i].x << " " << cloud_c.points[i].y << " " << cloud_c.points[i].z << " " << std::endl;
00071   }
00072   else
00073   {
00074     pcl::concatenateFields (cloud_a, n_cloud_b, p_n_cloud_c);
00075     std::cerr << "Cloud C: " << std::endl;
00076     for (size_t i = 0; i < p_n_cloud_c.points.size (); ++i)
00077       std::cerr << "    " <<
00078         p_n_cloud_c.points[i].x << " " << p_n_cloud_c.points[i].y << " " << p_n_cloud_c.points[i].z << " " <<
00079         p_n_cloud_c.points[i].normal[0] << " " << p_n_cloud_c.points[i].normal[1] << " " << p_n_cloud_c.points[i].normal[2] << std::endl;
00080   }
00081   return (0);
00082 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:22:51