Go to the documentation of this file.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/point_operators.h>
00042
00043 using namespace pcl;
00044 using namespace pcl::test;
00045
00046 TEST (PointOperators, PointXYZI)
00047 {
00048 using namespace pcl::common;
00049 PointXYZI p0; p0.x = 0.1f; p0.y = 0.2f; p0.z = 0.3f; p0.intensity = 123;
00050 PointXYZI p1; p1.x = 0.05f; p1.y = 0.05f; p1.z = 0.05f; p1.intensity = 133;
00051 PointXYZI p2 = p0 + p1;
00052
00053 EXPECT_EQ (p2.x, p0.x + p1.x);
00054 EXPECT_EQ (p2.y, p0.y + p1.y);
00055 EXPECT_EQ (p2.z, p0.z + p1.z);
00056 EXPECT_EQ (p2.intensity, p0.intensity + p1.intensity);
00057 p2 = 0.1f * p1;
00058 EXPECT_NEAR (p2.x, 0.1 * p1.x, 1e-4);
00059 EXPECT_NEAR (p2.y, 0.1 * p1.y, 1e-4);
00060 EXPECT_NEAR (p2.z, 0.1 * p1.z, 1e-4);
00061 EXPECT_NEAR (p2.intensity, 0.1 * p1.intensity, 1e-4);
00062 PointXYZI p3 = p1 * 0.1f;
00063 EXPECT_EQ_VECTORS (p2.getVector3fMap (), p3.getVector3fMap ());
00064 EXPECT_EQ (p2.intensity, p3.intensity);
00065 }
00066
00067 TEST (PointOperators, PointXYZRGB)
00068 {
00069 using namespace pcl::common;
00070 PointXYZRGB p0; p0.x = 0.1f; p0.y = 0.2f; p0.z = 0.3f; p0.r = 123; p0.g = 125; p0.b = 127;
00071 PointXYZRGB p1; p1.x = 0.05f; p1.y = 0.05f; p1.z = 0.05f; p1.r = 123; p1.g = 125; p1.b = 127;
00072 PointXYZRGB p2 = p0 + p1;
00073
00074 EXPECT_EQ (p2.x, p0.x + p1.x);
00075 EXPECT_EQ (p2.y, p0.y + p1.y);
00076 EXPECT_EQ (p2.z, p0.z + p1.z);
00077 EXPECT_EQ (p2.r, p0.r + p1.r);
00078 EXPECT_EQ (p2.g, p0.g + p1.g);
00079 EXPECT_EQ (p2.b, p0.b + p1.b);
00080 p2 = 0.1f * p1;
00081 EXPECT_NEAR (p2.x, 0.1 * p1.x, 1e-4);
00082 EXPECT_NEAR (p2.y, 0.1 * p1.y, 1e-4);
00083 EXPECT_NEAR (p2.z, 0.1 * p1.z, 1e-4);
00084 EXPECT_EQ (p2.r, static_cast<pcl::uint8_t> (0.1 * p1.r));
00085 EXPECT_EQ (p2.g, static_cast<pcl::uint8_t> (0.1 * p1.g));
00086 EXPECT_EQ (p2.b, static_cast<pcl::uint8_t> (0.1 * p1.b));
00087 PointXYZRGB p3 = p1 * 0.1f;
00088 EXPECT_EQ_VECTORS (p2.getVector3fMap (), p3.getVector3fMap ());
00089 EXPECT_EQ (p2.r, p3.r);
00090 EXPECT_EQ (p2.g, p3.g);
00091 EXPECT_EQ (p2.b, p3.b);
00092 }
00093
00094 int
00095 main (int argc, char** argv)
00096 {
00097 testing::InitGoogleTest (&argc, argv);
00098 return (RUN_ALL_TESTS ());
00099 }