/////////////////////////////////////////////////////////////////////////////////////////////////////////////
| 54 | |
| 55 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 56 | TEST (BoxClipper3D, Filters) |
| 57 | { |
| 58 | // PointCloud |
| 59 | // ------------------------------------------------------------------------- |
| 60 | |
| 61 | // Create cloud with center point and corner points |
| 62 | PointCloud<PointXYZ>::Ptr input (new PointCloud<PointXYZ> ()); |
| 63 | input->push_back (PointXYZ (0.0f, 0.0f, 0.0f)); |
| 64 | input->push_back (PointXYZ (0.9f, 0.9f, 0.9f)); |
| 65 | input->push_back (PointXYZ (0.9f, 0.9f, -0.9f)); |
| 66 | input->push_back (PointXYZ (0.9f, -0.9f, 0.9f)); |
| 67 | input->push_back (PointXYZ (-0.9f, 0.9f, 0.9f)); |
| 68 | input->push_back (PointXYZ (0.9f, -0.9f, -0.9f)); |
| 69 | input->push_back (PointXYZ (-0.9f, -0.9f, 0.9f)); |
| 70 | input->push_back (PointXYZ (-0.9f, 0.9f, -0.9f)); |
| 71 | input->push_back (PointXYZ (-0.9f, -0.9f, -0.9f)); |
| 72 | |
| 73 | ExtractIndices<PointXYZ> extract_indices; |
| 74 | pcl::Indices indices; |
| 75 | |
| 76 | BoxClipper3D<PointXYZ> boxClipper3D (Affine3f::Identity ()); |
| 77 | boxClipper3D.clipPointCloud3D (*input, indices); |
| 78 | |
| 79 | PointCloud<PointXYZ> cloud_out; |
| 80 | |
| 81 | extract_indices.setInputCloud (input); |
| 82 | extract_indices.setIndices (pcl::make_shared<pcl::Indices> (indices)); |
| 83 | extract_indices.filter (cloud_out); |
| 84 | |
| 85 | EXPECT_EQ (int (indices.size ()), 9); |
| 86 | EXPECT_EQ (int (cloud_out.size ()), 9); |
| 87 | EXPECT_EQ (int (cloud_out.width), 9); |
| 88 | EXPECT_EQ (int (cloud_out.height), 1); |
| 89 | |
| 90 | // Translate points by 1 in Y-axis ... |
| 91 | Affine3f t (Translation3f (0.0f, 1.0f, 0.0f)); |
| 92 | boxClipper3D.setTransformation (t); |
| 93 | boxClipper3D.clipPointCloud3D (*input, indices); |
| 94 | |
| 95 | EXPECT_EQ (int (indices.size ()), 5); |
| 96 | |
| 97 | // ... then rotate points +45 in Y-Axis |
| 98 | t.rotate (AngleAxisf (45.0f * static_cast<float>(M_PI) / 180.0f, Vector3f::UnitY ())); |
| 99 | boxClipper3D.setTransformation (t); |
| 100 | boxClipper3D.clipPointCloud3D (*input, indices); |
| 101 | EXPECT_EQ (int (indices.size ()), 1); |
| 102 | |
| 103 | // ... then rotate points -45 in Z-axis |
| 104 | t.rotate (AngleAxisf (-45.0f * static_cast<float>(M_PI) / 180.0f, Vector3f::UnitZ ())); |
| 105 | boxClipper3D.setTransformation (t); |
| 106 | boxClipper3D.clipPointCloud3D (*input, indices); |
| 107 | EXPECT_EQ (int (indices.size ()), 3); |
| 108 | |
| 109 | // ... then scale points by 2 |
| 110 | t.scale (2.0f); |
| 111 | boxClipper3D.setTransformation (t); |
| 112 | boxClipper3D.clipPointCloud3D (*input, indices); |
| 113 | EXPECT_EQ (int (indices.size ()), 1); |
nothing calls this directly
no test coverage detected