51 :
AnalyticalF<3,T,T>(1), _volumeDeltaX{volumeDeltaX}
54 openvdb::io::File _vdbFile(fileName);
57 _grids = _vdbFile.getGrids();
59 _grid = openvdb::gridPtrCast<openvdb::FloatGrid>(*_grids->begin());
60 auto bbox = _grid->evalActiveVoxelBoundingBox();
63 openvdb::Vec3d minIdx(bbox.min().x(), bbox.min().y(), bbox.min().z());
64 openvdb::Vec3d extents(bbox.extents().x(), bbox.extents().y(), bbox.extents().z());
65 openvdb::Vec3d centerIdx = minIdx + extents * 0.5;
67 _rotation = openvdb::math::Transform::createLinearTransform(
68 openvdb::math::Mat4d::identity());
69 _rotation->preTranslate( centerIdx);
70 _rotation->preRotate(rotation, openvdb::math::Z_AXIS);
71 _rotation->preTranslate(-centerIdx);
72 _grid->setTransform(_rotation);
74 _rotation = openvdb::math::Transform::createLinearTransform(
75 openvdb::math::Mat4d::identity());
76 _grid->setTransform(_rotation);
79 bbox = _grid->evalActiveVoxelBoundingBox();
80 _shape[0] = bbox.max().x() - bbox.min().x();
81 _shape[1] = bbox.max().y() - bbox.min().y();
82 _shape[2] = bbox.max().z() - bbox.min().z();
83 _origin[0] = bbox.min().x();
84 _origin[1] = bbox.min().y();
85 _origin[2] = bbox.min().z();
89 throw std::runtime_error(
"VDB support not enabled, set FEATURE := VDB");
102 openvdb::Vec3d worldPos(
108 openvdb::Vec3d indexPos = _grid->transform().worldToIndex(worldPos);
109 openvdb::Coord location(
110 static_cast<int>(std::round(indexPos.x())),
111 static_cast<int>(std::round(indexPos.y())),
112 static_cast<int>(std::round(indexPos.z()))
115 openvdb::FloatGrid::Accessor accessor = _grid->getAccessor();
116 if(accessor.isValueOn(location)){
117 output[0] = _grid->tree().getValue(location);