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

make several vtk filters accessible in contour filter #421

Merged
merged 2 commits into from
Oct 27, 2019

Conversation

imsodin
Copy link
Contributor

@imsodin imsodin commented Oct 25, 2019

No description provided.

Copy link
Member

@banesullivan banesullivan left a comment

Choose a reason for hiding this comment

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

Looks great! This was on my list of todos a while back but I forgot to implement the other algorithms like marching cubes which is definitely needed

Just a few minor changes that I would like to see, please.

It might be nice to add an example under the filters category showcasing the differences of these three contouring algorithms (if they have noticeable differences for any of the example datasets that we have)

Thanks for making these contributions!

tests/test_filters.py Outdated Show resolved Hide resolved
@@ -663,7 +663,7 @@ def elevation(dataset, low_point=None, high_point=None, scalar_range=None,

def contour(dataset, isosurfaces=10, scalars=None, compute_normals=False,
compute_gradients=False, compute_scalars=True, rng=None,
preference='point'):
preference='point', method=None):
Copy link
Member

Choose a reason for hiding this comment

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

Instead of defaulting to None, let's just default to 'contour'

Copy link
Member

Choose a reason for hiding this comment

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

Or does another one of these algorithms perform better that we should default to?

Copy link
Member

Choose a reason for hiding this comment

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

the standard contour default is probably safest though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For my purposes I didn't see any significant difference between them.

I'll switch to contour then. I generally like None for default arguments, because it allows easy propagation of the default value when extending (i.e. creating anything that wraps this method and also wants to expose method) or scripting. E.g. if I want to use the default value unless some condition is met I can do method=None; if special_case: method=marching_cubes; obj.contour(method=method).

Copy link
Member

Choose a reason for hiding this comment

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

That's a fair point!

Throughout PyVista's API, we have tons of default arguments set to None but they typically lookup a choice/values from somewhere else or a preference from rcParams if None. I'd like to keep it that way for consistency, but you could still leave the if method is None or method == "contour": statement to catch that case.

@banesullivan banesullivan added the enhancement Changes that enhance the library label Oct 25, 2019
"""
if method == 'contour':
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if method == 'contour':
if method is None or method == 'contour':

@banesullivan banesullivan merged commit f52b028 into pyvista:master Oct 27, 2019
banesullivan added a commit that referenced this pull request Oct 27, 2019
@banesullivan banesullivan added this to the 0.23.0 milestone Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Changes that enhance the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants