Fix issues with RectilinearGrid instantiation #530
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes fix an issue where you couldn't update the coordinates of a
RectilinearGrid
after instantiating it.The issue arose from how the dimensions have to be updated anytime the coordinates are changed. These changes make it so that the dimensions are automatically managed by PyVista and the user is unable to set them unless using the VTK method (
.SetDimensions()
).RectilinearGrid
s are technically implicitly defined, so it makes sense to only let the user update thex
,y
, andz
coordinates for the mesh grid.These changes also give users more options if wanting to create a 1D or 2D
RectilinearGrid
upon instantiation by allowing 1 or 2 coordinate arrays to be passed instead of 3. The__init__
method defaults to x first, then y, then z. If a user wants to have a 2D grid oriented on theyz
plane, then they can set the coordinates after instantiating like so (this was previously not possible):This also adds a convenient
cast_to_structured_grid()
method asRectilinearGrid
s can easily be represented by aStructuredGrid
.Testing is implemented.