00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <gtest/gtest.h>
00039 #include <pcl/pcl_tests.h>
00040 #include <pcl/point_types.h>
00041 #include <pcl/common/random.h>
00042 #include <pcl/common/generate.h>
00043
00044 TEST (UniformCloudGenerator, PointXYZ)
00045 {
00046 using namespace pcl::common;
00047 CloudGenerator<pcl::PointXYZ, UniformGenerator<float> > generator;
00048 UniformGenerator<float>::Parameters x_params;
00049 generator.setParametersForX (x_params);
00050 UniformGenerator<float>::Parameters y_params (-1.f, 1.f);
00051 generator.setParametersForY (y_params);
00052 UniformGenerator<float>::Parameters z_params (-2.5, 1.5f);
00053 generator.setParametersForZ (z_params);
00054
00055 pcl::PointCloud<pcl::PointXYZ> output;
00056 int result = generator.fill (480, 640, output);
00057 EXPECT_EQ (result, 0);
00058 EXPECT_EQ (output.height, 640);
00059 EXPECT_EQ (output.width, 480);
00060 EXPECT_EQ (output.size (), 480*640);
00061 for(pcl::PointCloud<pcl::PointXYZ>::const_iterator points_it = output.begin ();
00062 points_it != output.end ();
00063 ++points_it)
00064 {
00065 EXPECT_GE (points_it->x, 0);
00066 EXPECT_LT (points_it->x, 1);
00067 EXPECT_GE (points_it->y, -1);
00068 EXPECT_LT (points_it->y, 1);
00069 EXPECT_GE (points_it->z, -2.5);
00070 EXPECT_LT (points_it->z, 1.5);
00071 }
00072 }
00073
00074 TEST (UniformCloudGenerator, PointXY)
00075 {
00076 using namespace pcl::common;
00077 CloudGenerator<pcl::PointXY, UniformGenerator<float> > generator;
00078 UniformGenerator<float>::Parameters x_params;
00079 generator.setParametersForX (x_params);
00080 UniformGenerator<float>::Parameters y_params (-1.f, 1.f);
00081 generator.setParametersForY (y_params);
00082
00083 pcl::PointCloud<pcl::PointXY> output;
00084 int result = generator.fill (480, 640, output);
00085 EXPECT_EQ (result, 0);
00086 EXPECT_EQ (output.height, 640);
00087 EXPECT_EQ (output.width, 480);
00088 EXPECT_EQ (output.size (), 480*640);
00089 for(pcl::PointCloud<pcl::PointXY>::const_iterator points_it = output.begin ();
00090 points_it != output.end ();
00091 ++points_it)
00092 {
00093 EXPECT_GE (points_it->x, 0);
00094 EXPECT_LT (points_it->x, 1);
00095 EXPECT_GE (points_it->y, -1);
00096 EXPECT_LT (points_it->y, 1);
00097 }
00098 }
00099
00100 TEST (UniformCloudGenerator, Cube)
00101 {
00102 using namespace pcl::common;
00103 CloudGenerator<pcl::PointXYZ, UniformGenerator<float> > generator;
00104 UniformGenerator<float>::Parameters params (-3, 3, 1);
00105 generator.setParameters (params);
00106
00107 pcl::PointCloud<pcl::PointXYZ> output;
00108 int result = generator.fill (480, 640, output);
00109 EXPECT_EQ (result, 0);
00110 EXPECT_EQ (output.height, 640);
00111 EXPECT_EQ (output.width, 480);
00112 EXPECT_EQ (output.size (), 480*640);
00113 for(pcl::PointCloud<pcl::PointXYZ>::const_iterator points_it = output.begin ();
00114 points_it != output.end ();
00115 ++points_it)
00116 {
00117 EXPECT_GE (points_it->x, -3);
00118 EXPECT_LT (points_it->x, 3);
00119 EXPECT_GE (points_it->y, -3);
00120 EXPECT_LT (points_it->y, 3);
00121 EXPECT_GE (points_it->z, -3);
00122 EXPECT_LT (points_it->z, 3);
00123 }
00124 }
00125
00126 TEST (UniformCloudGenerator, Square)
00127 {
00128 using namespace pcl::common;
00129 CloudGenerator<pcl::PointXY, UniformGenerator<float> > generator;
00130 UniformGenerator<float>::Parameters params (-3, 3, 1);
00131 generator.setParameters (params);
00132
00133 pcl::PointCloud<pcl::PointXY> output;
00134 int result = generator.fill (480, 640, output);
00135 EXPECT_EQ (result, 0);
00136 EXPECT_EQ (output.height, 640);
00137 EXPECT_EQ (output.width, 480);
00138 EXPECT_EQ (output.size (), 480*640);
00139 for(pcl::PointCloud<pcl::PointXY>::const_iterator points_it = output.begin ();
00140 points_it != output.end ();
00141 ++points_it)
00142 {
00143 EXPECT_GE (points_it->x, -3);
00144 EXPECT_LT (points_it->x, 3);
00145 EXPECT_GE (points_it->y, -3);
00146 EXPECT_LT (points_it->y, 3);
00147 }
00148 }
00149
00150 int
00151 main (int argc, char** argv)
00152 {
00153 testing::InitGoogleTest (&argc, argv);
00154 return (RUN_ALL_TESTS ());
00155 }