Skip to content

Refactor I/O#2179

Open
danrbailey wants to merge 13 commits intoAcademySoftwareFoundation:feature/iofrom
danrbailey:io_refactor
Open

Refactor I/O#2179
danrbailey wants to merge 13 commits intoAcademySoftwareFoundation:feature/iofrom
danrbailey:io_refactor

Conversation

@danrbailey
Copy link
Copy Markdown
Contributor

@danrbailey danrbailey commented Mar 20, 2026

This PR is a no-op change - no behavior changes and no breakages to the public I/O API. All unit tests pass and this portion of the codebase is reduced by ~250 lines.

The primary goals for this PR are:

  • To consolidate all the grid reading behind Archive::readGrid() and all the grid writing behind Archive::writeGrid()
  • To move all grid creation into Archive::readGrid()
  • To eliminate as much of the complexity in the I/O codebase now that delayed-loading is no longer supported, including:
    • Removing the pImpl pattern in File and Stream classes
    • Removing and consolidating lots of private and protected member functions

The changes are broken out into commits so as to make this easier to review:

  1. GridDescriptor reading

This is the only public API change - GridDescriptor::read() creates a Grid from a GridDescriptor, however the Grid return type was never used in the OpenVDB codebase, so this function has been deprecated and all the places where this was previously used now calls GridDescriptor.readHeader() followed by GridDescriptor::readStreamPos() instead which does not create the Grid and mirrors the write implementation. Finally, File::readGridDescriptors() was only ever used in one place in the codebase, so this logic has been hoisted into the calling code instead.

db9b6cf
787ff90

  1. Small refactor to remove private File::readGridByName() method

b3471b0

  1. Remove unused topology reading option to private File::readPartialGrid() method

This also removes one of the File::readPartialGrid() variants and hoists the logic into the calling code instead.

e990a15

  1. Remove pImpl pattern

There was no longer a good reason to use this pattern. It didn't serve a practical purpose at reducing compile times or improving binary compatibility. We support reinterpret casting a Grid pointer across ABI boundaries, but not a File or Stream object. This greatly simplifies the code.

7fe0036
5672d77

  1. Always pass BBox through read methods

Some of the complexity in the I/O is due to handling different bounding box clipping options (no bounding box, index-space bounding box, world-space bounding box). Previously this code was checking bbox.isSorted() to know whether to clip or not and doing an world-space -> index-space conversion early, this mainly delays that until Archive::read() so as to reduce the number of variants. The public API remains the same after this change - it still has bbox clipping and non-bbox clipping methods, but the non-bbox clipping method now simply creates a default BBox and passes that down. In theory this introduces a tiny slowdown in checking this bbox is valid or not on every grid read (as opposed to once at the start), but the reduction in complexity vastly outweighs any performance concerns here IMO.

864670c

  1. Move grid creation into Archive::readGrid()

This change adds a new partial = false argument to the private Archive::readGrid() method so that File::readGridPartial() can be removed entirely. Previously there was a loose agreement to keep the order of operations in both methods the same. The big change here is to move grid creation down into Archive::readGrid() instead of doing this in the calling functions. In practical terms, the only real difference is that the exception thrown does not distinguish if it is a filename or stream if the grid type has not been registered.

eb8dead

…f I/O methods

Signed-off-by: Dan Bailey <danbailey@ilm.com>
Signed-off-by: Dan Bailey <danbailey@ilm.com>
Signed-off-by: Dan Bailey <danbailey@ilm.com>
Signed-off-by: Dan Bailey <danbailey@ilm.com>
Signed-off-by: Dan Bailey <danbailey@ilm.com>
Signed-off-by: Dan Bailey <danbailey@ilm.com>
Signed-off-by: Dan Bailey <danbailey@ilm.com>
Signed-off-by: Dan Bailey <danbailey@ilm.com>
Signed-off-by: Dan Bailey <danbailey@ilm.com>
Signed-off-by: Dan Bailey <danbailey@ilm.com>
Signed-off-by: Dan Bailey <danbailey@ilm.com>
Signed-off-by: Dan Bailey <danbailey@ilm.com>
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.

1 participant