Skip to content

Commit b1cb0e6

Browse files
committed
WIP-FIX: testing full test suite ci
1 parent b66ee8c commit b1cb0e6

File tree

3 files changed

+182
-170
lines changed

3 files changed

+182
-170
lines changed

src/diffCheck/IOManager.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "diffCheck/log.hh"
66

7+
#include <cstdlib>
78
#include <filesystem>
89
#include <iostream>
910
#include <fstream>
@@ -29,8 +30,19 @@ namespace diffCheck::io
2930

3031
std::string GetTestDataDir()
3132
{
32-
std::filesystem::path path = std::filesystem::path(__FILE__).parent_path().parent_path().parent_path();
33-
std::filesystem::path pathTestData = path / "tests" / "test_data";
33+
// for github action conviniency
34+
const char* env_p = std::getenv("DF_TEST_DATA_DIR");
35+
std::filesystem::path pathTestData;
36+
if (env_p != nullptr)
37+
{
38+
pathTestData = std::filesystem::path(env_p);
39+
}
40+
else
41+
{
42+
std::filesystem::path path = std::filesystem::path(__FILE__).parent_path().parent_path().parent_path();
43+
pathTestData = path / "tests" / "test_data";
44+
}
45+
pathTestData = std::filesystem::absolute(pathTestData);
3446
return pathTestData.string();
3547
}
3648

tests/integration_tests/pybinds_tests/test_pybind_units.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
print(file)
2020
sys.exit(1)
2121

22+
# import data files with correct path (also for GitHub Actions)
2223
def get_ply_cloud_roof_quarter_path():
2324
base_test_data_dir = os.getenv('DF_TEST_DATA_DIR', os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'test_data')))
2425
ply_file_path = os.path.join(base_test_data_dir, "roof_quarter.ply")
2526
if not os.path.exists(ply_file_path):
2627
raise FileNotFoundError(f"PLY file not found at: {ply_file_path}")
27-
print(f"base_test_data_dir: {base_test_data_dir}") #TODO: Debug
28-
print(f"ply_file_path: {ply_file_path}") #TODO: Debug
2928
return ply_file_path
3029

3130
#------------------------------------------------------------------------------
@@ -100,7 +99,8 @@ def test_DFPointCloud_compute_normals(create_DFPointCloudSampleRoof):
10099
def test_DFPointCloud_get_tight_bounding_box(create_DFPointCloudSampleRoof):
101100
pc = create_DFPointCloudSampleRoof
102101
obb = pc.get_tight_bounding_box()
103-
assert obb[0][0] == 0.1955558282162114, "The min x of the OBB should be 0.1955558282162114"
102+
# round to the 3 decimal places
103+
assert round(obb[0][0], 3) == 0.196, "The min x of the OBB should be 0.196"
104104

105105
# TODO: to implement DFMesh tests
106106
def test_DFMesh_init():

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, ComputeDistance) {
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.ComputeDistance(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.ComputeDistance(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)