@@ -224,7 +224,7 @@ File::open()
224224 gd.readHeader (inputStream ());
225225 gd.readStreamPos (inputStream ());
226226
227- GridBase::Ptr grid = Archive::readGrid (gd, inputStream (), BBoxd () );
227+ GridBase::Ptr grid = Archive::readGrid (gd, inputStream (), io::ReadOptions{} );
228228
229229 mGridDescriptors .insert (std::make_pair (gd.gridName (), gd));
230230 mGrids ->push_back (grid);
@@ -298,7 +298,7 @@ File::getMetadata() const
298298
299299
300300GridPtrVecPtr
301- File::getGrids () const
301+ File::getGrids (const io::ReadOptions& readOptions ) const
302302{
303303 if (!mIsOpen ) {
304304 OPENVDB_THROW (IoError, mFilename << " is not open for reading" );
@@ -319,7 +319,7 @@ File::getGrids() const
319319 const GridDescriptor& gd = i->second ;
320320 // Seek to the grid in the file.
321321 gd.seekToGrid (inputStream ());
322- GridBase::Ptr grid = Archive::readGrid (gd, inputStream (), BBoxd () );
322+ GridBase::Ptr grid = Archive::readGrid (gd, inputStream (), readOptions );
323323 ret->push_back (grid);
324324 namedGrids[gd.uniqueName ()] = grid;
325325 }
@@ -385,7 +385,9 @@ File::readAllGridMetadata()
385385 const GridDescriptor& gd = i->second ;
386386 // Seek to the grid in the file.
387387 gd.seekToGrid (inputStream ());
388- GridBase::ConstPtr grid = Archive::readGrid (gd, inputStream (), BBoxd (), /* partial=*/ true );
388+ io::ReadOptions readOptions;
389+ readOptions.readMode = io::ReadMode::TopologyOnly;
390+ GridBase::ConstPtr grid = Archive::readGrid (gd, inputStream (), readOptions);
389391 // Return copies of the grids, but with empty trees.
390392 // (As of 0.98.0, at least, it would suffice to just const cast
391393 // the grid pointers returned by readGrid(partial=true), but shallow
@@ -423,7 +425,9 @@ File::readGridMetadata(const Name& name)
423425 // Seek to and read in the grid from the file.
424426 const GridDescriptor& gd = it->second ;
425427 gd.seekToGrid (inputStream ());
426- ret = Archive::readGrid (gd, inputStream (), BBoxd (), /* partial=*/ true );
428+ io::ReadOptions readOptions;
429+ readOptions.readMode = io::ReadMode::TopologyOnly;
430+ ret = Archive::readGrid (gd, inputStream (), readOptions);
427431 }
428432 return ret->copyGridWithNewTree ();
429433}
@@ -433,26 +437,28 @@ File::readGridMetadata(const Name& name)
433437
434438
435439GridBase::Ptr
436- File::readGrid (const Name& name)
440+ File::readGrid (const Name& name, const BBoxd& bbox )
437441{
438- return readGrid (name, BBoxd ());
442+ io::ReadOptions readOptions;
443+ readOptions.clipBBox = bbox;
444+ return readGrid (name, readOptions);
439445}
440446
441447
442448GridBase::Ptr
443- File::readGrid (const Name& name, const BBoxd& bbox )
449+ File::readGrid (const Name& name, const io::ReadOptions& readOptions )
444450{
445451 if (!mIsOpen ) {
446452 OPENVDB_THROW (IoError, mFilename << " is not open for reading." );
447453 }
448454
449- const bool clip = bbox.isSorted ();
450-
451455 // If a grid with the given name was already read and cached
452456 // (along with the entire contents of the file, because the file
453457 // doesn't support random access), retrieve and return it.
454458 GridBase::Ptr grid = retrieveCachedGrid (name);
455459 if (grid) {
460+ const auto & bbox = readOptions.clipBBox ;
461+ const bool clip = bbox.isSorted ();
456462 if (clip) {
457463 grid = grid->deepCopyGrid ();
458464 grid->clipGrid (bbox);
@@ -471,7 +477,7 @@ File::readGrid(const Name& name, const BBoxd& bbox)
471477 OPENVDB_ASSERT (inputHasGridOffsets ());
472478 // Seek to the grid in the file.
473479 gd.seekToGrid (inputStream ());
474- grid = Archive::readGrid (gd, inputStream (), bbox );
480+ grid = Archive::readGrid (gd, inputStream (), readOptions );
475481
476482 if (gd.isInstance ()) {
477483 // / @todo Refactor to share code with Archive::connectInstance()?
@@ -487,7 +493,7 @@ File::readGrid(const Name& name, const BBoxd& bbox)
487493 GridBase::Ptr parent;
488494 OPENVDB_ASSERT (inputHasGridOffsets ());
489495 parentIt->second .seekToGrid (inputStream ());
490- parent = Archive::readGrid (parentIt->second , inputStream (), bbox );
496+ parent = Archive::readGrid (parentIt->second , inputStream (), readOptions );
491497 if (parent) grid->setTree (parent->baseTreePtr ());
492498 }
493499 return grid;
0 commit comments