Skip to content

Commit 188dc81

Browse files
feat: add unit test to KMeans clustering of normals
1 parent 9aadeff commit 188dc81

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/diffCheck/IOManager.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,11 @@ namespace diffCheck::io
6868
std::filesystem::path pathCloud = pathTestData / "test_pc_for_SOR_101pts_with_1_outlier.ply";
6969
return pathCloud.string();
7070
}
71+
72+
std::string GetTwoConnectedPlanesPlyPath()
73+
{
74+
std::filesystem::path pathTestData = GetTestDataDir();
75+
std::filesystem::path pathCloud = pathTestData / "two_connected_planes_with_normals.ply";
76+
return pathCloud.string();
77+
}
7178
} // namespace diffCheck::io

src/diffCheck/IOManager.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ namespace diffCheck::io
4242
std::string GetRoofQuarterPlyPath();
4343
/// @brief Get the path to the plane point cloud with one outlier
4444
std::string GetPlanePCWithOneOutliers();
45+
/// @brief Get the path to the two connected planes ply test file
46+
std::string GetTwoConnectedPlanesPlyPath();
4547
} // namespace diffCheck::io

tests/unit_tests/DFPointCloudTest.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,12 @@ TEST_F(DFPointCloudTestFixture, Transform) {
219219

220220
//-------------------------------------------------------------------------
221221
// Others
222-
//-------------------------------------------------------------------------
222+
//-------------------------------------------------------------------------
223+
224+
TEST_F(DFPointCloudTestFixture, KMeansClusteringOfNormals) {
225+
std::string path = diffCheck::io::GetTwoConnectedPlanesPlyPath();
226+
diffCheck::geometry::DFPointCloud dfPointCloud2Planes;
227+
dfPointCloud2Planes.LoadFromPLY(path);
228+
std::vector<Eigen::Vector3d> axes = dfPointCloud2Planes.GetPrincipalAxes(2);
229+
EXPECT_TRUE((axes[0] - Eigen::Vector3d(0, 0, 1)).norm() < 1e-2 || (axes[1] - Eigen::Vector3d(0, 0, 1)).norm() < 1e-2);
230+
}

0 commit comments

Comments
 (0)