@@ -9,15 +9,22 @@ int main()
99{
1010 // import clouds
1111 std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr = std::make_shared<diffCheck::geometry::DFPointCloud>();
12+ std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr_1 = std::make_shared<diffCheck::geometry::DFPointCloud>();
13+ std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr_2 = std::make_shared<diffCheck::geometry::DFPointCloud>();
14+ std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrWithoutNormals = std::make_shared<diffCheck::geometry::DFPointCloud>();
1215 std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrGroundTruth = std::make_shared<diffCheck::geometry::DFPointCloud>();
1316 std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrGroundTruthFromMesh = std::make_shared<diffCheck::geometry::DFPointCloud>();
1417 std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr = std::make_shared<diffCheck::geometry::DFMesh>();
1518
16- std::string pathCloud = R"( C:\Users\localuser\Downloads\00_pt.ply)" ;
17- std::string pathMesh = R"( C:\Users\localuser\Downloads\00_mesh.ply)" ;
19+ std::string pathCloud = R"( C:\Users\localuser\Downloads\04_pt.ply)" ;
20+ std::string pathCloud_1 = R"( C:\Users\localuser\Downloads\part_1_module.ply)" ;
21+ std::string pathCloud_2 = R"( C:\Users\localuser\Downloads\part_2_module.ply)" ;
22+ std::string pathMesh = R"( C:\Users\localuser\Downloads\04_mesh.ply)" ;
1823
1924 dfMeshPtr->LoadFromPLY (pathMesh);
2025 dfPointCloudPtr->LoadFromPLY (pathCloud);
26+ dfPointCloudPtr_1->LoadFromPLY (pathCloud_1);
27+ dfPointCloudPtr_2->LoadFromPLY (pathCloud_2);
2128 dfPointCloudPtrGroundTruth->LoadFromPLY (pathCloud);
2229
2330 // add noise to dfPointCloudPtr
@@ -27,40 +34,47 @@ int main()
2734 {
2835 dfPointCloudPtr->Points [i] += Eigen::Vector3d::Random () * 0.002 * meanInterval;
2936 }
37+
38+ std::shared_ptr<open3d::geometry::PointCloud> pcd_1 = dfPointCloudPtr->Cvt2O3DPointCloud ();
39+ if (pcd_1->normals_ .size () > 0 )
40+ {
41+ pcd_1->normals_ .clear ();
42+ }
43+ dfPointCloudPtrWithoutNormals->Cvt2DFPointCloud (pcd_1);
3044
3145 // populate the mesh with points and store it in dfPointCloudPtrGroundTruthFromMesh
32- std::shared_ptr<open3d::geometry::PointCloud> pcd_1 = dfMeshPtr->Cvt2O3DTriangleMesh ()->SamplePointsUniformly (50000 );
33- dfPointCloudPtrGroundTruthFromMesh->Cvt2DFPointCloud (pcd_1 );
46+ std::shared_ptr<open3d::geometry::PointCloud> pcd_2 = dfMeshPtr->Cvt2O3DTriangleMesh ()->SamplePointsUniformly (50000 );
47+ dfPointCloudPtrGroundTruthFromMesh->Cvt2DFPointCloud (pcd_2 );
3448
3549 // create a rigid rotation matrix
3650 Eigen::Matrix4d T = Eigen::Matrix4d::Identity ();
3751 T.block <3 , 3 >(0 , 0 ) = Eigen::AngleAxisd (1.57 , Eigen::Vector3d::UnitX ()).toRotationMatrix ();
38- T (0 , 3 ) = 5 ;
39- T (1 , 3 ) = -10 ;
40- T (2 , 3 ) = 10 ;
41- dfPointCloudPtr ->ApplyTransformation (diffCheck::transformation::DFTransformation (T));
52+ T (0 , 3 ) = 50 ;
53+ T (1 , 3 ) = -100 ;
54+ T (2 , 3 ) = 100 ;
55+ dfPointCloudPtrWithoutNormals ->ApplyTransformation (diffCheck::transformation::DFTransformation (T));
4256
4357 // create a copy of the point cloud so we can test both global registrations
44- std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrCopy = std::make_shared<diffCheck::geometry::DFPointCloud>(*dfPointCloudPtr );
58+ std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtrCopy = std::make_shared<diffCheck::geometry::DFPointCloud>(*dfPointCloudPtrWithoutNormals );
4559
4660 // test global registrations Fast and RANSAC-based
4761 std::vector<diffCheck::transformation::DFTransformation> registrationResults;
4862 diffCheck::transformation::DFTransformation transformationA =
49- diffCheck::registrations::DFGlobalRegistrations::O3DFastGlobalRegistrationFeatureMatching (dfPointCloudPtr, dfPointCloudPtrGroundTruth );
63+ diffCheck::registrations::DFGlobalRegistrations::O3DFastGlobalRegistrationFeatureMatching (dfPointCloudPtr_1, dfPointCloudPtr_2 );
5064 std::cout << " Fast transformation: " << transformationA.TransformationMatrix << std::endl;
51- dfPointCloudPtr ->ApplyTransformation (transformationA);
65+ // dfPointCloudPtr_1 ->ApplyTransformation(transformationA);
5266 registrationResults.push_back (transformationA);
5367 diffCheck::transformation::DFTransformation transformationB =
54- diffCheck::registrations::DFGlobalRegistrations::O3DRansacOnFeatureMatching (dfPointCloudPtrCopy, dfPointCloudPtrGroundTruthFromMesh );
68+ diffCheck::registrations::DFGlobalRegistrations::O3DRansacOnFeatureMatching (dfPointCloudPtr_1, dfPointCloudPtr_2 );
5569 std::cout << " Ransac transformation: " << transformationB.TransformationMatrix << std::endl;
56- dfPointCloudPtrCopy ->ApplyTransformation (transformationB);
70+ dfPointCloudPtr_1 ->ApplyTransformation (transformationB);
5771 registrationResults.push_back (transformationB);
5872
5973 // visualize cloud
6074 std::shared_ptr<diffCheck::visualizer::Visualizer> visualizer = std::make_shared<diffCheck::visualizer::Visualizer>();
61- visualizer->AddPointCloud (dfPointCloudPtrCopy );
62- visualizer->AddPointCloud (dfPointCloudPtr );
63- visualizer->AddMesh (dfMeshPtr);
75+ visualizer->AddPointCloud (dfPointCloudPtr_1 );
76+ visualizer->AddPointCloud (dfPointCloudPtr_2 );
77+ // visualizer->AddMesh(dfMeshPtr);
6478 visualizer->Run ();
6579
6680 return 0 ;
0 commit comments