Skip to content

Commit 87adf1a

Browse files
committed
WIP: reintroducing the c++ test suite with ply
1 parent 18ce250 commit 87adf1a

File tree

1 file changed

+165
-165
lines changed

1 file changed

+165
-165
lines changed

tests/unit_tests/DFPointCloudTest.cc

Lines changed: 165 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class DFPointCloudTestFixture : public ::testing::Test {
1111

1212
DFPointCloudTestFixture() : dfPointCloud(points, colors, normals) {}
1313

14-
// void SetUp() override {
15-
// dfPointCloud = diffCheck::geometry::DFPointCloud();
16-
// std::string pathTest = diffCheck::io::GetRoofQuarterPlyPath();
17-
// dfPointCloud.LoadFromPLY(diffCheck::io::GetRoofQuarterPlyPath());
18-
// }
19-
20-
// void TearDown() override {
21-
// // Clean up any resources if needed
22-
// }
14+
void SetUp() override {
15+
dfPointCloud = diffCheck::geometry::DFPointCloud();
16+
std::string pathTest = diffCheck::io::GetRoofQuarterPlyPath();
17+
dfPointCloud.LoadFromPLY(diffCheck::io::GetRoofQuarterPlyPath());
18+
}
19+
20+
void TearDown() override {
21+
// Clean up any resources if needed
22+
}
2323
};
2424

2525
//-------------------------------------------------------------------------
@@ -33,159 +33,159 @@ TEST_F(DFPointCloudTestFixture, Constructor) {
3333
EXPECT_EQ(dfPointCloud.GetNumNormals(), 0);
3434
}
3535

36-
// TEST_F(DFPointCloudTestFixture, ConstructorWithVectors) {
37-
// std::vector<Eigen::Vector3d> points;
38-
// std::vector<Eigen::Vector3d> colors;
39-
// std::vector<Eigen::Vector3d> normals;
40-
// diffCheck::geometry::DFPointCloud dfPointCloud(points, colors, normals);
41-
// EXPECT_EQ(dfPointCloud.GetNumPoints(), 0);
42-
// EXPECT_EQ(dfPointCloud.GetNumColors(), 0);
43-
// EXPECT_EQ(dfPointCloud.GetNumNormals(), 0);
44-
// }
45-
46-
// //-------------------------------------------------------------------------
47-
// // i/o
48-
// //-------------------------------------------------------------------------
49-
50-
// TEST_F(DFPointCloudTestFixture, LoadFromPLY) {
51-
// EXPECT_EQ(dfPointCloud.GetNumPoints(), 7379);
52-
// EXPECT_EQ(dfPointCloud.GetNumColors(), 7379);
53-
// EXPECT_EQ(dfPointCloud.GetNumNormals(), 7379);
54-
55-
// }
56-
57-
// //-------------------------------------------------------------------------
58-
// // properties
59-
// //-------------------------------------------------------------------------
60-
61-
// TEST_F(DFPointCloudTestFixture, GetNumPoints){
62-
// EXPECT_EQ(dfPointCloud.GetNumPoints(), 7379);
63-
// }
64-
65-
// TEST_F(DFPointCloudTestFixture, GetNumColors) {
66-
// EXPECT_EQ(dfPointCloud.GetNumColors(), 7379);
67-
// }
68-
69-
// TEST_F(DFPointCloudTestFixture, GetNumNormals) {
70-
// EXPECT_EQ(dfPointCloud.GetNumNormals(), 7379);
71-
// }
72-
73-
// TEST_F(DFPointCloudTestFixture, HasPoints) {
74-
// EXPECT_TRUE(dfPointCloud.HasPoints());
75-
// }
76-
77-
// TEST_F(DFPointCloudTestFixture, HasColors) {
78-
// EXPECT_TRUE(dfPointCloud.HasColors());
79-
// }
80-
81-
// TEST_F(DFPointCloudTestFixture, HasNormals) {
82-
// EXPECT_TRUE(dfPointCloud.HasNormals());
83-
// }
84-
85-
// //-------------------------------------------------------------------------
86-
// // converters
87-
// //-------------------------------------------------------------------------
88-
89-
// TEST_F(DFPointCloudTestFixture, ConvertionO3dPointCloud) {
90-
// std::shared_ptr<open3d::geometry::PointCloud> o3dPointCloud = dfPointCloud.Cvt2O3DPointCloud();
91-
// std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloud2 = std::make_shared<diffCheck::geometry::DFPointCloud>();
92-
// dfPointCloud2->Cvt2DFPointCloud(o3dPointCloud);
93-
94-
// EXPECT_EQ(dfPointCloud.GetNumPoints(), dfPointCloud2->GetNumPoints());
95-
// EXPECT_EQ(dfPointCloud.GetNumColors(), dfPointCloud2->GetNumColors());
96-
// EXPECT_EQ(dfPointCloud.GetNumNormals(), dfPointCloud2->GetNumNormals());
97-
// }
98-
99-
// TEST_F(DFPointCloudTestFixture, ConvertionCilantroPointCloud) {
100-
// std::shared_ptr<cilantro::PointCloud3f> cilantroPointCloud = dfPointCloud.Cvt2CilantroPointCloud();
101-
// std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloud2 = std::make_shared<diffCheck::geometry::DFPointCloud>();
102-
// dfPointCloud2->Cvt2DFPointCloud(cilantroPointCloud);
103-
104-
// EXPECT_EQ(dfPointCloud.GetNumPoints(), dfPointCloud2->GetNumPoints());
105-
// EXPECT_EQ(dfPointCloud.GetNumColors(), dfPointCloud2->GetNumColors());
106-
// EXPECT_EQ(dfPointCloud.GetNumNormals(), dfPointCloud2->GetNumNormals());
107-
// }
108-
109-
// //-------------------------------------------------------------------------
110-
// // utilities
111-
// //-------------------------------------------------------------------------
112-
113-
// TEST_F(DFPointCloudTestFixture, ComputeP2PDistance) {
114-
// std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloud2 = std::make_shared<diffCheck::geometry::DFPointCloud>();
115-
// dfPointCloud2->LoadFromPLY(diffCheck::io::GetRoofQuarterPlyPath());
116-
// std::vector<double> distances = dfPointCloud.ComputeP2PDistance(dfPointCloud2);
117-
// EXPECT_EQ(distances.size(), 7379);
118-
// }
119-
120-
// TEST_F(DFPointCloudTestFixture, ComputeAABB) {
121-
// std::vector<Eigen::Vector3d> bbox = dfPointCloud.ComputeBoundingBox();
122-
// EXPECT_EQ(bbox.size(), 2);
123-
// }
124-
125-
// TEST_F(DFPointCloudTestFixture, ComputeOBB) {
126-
// std::vector<Eigen::Vector3d> obb = dfPointCloud.GetTightBoundingBox();
127-
// EXPECT_EQ(obb.size(), 8);
128-
// }
129-
130-
// TEST_F(DFPointCloudTestFixture, EstimateNormals) {
131-
// // knn
132-
// dfPointCloud.EstimateNormals();
133-
// EXPECT_EQ(dfPointCloud.GetNumNormals(), 7379);
134-
// // radius
135-
// dfPointCloud.EstimateNormals(false, 50, 0.1);
136-
// }
137-
138-
// TEST_F(DFPointCloudTestFixture, ApplyColor) {
139-
// dfPointCloud.ApplyColor(Eigen::Vector3d(1.0, 0.0, 0.0));
140-
// for (int i = 0; i < dfPointCloud.GetNumColors(); i++) {
141-
// EXPECT_EQ(dfPointCloud.Colors[i], Eigen::Vector3d(1.0, 0.0, 0.0));
142-
// }
143-
// dfPointCloud.ApplyColor(255, 0, 0);
144-
// for (int i = 0; i < dfPointCloud.GetNumColors(); i++) {
145-
// EXPECT_EQ(dfPointCloud.Colors[i], Eigen::Vector3d(1.0, 0.0, 0.0));
146-
// }
147-
// }
148-
149-
// //-------------------------------------------------------------------------
150-
// // Downsamplers
151-
// //-------------------------------------------------------------------------
152-
153-
// TEST_F(DFPointCloudTestFixture, Downsample) {
154-
// dfPointCloud.VoxelDownsample(0.1);
155-
// std::cout << "after downsampling .. " << dfPointCloud.GetNumPoints() << std::endl;
156-
// EXPECT_LT(dfPointCloud.GetNumPoints(), 7379);
157-
// DFPointCloudTestFixture::SetUp();
158-
159-
// dfPointCloud.UniformDownsample(2);
160-
// std::cout << "after downsampling .. " << dfPointCloud.GetNumPoints() << std::endl;
161-
// EXPECT_LT(dfPointCloud.GetNumPoints(), 7379);
162-
// DFPointCloudTestFixture::SetUp();
163-
164-
// dfPointCloud.DownsampleBySize(1000);
165-
// std::cout << "after downsampling .. " << dfPointCloud.GetNumPoints() << std::endl;
166-
// EXPECT_LT(dfPointCloud.GetNumPoints(), 1000);
167-
// DFPointCloudTestFixture::SetUp();
168-
// }
169-
170-
// //-------------------------------------------------------------------------
171-
// // Transformers
172-
// //-------------------------------------------------------------------------
173-
174-
// TEST_F(DFPointCloudTestFixture, Transform) {
175-
// Eigen::Matrix4d transformationMatrix = Eigen::Matrix4d::Identity();
176-
// diffCheck::transformation::DFTransformation transformation = diffCheck::transformation::DFTransformation(transformationMatrix);
177-
// dfPointCloud.ApplyTransformation(transformation);
178-
179-
// std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloud2 = std::make_shared<diffCheck::geometry::DFPointCloud>();
180-
// dfPointCloud2->LoadFromPLY(diffCheck::io::GetRoofQuarterPlyPath());
181-
// dfPointCloud2->ApplyTransformation(transformation);
182-
183-
// std::vector<double> distances = dfPointCloud.ComputeP2PDistance(dfPointCloud2);
184-
// for (int i = 0; i < distances.size(); i++) {
185-
// EXPECT_EQ(distances[i], 0);
186-
// }
187-
// }
188-
189-
// //-------------------------------------------------------------------------
190-
// // Others
191-
// //-------------------------------------------------------------------------
36+
TEST_F(DFPointCloudTestFixture, ConstructorWithVectors) {
37+
std::vector<Eigen::Vector3d> points;
38+
std::vector<Eigen::Vector3d> colors;
39+
std::vector<Eigen::Vector3d> normals;
40+
diffCheck::geometry::DFPointCloud dfPointCloud(points, colors, normals);
41+
EXPECT_EQ(dfPointCloud.GetNumPoints(), 0);
42+
EXPECT_EQ(dfPointCloud.GetNumColors(), 0);
43+
EXPECT_EQ(dfPointCloud.GetNumNormals(), 0);
44+
}
45+
46+
//-------------------------------------------------------------------------
47+
// i/o
48+
//-------------------------------------------------------------------------
49+
50+
TEST_F(DFPointCloudTestFixture, LoadFromPLY) {
51+
EXPECT_EQ(dfPointCloud.GetNumPoints(), 7379);
52+
EXPECT_EQ(dfPointCloud.GetNumColors(), 7379);
53+
EXPECT_EQ(dfPointCloud.GetNumNormals(), 7379);
54+
55+
}
56+
57+
//-------------------------------------------------------------------------
58+
// properties
59+
//-------------------------------------------------------------------------
60+
61+
TEST_F(DFPointCloudTestFixture, GetNumPoints){
62+
EXPECT_EQ(dfPointCloud.GetNumPoints(), 7379);
63+
}
64+
65+
TEST_F(DFPointCloudTestFixture, GetNumColors) {
66+
EXPECT_EQ(dfPointCloud.GetNumColors(), 7379);
67+
}
68+
69+
TEST_F(DFPointCloudTestFixture, GetNumNormals) {
70+
EXPECT_EQ(dfPointCloud.GetNumNormals(), 7379);
71+
}
72+
73+
TEST_F(DFPointCloudTestFixture, HasPoints) {
74+
EXPECT_TRUE(dfPointCloud.HasPoints());
75+
}
76+
77+
TEST_F(DFPointCloudTestFixture, HasColors) {
78+
EXPECT_TRUE(dfPointCloud.HasColors());
79+
}
80+
81+
TEST_F(DFPointCloudTestFixture, HasNormals) {
82+
EXPECT_TRUE(dfPointCloud.HasNormals());
83+
}
84+
85+
//-------------------------------------------------------------------------
86+
// converters
87+
//-------------------------------------------------------------------------
88+
89+
TEST_F(DFPointCloudTestFixture, ConvertionO3dPointCloud) {
90+
std::shared_ptr<open3d::geometry::PointCloud> o3dPointCloud = dfPointCloud.Cvt2O3DPointCloud();
91+
std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloud2 = std::make_shared<diffCheck::geometry::DFPointCloud>();
92+
dfPointCloud2->Cvt2DFPointCloud(o3dPointCloud);
93+
94+
EXPECT_EQ(dfPointCloud.GetNumPoints(), dfPointCloud2->GetNumPoints());
95+
EXPECT_EQ(dfPointCloud.GetNumColors(), dfPointCloud2->GetNumColors());
96+
EXPECT_EQ(dfPointCloud.GetNumNormals(), dfPointCloud2->GetNumNormals());
97+
}
98+
99+
TEST_F(DFPointCloudTestFixture, ConvertionCilantroPointCloud) {
100+
std::shared_ptr<cilantro::PointCloud3f> cilantroPointCloud = dfPointCloud.Cvt2CilantroPointCloud();
101+
std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloud2 = std::make_shared<diffCheck::geometry::DFPointCloud>();
102+
dfPointCloud2->Cvt2DFPointCloud(cilantroPointCloud);
103+
104+
EXPECT_EQ(dfPointCloud.GetNumPoints(), dfPointCloud2->GetNumPoints());
105+
EXPECT_EQ(dfPointCloud.GetNumColors(), dfPointCloud2->GetNumColors());
106+
EXPECT_EQ(dfPointCloud.GetNumNormals(), dfPointCloud2->GetNumNormals());
107+
}
108+
109+
//-------------------------------------------------------------------------
110+
// utilities
111+
//-------------------------------------------------------------------------
112+
113+
TEST_F(DFPointCloudTestFixture, ComputeP2PDistance) {
114+
std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloud2 = std::make_shared<diffCheck::geometry::DFPointCloud>();
115+
dfPointCloud2->LoadFromPLY(diffCheck::io::GetRoofQuarterPlyPath());
116+
std::vector<double> distances = dfPointCloud.ComputeP2PDistance(dfPointCloud2);
117+
EXPECT_EQ(distances.size(), 7379);
118+
}
119+
120+
TEST_F(DFPointCloudTestFixture, ComputeAABB) {
121+
std::vector<Eigen::Vector3d> bbox = dfPointCloud.ComputeBoundingBox();
122+
EXPECT_EQ(bbox.size(), 2);
123+
}
124+
125+
TEST_F(DFPointCloudTestFixture, ComputeOBB) {
126+
std::vector<Eigen::Vector3d> obb = dfPointCloud.GetTightBoundingBox();
127+
EXPECT_EQ(obb.size(), 8);
128+
}
129+
130+
TEST_F(DFPointCloudTestFixture, EstimateNormals) {
131+
// knn
132+
dfPointCloud.EstimateNormals();
133+
EXPECT_EQ(dfPointCloud.GetNumNormals(), 7379);
134+
// radius
135+
dfPointCloud.EstimateNormals(false, 50, 0.1);
136+
}
137+
138+
TEST_F(DFPointCloudTestFixture, ApplyColor) {
139+
dfPointCloud.ApplyColor(Eigen::Vector3d(1.0, 0.0, 0.0));
140+
for (int i = 0; i < dfPointCloud.GetNumColors(); i++) {
141+
EXPECT_EQ(dfPointCloud.Colors[i], Eigen::Vector3d(1.0, 0.0, 0.0));
142+
}
143+
dfPointCloud.ApplyColor(255, 0, 0);
144+
for (int i = 0; i < dfPointCloud.GetNumColors(); i++) {
145+
EXPECT_EQ(dfPointCloud.Colors[i], Eigen::Vector3d(1.0, 0.0, 0.0));
146+
}
147+
}
148+
149+
//-------------------------------------------------------------------------
150+
// Downsamplers
151+
//-------------------------------------------------------------------------
152+
153+
TEST_F(DFPointCloudTestFixture, Downsample) {
154+
dfPointCloud.VoxelDownsample(0.1);
155+
std::cout << "after downsampling .. " << dfPointCloud.GetNumPoints() << std::endl;
156+
EXPECT_LT(dfPointCloud.GetNumPoints(), 7379);
157+
DFPointCloudTestFixture::SetUp();
158+
159+
dfPointCloud.UniformDownsample(2);
160+
std::cout << "after downsampling .. " << dfPointCloud.GetNumPoints() << std::endl;
161+
EXPECT_LT(dfPointCloud.GetNumPoints(), 7379);
162+
DFPointCloudTestFixture::SetUp();
163+
164+
dfPointCloud.DownsampleBySize(1000);
165+
std::cout << "after downsampling .. " << dfPointCloud.GetNumPoints() << std::endl;
166+
EXPECT_LT(dfPointCloud.GetNumPoints(), 1000);
167+
DFPointCloudTestFixture::SetUp();
168+
}
169+
170+
//-------------------------------------------------------------------------
171+
// Transformers
172+
//-------------------------------------------------------------------------
173+
174+
TEST_F(DFPointCloudTestFixture, Transform) {
175+
Eigen::Matrix4d transformationMatrix = Eigen::Matrix4d::Identity();
176+
diffCheck::transformation::DFTransformation transformation = diffCheck::transformation::DFTransformation(transformationMatrix);
177+
dfPointCloud.ApplyTransformation(transformation);
178+
179+
std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloud2 = std::make_shared<diffCheck::geometry::DFPointCloud>();
180+
dfPointCloud2->LoadFromPLY(diffCheck::io::GetRoofQuarterPlyPath());
181+
dfPointCloud2->ApplyTransformation(transformation);
182+
183+
std::vector<double> distances = dfPointCloud.ComputeP2PDistance(dfPointCloud2);
184+
for (int i = 0; i < distances.size(); i++) {
185+
EXPECT_EQ(distances[i], 0);
186+
}
187+
}
188+
189+
//-------------------------------------------------------------------------
190+
// Others
191+
//-------------------------------------------------------------------------

0 commit comments

Comments
 (0)