1- // #include "diffCheck.hh"
2-
3- // #include <iostream>
4- // #include <fstream>
5-
6- // #include <open3d/Open3D.h>
7- // // #include <open3d/t/geometry/RaycastingScene.h>
8-
9- // int main()
10- // {
11- // // import clouds
12- // std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr
13- // = std::make_shared<diffCheck::geometry::DFPointCloud>();
14- // std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr
15- // = std::make_shared<diffCheck::geometry::DFMesh>();
16-
17- // // create a sphere from o3d
18- // std::string pathCloud = R"(C:\Users\andre\Downloads\moved_04.ply)";
19- // std::string pathMesh = R"(C:\Users\andre\Downloads\meshtest.ply)";
20-
21- // dfPointCloudPtr->LoadFromPLY(pathCloud);
22- // dfMeshPtr->LoadFromPLY(pathMesh);
23-
24- // // open3d::geometry::TriangleMesh meshO3d = *dfMeshPtr->Cvt2O3DTriangleMesh();
25- // // open3d::geometry::PointCloud pointCloudO3d = *dfPointCloudPtr->Cvt2O3DPointCloud();
26-
27- // // auto rayCastingScene = open3d::t::geometry::RaycastingScene();
28- // // // Get the vertices of the mesh
29- // // std::vector<Eigen::Vector3d> vertices = meshO3d.vertices_;
30-
31- // // // Convert the vertices to a tensor
32- // // std::vector<float> verticesPosition;
33- // // for (const auto& vertex : vertices) {
34- // // verticesPosition.insert(verticesPosition.end(), vertex.data(), vertex.data() + 3);
35- // // }
36- // // open3d::core::Tensor verticesPositionTensor(verticesPosition.data(), {static_cast<int64_t>(vertices.size()), 3}, open3d::core::Dtype::Float32);
37-
38- // // std::vector<uint32_t> triangles;
39- // // for (int i = 0; i < meshO3d.triangles_.size(); i++) {
40- // // triangles.push_back(static_cast<uint32_t>(meshO3d.triangles_[i].x()));
41- // // triangles.push_back(static_cast<uint32_t>(meshO3d.triangles_[i].y()));
42- // // triangles.push_back(static_cast<uint32_t>(meshO3d.triangles_[i].z()));
43- // // }
44- // // open3d::core::Tensor trianglesTensor(triangles.data(), {static_cast<int64_t>(meshO3d.triangles_.size()), 3}, open3d::core::Dtype::UInt32);
1+ #include " diffCheck.hh"
2+
3+ #include < iostream>
4+ #include < fstream>
5+
6+ #include < open3d/Open3D.h>
7+ // #include <open3d/t/geometry/RaycastingScene.h>
8+
9+ int main ()
10+ {
11+ // import clouds
12+ std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr
13+ = std::make_shared<diffCheck::geometry::DFPointCloud>();
14+ std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr
15+ = std::make_shared<diffCheck::geometry::DFMesh>();
16+
17+ // create a sphere from o3d
18+ std::string pathCloud = R"( C:\Users\andre\Downloads\moved_04.ply)" ;
19+ std::string pathMesh = R"( C:\Users\andre\Downloads\meshtest.ply)" ;
20+
21+ dfPointCloudPtr->LoadFromPLY (pathCloud);
22+ dfMeshPtr->LoadFromPLY (pathMesh);
23+
24+ // open3d::geometry::TriangleMesh meshO3d = *dfMeshPtr->Cvt2O3DTriangleMesh();
25+ // open3d::geometry::PointCloud pointCloudO3d = *dfPointCloudPtr->Cvt2O3DPointCloud();
26+
27+ // auto rayCastingScene = open3d::t::geometry::RaycastingScene();
28+ // // Get the vertices of the mesh
29+ // std::vector<Eigen::Vector3d> vertices = meshO3d.vertices_;
30+
31+ // // Convert the vertices to a tensor
32+ // std::vector<float> verticesPosition;
33+ // for (const auto& vertex : vertices) {
34+ // verticesPosition.insert(verticesPosition.end(), vertex.data(), vertex.data() + 3);
35+ // }
36+ // open3d::core::Tensor verticesPositionTensor(verticesPosition.data(), {static_cast<int64_t>(vertices.size()), 3}, open3d::core::Dtype::Float32);
37+
38+ // std::vector<uint32_t> triangles;
39+ // for (int i = 0; i < meshO3d.triangles_.size(); i++) {
40+ // triangles.push_back(static_cast<uint32_t>(meshO3d.triangles_[i].x()));
41+ // triangles.push_back(static_cast<uint32_t>(meshO3d.triangles_[i].y()));
42+ // triangles.push_back(static_cast<uint32_t>(meshO3d.triangles_[i].z()));
43+ // }
44+ // open3d::core::Tensor trianglesTensor(triangles.data(), {static_cast<int64_t>(meshO3d.triangles_.size()), 3}, open3d::core::Dtype::UInt32);
4545
46- // // rayCastingScene.AddTriangles(verticesPositionTensor, trianglesTensor);
46+ // rayCastingScene.AddTriangles(verticesPositionTensor, trianglesTensor);
4747
48- // // // compute the cloud to mesh signed distance
49- // // std::vector<float> cloudPoints;
50- // // for (const auto& point : pointCloudO3d.points_) {
51- // // cloudPoints.insert(cloudPoints.end(), point.data(), point.data() + 3);
52- // // }
53- // // open3d::core::Tensor cloudPointsTensor(cloudPoints.data(), {static_cast<int64_t>(pointCloudO3d.points_.size()), 3}, open3d::core::Dtype::Float32);
48+ // // compute the cloud to mesh signed distance
49+ // std::vector<float> cloudPoints;
50+ // for (const auto& point : pointCloudO3d.points_) {
51+ // cloudPoints.insert(cloudPoints.end(), point.data(), point.data() + 3);
52+ // }
53+ // open3d::core::Tensor cloudPointsTensor(cloudPoints.data(), {static_cast<int64_t>(pointCloudO3d.points_.size()), 3}, open3d::core::Dtype::Float32);
5454
5555
56- // // open3d::core::Tensor sdf = rayCastingScene.ComputeSignedDistance(cloudPointsTensor);
56+ // open3d::core::Tensor sdf = rayCastingScene.ComputeSignedDistance(cloudPointsTensor);
5757
58- // // // FIXME: replace with bool parameter
59- // // // if true, get the absolute value of the sdf
60- // // if (true) {
61- // // sdf = sdf.Abs();
62- // // }
58+ // // FIXME: replace with bool parameter
59+ // // if true, get the absolute value of the sdf
60+ // if (true) {
61+ // sdf = sdf.Abs();
62+ // }
6363
64- // // convert sdf to a vector
65- // std::vector<float> sdfVector = dfMeshPtr->ComputeDistance(*dfPointCloudPtr);
64+ // convert sdf to a vector
65+ std::vector<float > sdfVector = dfMeshPtr->ComputeDistance (*dfPointCloudPtr);
6666
6767
68- // // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
69- // // compute point cloud to point cloud distance
70- // std::vector<double> distances = dfPointCloudPtr->ComputeDistance(*dfPointCloudPtr);
71- // // for (auto &dist : distances)
72- // // {
73- // // std::cout << dist << std::endl;
74- // // }
68+ // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
69+ // compute point cloud to point cloud distance
70+ std::vector<double > distances = dfPointCloudPtr->ComputeDistance (*dfPointCloudPtr);
71+ // for (auto &dist : distances)
72+ // {
73+ // std::cout << dist << std::endl;
74+ // }
7575
7676
7777
78- // // // convert the sphere to a diffCheck point cloud
79- // // // auto o3dPointCloud = meshO3d.SamplePointsUniformly(1000);
78+ // // convert the sphere to a diffCheck point cloud
79+ // // auto o3dPointCloud = meshO3d.SamplePointsUniformly(1000);
8080
81- // // std::shared_ptr<open3d::geometry::PointCloud> tightBBOX = std::make_shared<open3d::geometry::PointCloud>();
81+ // std::shared_ptr<open3d::geometry::PointCloud> tightBBOX = std::make_shared<open3d::geometry::PointCloud>();
8282
83- // // // compute the bounding box
84- // // open3d::geometry::OrientedBoundingBox bbox = meshO3d.GetMinimalOrientedBoundingBox();
85- // // std::vector<Eigen::Vector3d> bboxPts = bbox.GetBoxPoints();
86- // // for (auto &pt : bboxPts)
87- // // {
88- // // tightBBOX->points_.push_back(pt);
89- // // }
83+ // // compute the bounding box
84+ // open3d::geometry::OrientedBoundingBox bbox = meshO3d.GetMinimalOrientedBoundingBox();
85+ // std::vector<Eigen::Vector3d> bboxPts = bbox.GetBoxPoints();
86+ // for (auto &pt : bboxPts)
87+ // {
88+ // tightBBOX->points_.push_back(pt);
89+ // }
9090
9191
92- // // dfPointCloudPtr->Cvt2DFPointCloud(tightBBOX);
92+ // dfPointCloudPtr->Cvt2DFPointCloud(tightBBOX);
9393
9494
9595
9696
97- // // std::shared_ptr<diffCheck::visualizer::Visualizer> vis = std::make_shared<diffCheck::visualizer::Visualizer>();
98- // // vis->AddPointCloud(dfPointCloudPtr);
99- // // // vis->AddMesh(dfMeshPtr);
100- // // vis->Run();
97+ // std::shared_ptr<diffCheck::visualizer::Visualizer> vis = std::make_shared<diffCheck::visualizer::Visualizer>();
98+ // vis->AddPointCloud(dfPointCloudPtr);
99+ // // vis->AddMesh(dfMeshPtr);
100+ // vis->Run();
101101
102102
103- // return 0;
104- // }
103+ return 0 ;
104+ }
0 commit comments