/////////////////////////////////////////////////////////////////////////////////////////////////////////////
| 61 | |
| 62 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 63 | TEST (PCL, Organized) |
| 64 | { |
| 65 | //construct dataset |
| 66 | pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_organized (new pcl::PointCloud<pcl::PointXYZ> ()); |
| 67 | cloud_organized->width = 5; |
| 68 | cloud_organized->height = 10; |
| 69 | cloud_organized->points.resize (cloud_organized->width * cloud_organized->height); |
| 70 | |
| 71 | int npoints = 0; |
| 72 | for (std::size_t i = 0; i < cloud_organized->height; i++) |
| 73 | { |
| 74 | for (std::size_t j = 0; j < cloud_organized->width; j++) |
| 75 | { |
| 76 | (*cloud_organized)[npoints].x = static_cast<float> (i); |
| 77 | (*cloud_organized)[npoints].y = static_cast<float> (j); |
| 78 | (*cloud_organized)[npoints].z = static_cast<float> (cloud_organized->size ()); // to avoid shadowing |
| 79 | npoints++; |
| 80 | } |
| 81 | } |
| 82 | int nan_idx = cloud_organized->width*cloud_organized->height - 2*cloud_organized->width + 1; |
| 83 | (*cloud_organized)[nan_idx].x = std::numeric_limits<float>::quiet_NaN (); |
| 84 | (*cloud_organized)[nan_idx].y = std::numeric_limits<float>::quiet_NaN (); |
| 85 | (*cloud_organized)[nan_idx].z = std::numeric_limits<float>::quiet_NaN (); |
| 86 | |
| 87 | // Init objects |
| 88 | PolygonMesh triangles; |
| 89 | OrganizedFastMesh<PointXYZ> ofm; |
| 90 | |
| 91 | // Set parameters |
| 92 | ofm.setInputCloud (cloud_organized); |
| 93 | ofm.setMaxEdgeLength (1.5); |
| 94 | ofm.setTrianglePixelSize (1); |
| 95 | ofm.setTriangulationType (OrganizedFastMesh<PointXYZ>::TRIANGLE_ADAPTIVE_CUT); |
| 96 | |
| 97 | // Reconstruct |
| 98 | ofm.reconstruct (triangles); |
| 99 | //saveVTKFile ("./test/organized.vtk", triangles); |
| 100 | |
| 101 | // Check triangles |
| 102 | EXPECT_EQ (triangles.cloud.width, cloud_organized->width); |
| 103 | EXPECT_EQ (triangles.cloud.height, cloud_organized->height); |
| 104 | EXPECT_EQ (int (triangles.polygons.size ()), 2*(triangles.cloud.width-1)*(triangles.cloud.height-1) - 4); |
| 105 | EXPECT_EQ (int (triangles.polygons.at (0).vertices.size ()), 3); |
| 106 | EXPECT_EQ (int (triangles.polygons.at (0).vertices.at (0)), 0); |
| 107 | EXPECT_EQ (int (triangles.polygons.at (0).vertices.at (1)), triangles.cloud.width+1); |
| 108 | EXPECT_EQ (int (triangles.polygons.at (0).vertices.at (2)), 1); |
| 109 | } |
| 110 | |
| 111 | /* ---[ */ |
| 112 | int |
nothing calls this directly
no test coverage detected