|
3 | 3 | #include <iostream> |
4 | 4 | #include <fstream> |
5 | 5 |
|
| 6 | +#include <open3d/Open3D.h> |
| 7 | +// #include <open3d/t/geometry/RaycastingScene.h> |
6 | 8 |
|
7 | 9 | int main() |
8 | 10 | { |
9 | 11 | // import clouds |
10 | | - std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr |
| 12 | + std::shared_ptr<diffCheck::geometry::DFPointCloud> dfPointCloudPtr |
11 | 13 | = std::make_shared<diffCheck::geometry::DFPointCloud>(); |
12 | 14 | std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr |
13 | 15 | = std::make_shared<diffCheck::geometry::DFMesh>(); |
14 | 16 |
|
15 | 17 | // create a sphere from o3d |
16 | | - std::string pathCloud = R"(C:\andre\Downloads\moved_04.ply)"; |
| 18 | + std::string pathCloud = R"(C:\Users\andre\Downloads\moved_04.ply)"; |
17 | 19 | std::string pathMesh = R"(C:\Users\andre\Downloads\meshtest.ply)"; |
18 | 20 |
|
19 | | - // dfPointCloudPtr->LoadFromPLY(pathCloud); |
| 21 | + dfPointCloudPtr->LoadFromPLY(pathCloud); |
20 | 22 | dfMeshPtr->LoadFromPLY(pathMesh); |
21 | 23 |
|
22 | | - open3d::geometry::TriangleMesh meshO3d = *dfMeshPtr->Cvt2O3DTriangleMesh(); |
| 24 | +// open3d::geometry::TriangleMesh meshO3d = *dfMeshPtr->Cvt2O3DTriangleMesh(); |
| 25 | +// open3d::geometry::PointCloud pointCloudO3d = *dfPointCloudPtr->Cvt2O3DPointCloud(); |
23 | 26 |
|
| 27 | +// auto rayCastingScene = open3d::t::geometry::RaycastingScene(); |
| 28 | +// // Get the vertices of the mesh |
| 29 | +// std::vector<Eigen::Vector3d> vertices = meshO3d.vertices_; |
24 | 30 |
|
25 | | - // convert the sphere to a diffCheck point cloud |
26 | | - // auto o3dPointCloud = meshO3d.SamplePointsUniformly(1000); |
| 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); |
27 | 37 |
|
28 | | - std::shared_ptr<open3d::geometry::PointCloud> tightBBOX = std::make_shared<open3d::geometry::PointCloud>(); |
| 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); |
| 45 | + |
| 46 | +// rayCastingScene.AddTriangles(verticesPositionTensor, trianglesTensor); |
29 | 47 |
|
30 | | - // compute the bounding box |
31 | | - open3d::geometry::OrientedBoundingBox bbox = meshO3d.GetMinimalOrientedBoundingBox(); |
32 | | - std::vector<Eigen::Vector3d> bboxPts = bbox.GetBoxPoints(); |
33 | | - for (auto &pt : bboxPts) |
34 | | - { |
35 | | - tightBBOX->points_.push_back(pt); |
36 | | - } |
| 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); |
37 | 54 |
|
38 | 55 |
|
39 | | - dfPointCloudPtr->Cvt2DFPointCloud(tightBBOX); |
| 56 | +// open3d::core::Tensor sdf = rayCastingScene.ComputeSignedDistance(cloudPointsTensor); |
40 | 57 |
|
| 58 | +// // FIXME: replace with bool parameter |
| 59 | +// // if true, get the absolute value of the sdf |
| 60 | +// if (true) { |
| 61 | +// sdf = sdf.Abs(); |
| 62 | +// } |
41 | 63 |
|
| 64 | + // convert sdf to a vector |
| 65 | + std::vector<float> sdfVector = dfMeshPtr->ComputeDistance(*dfPointCloudPtr); |
42 | 66 |
|
43 | 67 |
|
44 | | - std::shared_ptr<diffCheck::visualizer::Visualizer> vis = std::make_shared<diffCheck::visualizer::Visualizer>(); |
45 | | - vis->AddPointCloud(dfPointCloudPtr); |
46 | | - // vis->AddMesh(dfMeshPtr); |
47 | | - vis->Run(); |
| 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 | +// } |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + // // convert the sphere to a diffCheck point cloud |
| 79 | + // // auto o3dPointCloud = meshO3d.SamplePointsUniformly(1000); |
| 80 | + |
| 81 | + // std::shared_ptr<open3d::geometry::PointCloud> tightBBOX = std::make_shared<open3d::geometry::PointCloud>(); |
| 82 | + |
| 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 | + // } |
| 90 | + |
| 91 | + |
| 92 | + // dfPointCloudPtr->Cvt2DFPointCloud(tightBBOX); |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 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(); |
48 | 101 |
|
49 | 102 |
|
50 | 103 | return 0; |
|
0 commit comments