Repository navigation
VTK based implementation of extract trianglemesh - #6648
Conversation
|
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes. |
theNded
left a comment
There was a problem hiding this comment.
Thanks for the PR! Please kindly check my comments. The PR also needs unit tests and benchmarking.
VTK version is more limited (does not allow weights and the perturbation of isosurface). Additional overhead is added through memory copy from TSDFVolume to VTK and tensor mesh to legacy mesh (they can be potentially optimized).
I think it would be fine to merge the PR if we can justify that the VTK version is faster. Otherwise, it might be good to rethink the necessity.
| std::shared_ptr<geometry::PointCloud> ExtractPointCloud() override; | ||
| std::shared_ptr<geometry::TriangleMesh> ExtractTriangleMesh() override; | ||
| /// Temporary function will be deleted/"merged" with ExtractTriangleMesh | ||
| std::shared_ptr<geometry::TriangleMesh> ExtractTriangleMesh_v2(); |
There was a problem hiding this comment.
It would be better to inject the implementation as an option in ExtractTriangleMesh(bool use_vtk = False).
| .def("inject_volume_color", &UniformTSDFVolume::InjectVolumeColor, | ||
| "Debug function to inject the voxel Color data.", "color"_a) | ||
| // TODO remove after debugging | ||
| .def("extract_triangle_mesh_v2", &UniformTSDFVolume::ExtractTriangleMesh_v2) |
There was a problem hiding this comment.
Same, do not duplicate API.
| surface->SetValue(0, isoValue); | ||
|
|
||
| //// To remain largest region. | ||
| //// vtkNew<vtkPolyDataConnectivityFilter> confilter; |
There was a problem hiding this comment.
Either remove unused code or add a flag to run the code.
| std::shared_ptr<geometry::TriangleMesh> | ||
| UniformTSDFVolume::ExtractTriangleMesh_v2() { | ||
| auto mesh = std::make_shared<geometry::TriangleMesh>(); | ||
| //float *image_array = new float[resolution_ * resolution_ * resolution_]; |
| auto mesh = std::make_shared<geometry::TriangleMesh>(); | ||
| //float *image_array = new float[resolution_ * resolution_ * resolution_]; | ||
| //const long r_sq = resolution_ * resolution_; | ||
| int dims[] = {resolution_, resolution_, resolution_}; |
There was a problem hiding this comment.
Use std::array or modern containers, or explicitly declare array size.
| //float *image_array = new float[resolution_ * resolution_ * resolution_]; | ||
| //const long r_sq = resolution_ * resolution_; | ||
| int dims[] = {resolution_, resolution_, resolution_}; | ||
| float ***values = new float **[dims[0]]; |
There was a problem hiding this comment.
All pointers are allocated but not released. It's better to allocate a flattened std::vector and unroll the indices.
| } | ||
| } | ||
| } | ||
| vtkIdType totalSize = (vtkIdType)dims[0] * (vtkIdType) dims[1] * (vtkIdType) dims[2]; |
| for (int z = 0; z < resolution_ - 1; z++) { | ||
| Eigen::Vector3i idx0(x, y, z); | ||
| const float f = voxels_[IndexOf(idx0)].tsdf_; | ||
| values[x][y][z] = f; |
There was a problem hiding this comment.
Only TSDF is used here, weights are not handled, see the original implementation. This is known to provide problematic mesh especially around boundaries.
| vtkPolyData *sdata = surface->GetOutput(); | ||
| auto tmesh = open3d::t::geometry::vtkutils::CreateTriangleMeshFromVtkPolyData(sdata); | ||
| auto lmesh = tmesh.ToLegacy(); | ||
| std::shared_ptr<geometry::TriangleMesh> pmesh(new geometry::TriangleMesh(lmesh.vertices_, lmesh.triangles_)); |
There was a problem hiding this comment.
Memory is copied twice in the conversion. It is also unsafe to use new to initialize a shared_ptr. Please use std::make_shared and reduce redundant memory copy.
ssheorey
left a comment
There was a problem hiding this comment.
This implementation is not linked to the voxel grid / voxel block grid anymore. An example of how to use it with data in those formats would make it more accessible.
Type
Motivation and Context
Checklist:
python util/check_style.py --applyto apply Open3D code styleto my code.
updated accordingly.
results (e.g. screenshots or numbers) here.
Description