test_io.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2012-, Open Perception, Inc.
00006  *
00007  *  All rights reserved.
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of the copyright holder(s) nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  */
00037 
00038 #include <gtest/gtest.h>
00039 #include <pcl/point_types.h>
00040 #include <pcl/common/io.h>
00041 
00042 using namespace pcl;
00043 using namespace std;
00044 
00045 typedef PointCloud <PointXYZRGBA>      CloudXYZRGBA;
00046 typedef PointCloud <PointXYZRGB>       CloudXYZRGB;
00047 typedef PointCloud <PointXYZRGBNormal> CloudXYZRGBNormal;
00048 
00049 PointXYZRGBA pt_xyz_rgba, pt_xyz_rgba2;
00050 PointXYZRGB pt_xyz_rgb;
00051 
00053 TEST (PCL, concatenateFields)
00054 {
00055   bool status = isSamePointType<PointXYZ, PointXYZ> ();
00056   EXPECT_TRUE (status);
00057   status = isSamePointType<PointXYZ, PointXY> ();
00058   EXPECT_FALSE (status);
00059   status = isSamePointType<PointXY, PointXYZ> ();
00060   EXPECT_FALSE (status);
00061   status = isSamePointType<PointNormal, PointNormal> ();
00062   EXPECT_TRUE (status);
00063   status = isSamePointType<PointNormal, PointXYZRGBNormal> ();
00064   EXPECT_FALSE (status);
00065   status = isSamePointType<PointXYZRGB, PointXYZRGB> ();
00066   EXPECT_TRUE (status);
00067   
00068   // Even though it's the "same" type, rgb != rgba
00069   status = isSamePointType<PointXYZRGB, PointXYZRGBA> ();
00070   EXPECT_FALSE (status);
00071   status = isSamePointType<PointXYZRGBA, PointXYZRGB> ();
00072   EXPECT_FALSE (status);
00073 }
00074 
00076 TEST (PCL, copyPointCloud)
00077 {
00078   CloudXYZRGBA cloud_xyz_rgba;
00079   cloud_xyz_rgba.push_back (pt_xyz_rgba);
00080   cloud_xyz_rgba.push_back (pt_xyz_rgba);
00081   cloud_xyz_rgba.push_back (pt_xyz_rgba);
00082   cloud_xyz_rgba.push_back (pt_xyz_rgba);
00083   cloud_xyz_rgba.push_back (pt_xyz_rgba);
00084 
00085   CloudXYZRGBNormal cloud_xyz_rgb_normal;
00086   pcl::copyPointCloud (cloud_xyz_rgba, cloud_xyz_rgb_normal);
00087   EXPECT_EQ (int (cloud_xyz_rgb_normal.size ()), 5);
00088   for (int i = 0; i < 5; ++i)
00089   {
00090     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].x, cloud_xyz_rgb_normal[i].x);
00091     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].y, cloud_xyz_rgb_normal[i].y);
00092     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].z, cloud_xyz_rgb_normal[i].z);
00093     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].r, cloud_xyz_rgb_normal[i].r);
00094     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].g, cloud_xyz_rgb_normal[i].g);
00095     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].b, cloud_xyz_rgb_normal[i].b);
00096     EXPECT_EQ (cloud_xyz_rgba[i].rgba, cloud_xyz_rgb_normal[i].rgba);
00097   }
00098 
00099   vector<int> indices;
00100   indices.push_back (0); indices.push_back (1); 
00101   pcl::copyPointCloud (cloud_xyz_rgba, indices, cloud_xyz_rgb_normal);
00102   EXPECT_EQ (int (cloud_xyz_rgb_normal.size ()), 2);
00103   for (int i = 0; i < 2; ++i)
00104   {
00105     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].x, cloud_xyz_rgb_normal[i].x);
00106     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].y, cloud_xyz_rgb_normal[i].y);
00107     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].z, cloud_xyz_rgb_normal[i].z);
00108     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].r, cloud_xyz_rgb_normal[i].r);
00109     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].g, cloud_xyz_rgb_normal[i].g);
00110     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].b, cloud_xyz_rgb_normal[i].b);
00111     EXPECT_EQ (cloud_xyz_rgba[i].rgba, cloud_xyz_rgb_normal[i].rgba);
00112   }
00113 
00114   vector<int, Eigen::aligned_allocator<int> > indices_aligned;
00115   indices_aligned.push_back (1); indices_aligned.push_back (2); indices_aligned.push_back (3); 
00116   pcl::copyPointCloud (cloud_xyz_rgba, indices_aligned, cloud_xyz_rgb_normal);
00117   EXPECT_EQ (int (cloud_xyz_rgb_normal.size ()), 3);
00118   for (int i = 0; i < 3; ++i)
00119   {
00120     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].x, cloud_xyz_rgb_normal[i].x);
00121     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].y, cloud_xyz_rgb_normal[i].y);
00122     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].z, cloud_xyz_rgb_normal[i].z);
00123     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].r, cloud_xyz_rgb_normal[i].r);
00124     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].g, cloud_xyz_rgb_normal[i].g);
00125     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].b, cloud_xyz_rgb_normal[i].b);
00126     EXPECT_EQ (cloud_xyz_rgba[i].rgba, cloud_xyz_rgb_normal[i].rgba);
00127   }
00128 
00129   PointIndices pindices;
00130   pindices.indices.push_back (0); pindices.indices.push_back (2); pindices.indices.push_back (4);
00131   EXPECT_EQ (int (cloud_xyz_rgb_normal.size ()), 3);
00132   for (int i = 0; i < 3; ++i)
00133   {
00134     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].x, cloud_xyz_rgb_normal[i].x);
00135     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].y, cloud_xyz_rgb_normal[i].y);
00136     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].z, cloud_xyz_rgb_normal[i].z);
00137     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].r, cloud_xyz_rgb_normal[i].r);
00138     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].g, cloud_xyz_rgb_normal[i].g);
00139     EXPECT_FLOAT_EQ (cloud_xyz_rgba[i].b, cloud_xyz_rgb_normal[i].b);
00140     EXPECT_EQ (cloud_xyz_rgba[i].rgba, cloud_xyz_rgb_normal[i].rgba);
00141   }
00142 }
00143 
00145 TEST (PCL, concatenatePointCloud)
00146 {
00147   CloudXYZRGBA cloud_xyz_rgba;
00148   cloud_xyz_rgba.push_back (pt_xyz_rgba);
00149   cloud_xyz_rgba.push_back (pt_xyz_rgba);
00150   cloud_xyz_rgba.push_back (pt_xyz_rgba);
00151   cloud_xyz_rgba.push_back (pt_xyz_rgba);
00152   cloud_xyz_rgba.push_back (pt_xyz_rgba);
00153 
00154   CloudXYZRGBA cloud_xyz_rgba2;
00155   cloud_xyz_rgba2.push_back (pt_xyz_rgba2);
00156   cloud_xyz_rgba2.push_back (pt_xyz_rgba2);
00157 
00158   pcl::PCLPointCloud2 cloud1, cloud2, cloud_out, cloud_out2, cloud_out3, cloud_out4;
00159   pcl::toPCLPointCloud2 (cloud_xyz_rgba, cloud1);
00160   pcl::toPCLPointCloud2 (cloud_xyz_rgba2, cloud2);
00161 
00162   // Regular
00163   pcl::concatenatePointCloud (cloud1, cloud2, cloud_out);
00164   
00165   CloudXYZRGBA cloud_all;
00166   pcl::fromPCLPointCloud2 (cloud_out, cloud_all);
00167 
00168   EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ());
00169   for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i)
00170   {
00171     EXPECT_FLOAT_EQ (cloud_all[i].x, cloud_xyz_rgba[i].x);
00172     EXPECT_FLOAT_EQ (cloud_all[i].y, cloud_xyz_rgba[i].y);
00173     EXPECT_FLOAT_EQ (cloud_all[i].z, cloud_xyz_rgba[i].z);
00174     EXPECT_FLOAT_EQ (cloud_all[i].r, cloud_xyz_rgba[i].r);
00175     EXPECT_FLOAT_EQ (cloud_all[i].g, cloud_xyz_rgba[i].g);
00176     EXPECT_FLOAT_EQ (cloud_all[i].b, cloud_xyz_rgba[i].b);
00177     EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgba[i].rgba);
00178   }
00179   for (int i = 0; i < int (cloud_xyz_rgba2.size ()); ++i)
00180   {
00181     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].x, cloud_xyz_rgba2[i].x);
00182     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].y, cloud_xyz_rgba2[i].y);
00183     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].z, cloud_xyz_rgba2[i].z);
00184     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].r, cloud_xyz_rgba2[i].r);
00185     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].g, cloud_xyz_rgba2[i].g);
00186     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].b, cloud_xyz_rgba2[i].b);
00187     EXPECT_EQ (cloud_all[cloud_xyz_rgba.size () + i].rgba, cloud_xyz_rgba2[i].rgba);
00188   }
00189 
00190   // RGB != RGBA
00191   CloudXYZRGB cloud_xyz_rgb;
00192   cloud_xyz_rgb.push_back (pt_xyz_rgb);
00193   cloud_xyz_rgb.push_back (pt_xyz_rgb);
00194 
00195   pcl::toPCLPointCloud2 (cloud_xyz_rgb, cloud2);
00196   pcl::concatenatePointCloud (cloud1, cloud2, cloud_out2);
00197   
00198   pcl::fromPCLPointCloud2 (cloud_out2, cloud_all);
00199 
00200   EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ());
00201   for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i)
00202   {
00203     EXPECT_FLOAT_EQ (cloud_all[i].x, cloud_xyz_rgba[i].x);
00204     EXPECT_FLOAT_EQ (cloud_all[i].y, cloud_xyz_rgba[i].y);
00205     EXPECT_FLOAT_EQ (cloud_all[i].z, cloud_xyz_rgba[i].z);
00206     EXPECT_FLOAT_EQ (cloud_all[i].r, cloud_xyz_rgba[i].r);
00207     EXPECT_FLOAT_EQ (cloud_all[i].g, cloud_xyz_rgba[i].g);
00208     EXPECT_FLOAT_EQ (cloud_all[i].b, cloud_xyz_rgba[i].b);
00209     EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgba[i].rgba);
00210   }
00211   for (int i = 0; i < int (cloud_xyz_rgb.size ()); ++i)
00212   {
00213     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].x, cloud_xyz_rgb[i].x);
00214     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].y, cloud_xyz_rgb[i].y);
00215     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].z, cloud_xyz_rgb[i].z);
00216     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].r, cloud_xyz_rgb[i].r);
00217     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].g, cloud_xyz_rgb[i].g);
00218     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].b, cloud_xyz_rgb[i].b);
00219     EXPECT_EQ (cloud_all[cloud_xyz_rgba.size () + i].rgba, cloud_xyz_rgb[i].rgba);
00220   }
00221 
00222   // _ vs regular
00223   int rgb_idx = pcl::getFieldIndex (cloud1, "rgba");
00224   cloud1.fields[rgb_idx].name = "_";
00225   pcl::concatenatePointCloud (cloud1, cloud2, cloud_out3);
00226   
00227   pcl::fromPCLPointCloud2 (cloud_out3, cloud_all);
00228 
00229   EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ());
00230   for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i)
00231   {
00232     EXPECT_FLOAT_EQ (cloud_all[i].x, cloud_xyz_rgba[i].x);
00233     EXPECT_FLOAT_EQ (cloud_all[i].y, cloud_xyz_rgba[i].y);
00234     EXPECT_FLOAT_EQ (cloud_all[i].z, cloud_xyz_rgba[i].z);
00235     // Data doesn't get modified
00236     EXPECT_FLOAT_EQ (cloud_all[i].r, cloud_xyz_rgba[i].r);
00237     EXPECT_FLOAT_EQ (cloud_all[i].g, cloud_xyz_rgba[i].g);
00238     EXPECT_FLOAT_EQ (cloud_all[i].b, cloud_xyz_rgba[i].b);
00239     EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgba[i].rgba);
00240   }
00241   for (int i = 0; i < int (cloud_xyz_rgb.size ()); ++i)
00242   {
00243     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].x, cloud_xyz_rgb[i].x);
00244     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].y, cloud_xyz_rgb[i].y);
00245     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].z, cloud_xyz_rgb[i].z);
00246     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].r, 0);
00247     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].g, 0);
00248     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].b, 0);
00249     EXPECT_EQ (cloud_all[cloud_xyz_rgba.size () + i].rgba, 0);
00250   }
00251 
00252   cloud1.fields[rgb_idx].name = "rgba";
00253   // regular vs _
00254   rgb_idx = pcl::getFieldIndex (cloud2, "rgb");
00255   cloud2.fields[rgb_idx].name = "_";
00256   pcl::concatenatePointCloud (cloud1, cloud2, cloud_out4);
00257 
00258   pcl::fromPCLPointCloud2 (cloud_out4, cloud_all);
00259 
00260   EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ());
00261   for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i)
00262   {
00263     EXPECT_FLOAT_EQ (cloud_all[i].x, cloud_xyz_rgba[i].x);
00264     EXPECT_FLOAT_EQ (cloud_all[i].y, cloud_xyz_rgba[i].y);
00265     EXPECT_FLOAT_EQ (cloud_all[i].z, cloud_xyz_rgba[i].z);
00266     // Data doesn't get modified
00267     EXPECT_FLOAT_EQ (cloud_all[i].r, cloud_xyz_rgba[i].r);
00268     EXPECT_FLOAT_EQ (cloud_all[i].g, cloud_xyz_rgba[i].g);
00269     EXPECT_FLOAT_EQ (cloud_all[i].b, cloud_xyz_rgba[i].b);
00270     EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgba[i].rgba);
00271   }
00272   for (int i = 0; i < int (cloud_xyz_rgb.size ()); ++i)
00273   {
00274     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].x, cloud_xyz_rgb[i].x);
00275     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].y, cloud_xyz_rgb[i].y);
00276     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].z, cloud_xyz_rgb[i].z);
00277     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].r, 0);
00278     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].g, 0);
00279     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].b, 0);
00280     EXPECT_EQ (cloud_all[cloud_xyz_rgba.size () + i].rgba, 0);
00281   }
00282 
00283   // _ vs _
00284   rgb_idx = pcl::getFieldIndex (cloud1, "rgba");
00285   cloud1.fields[rgb_idx].name = "_";
00286   pcl::toPCLPointCloud2 (cloud_xyz_rgb, cloud2);
00287   rgb_idx = pcl::getFieldIndex (cloud2, "rgb");
00288   cloud2.fields[rgb_idx].name = "_";
00289 
00290   pcl::concatenatePointCloud (cloud1, cloud2, cloud_out3);
00291   
00292   pcl::fromPCLPointCloud2 (cloud_out3, cloud_all);
00293 
00294   EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ());
00295   for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i)
00296   {
00297     EXPECT_FLOAT_EQ (cloud_all[i].x, cloud_xyz_rgba[i].x);
00298     EXPECT_FLOAT_EQ (cloud_all[i].y, cloud_xyz_rgba[i].y);
00299     EXPECT_FLOAT_EQ (cloud_all[i].z, cloud_xyz_rgba[i].z);
00300     // Data doesn't get modified
00301     EXPECT_FLOAT_EQ (cloud_all[i].r, cloud_xyz_rgba[i].r);
00302     EXPECT_FLOAT_EQ (cloud_all[i].g, cloud_xyz_rgba[i].g);
00303     EXPECT_FLOAT_EQ (cloud_all[i].b, cloud_xyz_rgba[i].b);
00304     EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgba[i].rgba);
00305   }
00306   for (int i = 0; i < int (cloud_xyz_rgb.size ()); ++i)
00307   {
00308     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].x, cloud_xyz_rgb[i].x);
00309     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].y, cloud_xyz_rgb[i].y);
00310     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].z, cloud_xyz_rgb[i].z);
00311     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].r, 0);
00312     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].g, 0);
00313     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].b, 0);
00314     EXPECT_EQ (cloud_all[cloud_xyz_rgba.size () + i].rgba, 0);
00315   }
00316 
00317   cloud1.fields[rgb_idx].name = "rgba";
00318   // _ vs regular
00319   rgb_idx = pcl::getFieldIndex (cloud1, "rgba");
00320 
00321   cloud1.fields[rgb_idx].name = "_";
00322   pcl::toPCLPointCloud2 (cloud_xyz_rgb, cloud2);
00323   pcl::concatenatePointCloud (cloud2, cloud1, cloud_out3);
00324   
00325   pcl::fromPCLPointCloud2 (cloud_out3, cloud_all);
00326 
00327   EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ());
00328   for (int i = 0; i < int (cloud_xyz_rgb.size ()); ++i)
00329   {
00330     EXPECT_FLOAT_EQ (cloud_all[i].x, cloud_xyz_rgb[i].x);
00331     EXPECT_FLOAT_EQ (cloud_all[i].y, cloud_xyz_rgb[i].y);
00332     EXPECT_FLOAT_EQ (cloud_all[i].z, cloud_xyz_rgb[i].z);
00333     // Data doesn't get modified
00334     EXPECT_FLOAT_EQ (cloud_all[i].r, cloud_xyz_rgb[i].r);
00335     EXPECT_FLOAT_EQ (cloud_all[i].g, cloud_xyz_rgb[i].g);
00336     EXPECT_FLOAT_EQ (cloud_all[i].b, cloud_xyz_rgb[i].b);
00337     EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgb[i].rgba);
00338   }
00339   for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i)
00340   {
00341     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].x, cloud_xyz_rgba[i].x);
00342     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].y, cloud_xyz_rgba[i].y);
00343     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].z, cloud_xyz_rgba[i].z);
00344     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].r, 0);
00345     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].g, 0);
00346     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].b, 0);
00347     EXPECT_EQ (cloud_all[cloud_xyz_rgb.size () + i].rgba, 0);
00348   }
00349 
00350   cloud1.fields[rgb_idx].name = "rgba";
00351   // regular vs _
00352   rgb_idx = pcl::getFieldIndex (cloud2, "rgb");
00353   cloud2.fields[rgb_idx].name = "_";
00354   pcl::concatenatePointCloud (cloud2, cloud1, cloud_out4);
00355 
00356   pcl::fromPCLPointCloud2 (cloud_out4, cloud_all);
00357 
00358   EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ());
00359   for (int i = 0; i < int (cloud_xyz_rgb.size ()); ++i)
00360   {
00361     EXPECT_FLOAT_EQ (cloud_all[i].x, cloud_xyz_rgb[i].x);
00362     EXPECT_FLOAT_EQ (cloud_all[i].y, cloud_xyz_rgb[i].y);
00363     EXPECT_FLOAT_EQ (cloud_all[i].z, cloud_xyz_rgb[i].z);
00364     // Data doesn't get modified
00365     EXPECT_FLOAT_EQ (cloud_all[i].r, cloud_xyz_rgb[i].r);
00366     EXPECT_FLOAT_EQ (cloud_all[i].g, cloud_xyz_rgb[i].g);
00367     EXPECT_FLOAT_EQ (cloud_all[i].b, cloud_xyz_rgb[i].b);
00368     EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgb[i].rgba);
00369   }
00370   for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i)
00371   {
00372     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].x, cloud_xyz_rgba[i].x);
00373     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].y, cloud_xyz_rgba[i].y);
00374     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].z, cloud_xyz_rgba[i].z);
00375     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].r, 0);
00376     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].g, 0);
00377     EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].b, 0);
00378     EXPECT_EQ (cloud_all[cloud_xyz_rgb.size () + i].rgba, 0);
00379   }
00380 }
00381 
00382 /* ---[ */
00383 int
00384 main (int argc, char** argv)
00385 {
00386   pt_xyz_rgba.x = 5;
00387   pt_xyz_rgba.y = 2;
00388   pt_xyz_rgba.z = 3;
00389   pt_xyz_rgba.r = 112;
00390   pt_xyz_rgba.g = 100;
00391   pt_xyz_rgba.b = 255;
00392   pt_xyz_rgba.a = 135;
00393   
00394   pt_xyz_rgba2.x = 4;
00395   pt_xyz_rgba2.y = 1;
00396   pt_xyz_rgba2.z = 5;
00397   pt_xyz_rgba2.r = 11;
00398   pt_xyz_rgba2.g = 10;
00399   pt_xyz_rgba2.b = 0;
00400   pt_xyz_rgba2.a = 255;
00401 
00402   pt_xyz_rgb.x = 4;
00403   pt_xyz_rgb.y = 1;
00404   pt_xyz_rgb.z = 5;
00405   pt_xyz_rgb.r = 11;
00406   pt_xyz_rgb.g = 10;
00407   pt_xyz_rgb.b = 0;
00408   pt_xyz_rgb.a = 255;
00409 
00410   testing::InitGoogleTest (&argc, argv);
00411   return (RUN_ALL_TESTS ());
00412 }
00413 /* ]--- */


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:35:02