99int main ()
1010{
1111 // import clouds
12- std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr
12+ std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr
1313 = std::make_shared<diffCheck::geometry::DFPointCloud>();
1414 std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr
1515 = std::make_shared<diffCheck::geometry::DFMesh>();
@@ -21,56 +21,57 @@ int main()
2121 dfPointCloudPtr->LoadFromPLY (pathCloud);
2222 dfMeshPtr->LoadFromPLY (pathMesh);
2323
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);
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- // if true, get the absolute value of the sdf
59- if (true ) {
60- sdf = sdf.Abs ();
61- }
58+ // // FIXME: replace with bool parameter
59+ // // if true, get the absolute value of the sdf
60+ // if (true) {
61+ // sdf = sdf.Abs();
62+ // }
6263
6364 // convert sdf to a vector
64- std::vector<float > sdfVector (sdf. GetDataPtr < float >(), sdf. GetDataPtr < float >() + sdf. NumElements () );
65+ std::vector<float > sdfVector = dfMeshPtr-> ComputeDistance (*dfPointCloudPtr );
6566
6667
6768 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
6869 // compute point cloud to point cloud distance
69- auto distances = dfPointCloudPtr->ComputeP2PDistance ( dfPointCloudPtr);
70- for (auto &dist : distances)
71- {
72- std::cout << dist << std::endl;
73- }
70+ std::vector< double > distances = dfPointCloudPtr->ComputeDistance (* dfPointCloudPtr);
71+ // for (auto &dist : distances)
72+ // {
73+ // std::cout << dist << std::endl;
74+ // }
7475
7576
7677
0 commit comments