/////////////////////////////////////////////////////////////////////////////////////////////////////////////
| 51 | |
| 52 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 53 | TEST (PCL, compute3DCentroidFloat) |
| 54 | { |
| 55 | pcl::PointIndices pindices; |
| 56 | Indices indices; |
| 57 | PointXYZ point; |
| 58 | PointCloud<PointXYZ> cloud; |
| 59 | Eigen::Vector4f centroid = Eigen::Vector4f::Random(); |
| 60 | const Eigen::Vector4f old_centroid = centroid; |
| 61 | |
| 62 | // test empty cloud which is dense |
| 63 | cloud.is_dense = true; |
| 64 | EXPECT_EQ (compute3DCentroid (cloud, centroid), 0); |
| 65 | EXPECT_EQ (old_centroid, centroid); // centroid remains unchanged |
| 66 | |
| 67 | // test empty cloud non_dense |
| 68 | cloud.is_dense = false; |
| 69 | EXPECT_EQ (compute3DCentroid (cloud, centroid), 0); |
| 70 | EXPECT_EQ (old_centroid, centroid); // centroid remains unchanged |
| 71 | |
| 72 | // test non-empty cloud non_dense (with only invalid points) |
| 73 | point.x = point.y = point.z = std::numeric_limits<float>::quiet_NaN (); |
| 74 | cloud.push_back (point); |
| 75 | EXPECT_EQ (compute3DCentroid (cloud, centroid), 0); |
| 76 | EXPECT_EQ (old_centroid, centroid); // centroid remains unchanged |
| 77 | |
| 78 | // test non-empty cloud non_dense (with only invalid points) |
| 79 | point.x = point.y = point.z = std::numeric_limits<float>::quiet_NaN (); |
| 80 | cloud.push_back (point); |
| 81 | indices.push_back (1); |
| 82 | EXPECT_EQ (compute3DCentroid (cloud, indices, centroid), 0); |
| 83 | EXPECT_EQ (old_centroid, centroid); // centroid remains unchanged |
| 84 | |
| 85 | cloud.clear (); |
| 86 | indices.clear (); |
| 87 | for (point.x = -1; point.x < 2; point.x += 2) |
| 88 | { |
| 89 | for (point.y = -1; point.y < 2; point.y += 2) |
| 90 | { |
| 91 | for (point.z = -1; point.z < 2; point.z += 2) |
| 92 | { |
| 93 | cloud.push_back (point); |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | cloud.is_dense = true; |
| 98 | |
| 99 | // eight points with (0, 0, 0) as centroid and covarmat (1, 0, 0, 0, 1, 0, 0, 0, 1) |
| 100 | centroid [0] = -100; |
| 101 | centroid [1] = -200; |
| 102 | centroid [2] = -300; |
| 103 | |
| 104 | EXPECT_EQ (compute3DCentroid (cloud, centroid), 8); |
| 105 | EXPECT_EQ (centroid [0], 0); |
| 106 | EXPECT_EQ (centroid [1], 0); |
| 107 | EXPECT_EQ (centroid [2], 0); |
| 108 | EXPECT_EQ (centroid [3], 1); |
| 109 | |
| 110 | centroid [0] = -100; |
nothing calls this directly
no test coverage detected