MCPcopy Create free account
hub / github.com/Kitware/VTK / UpdateGridInformation

Method UpdateGridInformation

IO/OpenVDB/vtkOpenVDBReader.cxx:593–710  ·  view source on GitHub ↗

------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

591
592//------------------------------------------------------------------------
593void vtkOpenVDBReaderInternals::UpdateGridInformation(
594 struct OpenVDBGridInformation* gridInfo, openvdb::GridBase::Ptr grid)
595{
596 if (grid == nullptr)
597 {
598 return;
599 }
600
601 // Needed only when reading from stream
602 // This is overriden when reading from file
603 gridInfo->Grid = grid;
604
605 gridInfo->Name = grid->getName();
606 // go through metadata
607 openvdb::Vec3i bBoxMin;
608 openvdb::Vec3i bBoxMax;
609 openvdb::Vec3d worldOrig;
610 try
611 {
612 // this is a standard convention, but we're not sure it is actually set
613 bBoxMin = grid->template metaValue<openvdb::Vec3i>("file_bbox_min");
614 bBoxMax = grid->template metaValue<openvdb::Vec3i>("file_bbox_max");
615
616 openvdb::Coord bboxMinCoord;
617 bboxMinCoord.reset(bBoxMin[0], bBoxMin[1], bBoxMin[2]);
618
619 // origin in world coordinates
620 worldOrig = grid->indexToWorld(bboxMinCoord);
621 }
622 catch (const openvdb::Exception& e)
623 {
624 // two different exceptions can happen: either the field is unknown,
625 // either it has incorrect type. in both cases, we have this fallback
626 // it will probably give [MAX_COORDS, MIN_COORDS] BBox, so we don't try
627 // to compute the origin
628 openvdb::CoordBBox defaultBBox = grid->evalActiveVoxelBoundingBox();
629 openvdb::Coord defaultMin = defaultBBox.min();
630 openvdb::Coord defaultMax = defaultBBox.max();
631 bBoxMin.init(defaultMin[0], defaultMin[1], defaultMin[2]);
632 bBoxMax.init(defaultMax[0], defaultMax[1], defaultMax[2]);
633 worldOrig.init(); // 0, 0, 0
634 }
635
636 // spacing
637 openvdb::Vec3d voxSpacing = grid->voxelSize();
638
639 for (int s = 0; s < 3; s++)
640 {
641 gridInfo->BBoxMin[s] = bBoxMin[s];
642 gridInfo->BBoxMax[s] = bBoxMax[s];
643 gridInfo->Spacing[s] = voxSpacing[s];
644 gridInfo->WorldOrigin[s] = worldOrig[s];
645 }
646
647 gridInfo->UniformScale = grid->hasUniformVoxels();
648
649 // Get grid type
650 if (grid->isType<openvdb::BoolGrid>())

Callers 1

Calls 3

getNameMethod · 0.45
resetMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected