Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable attributes in vtk wrapper functions #5347

Merged
merged 4 commits into from
Jul 27, 2022

Conversation

benjaminum
Copy link
Contributor

@benjaminum benjaminum commented Jul 21, 2022

This PR

  • enables attributes in vtk wrapper functions allowing to preserve (interpolate) vertex and triangle attributes
  • fixes a segfault when converting empty vtkPolyData to a TriangleMesh

This change is Reviewable

-fix segfault for converting empty vtkPolyData to geometry
@update-docs
Copy link

update-docs bot commented Jul 21, 2022

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

-fix conversion for empty triangle indices
@benjaminum benjaminum marked this pull request as ready for review July 22, 2022 11:50
@benjaminum benjaminum requested review from ssheorey and yxlao July 22, 2022 11:50
Copy link
Member

@ssheorey ssheorey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 5 files reviewed, 2 unresolved discussions (waiting on @benjaminum and @yxlao)


cpp/open3d/t/geometry/VtkUtils.cpp line 306 at r2 (raw file):

/// \param copy If true always create a copy for attribute arrays.
/// \param include A set of keys to select which attributes should be added.
///                The special key "*" includes all attributes.

"*" may hint that globbing / regexp is supported. Perhaps use a special constant (e.g.: TensorMap::ALL_KEYS) instead?
Also. document precedence of include and exclude. From code below, looks like exclude has precedence over include. i.e. if include = {"colors"} and exclude = {"colors'} then "colors" is excluded. Or should this be an error?


cpp/open3d/t/geometry/VtkUtils.cpp line 340 at r2 (raw file):

                    "Ignoring attribute '{}' for TensorMap with primary key "
                    "'{}'",
                    key_tensor.first, tmap.GetPrimaryKey());

We shouldn't need a LogWarning for doing what the user asked us to do, i.e. if they explicitly asked to exclude "colors", no need to warn them about this.

@@ -140,6 +140,9 @@ class TriangleMesh : public Geometry, public DrawableGeometry {
/// Getter for vertex_attr_ TensorMap. Used in Pybind.
const TensorMap &GetVertexAttr() const { return vertex_attr_; }

/// Getter for vertex_attr_ TensorMap.
TensorMap &GetVertexAttr() { return vertex_attr_; }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yxlao I added another getter without const to simplify some conversion code. Is there a reason for just having the const version? Same for TriangleAttr and in PointCloud.h

Copy link
Contributor Author

@benjaminum benjaminum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 7 files reviewed, 3 unresolved discussions (waiting on @ssheorey and @yxlao)


cpp/open3d/t/geometry/VtkUtils.cpp line 306 at r2 (raw file):

Previously, ssheorey (Sameer Sheorey) wrote…

"*" may hint that globbing / regexp is supported. Perhaps use a special constant (e.g.: TensorMap::ALL_KEYS) instead?
Also. document precedence of include and exclude. From code below, looks like exclude has precedence over include. i.e. if include = {"colors"} and exclude = {"colors'} then "colors" is excluded. Or should this be an error?

Done. I changed to signature to avoid the special "*" element and improved the docstring.


cpp/open3d/t/geometry/VtkUtils.cpp line 340 at r2 (raw file):

Previously, ssheorey (Sameer Sheorey) wrote…

We shouldn't need a LogWarning for doing what the user asked us to do, i.e. if they explicitly asked to exclude "colors", no need to warn them about this.

The function is not really meant to be directly used by the user and we decide which attributes to keep/exclude based on the algorithm we want to use.
However, if a user wants to combine o3d and vtk in C++ they can use the function; we don't hide the functionality.

@benjaminum benjaminum merged commit 2b285cf into master Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants