AcademySoftwareFoundation / AcademySoftwareFoundation/openvdb
dilate voxels from a PointDataGrid
- Dominant language
- C++
- Stars
- 3.4k
- Forks
- 774
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 34
Description
### Environment
**Operating System:** windows 10
**Compiler:** msvc 2019
### Describe the problem
i am trying to dilate voxels of a PointDataGrid in order to save each voxels to file with an offset, the dilateActiveValues doesnt affect the voxel of a PointDataGrid.
ex: PointDataGrid with voxel 2.0, and a extra offset of 0.3. so thats all the saved voxels overlap by 0.3, is there a way to achieve that ?
```
openvdb::points::PointAttributeVector positionsWrapper(positions/* my point cloud points */);
transform = openvdb::math::Transform::createLinearTransform(2.0); // voxel size => 2.0
// grid
grid = openvdb::tools::createPointIndexGrid(positionsWrapper, *transform);
grid->setName("PointsIndex");
// data
gridData = openvdb::points::createPointDataGrid(*grid, positionsWrapper, *transform);
gridData->setName("PointsData");
// dilate all voxels for
int iterations = 3;
openvdb::tools::dilateActiveValues(gridData->tree(), iterations );
// now save all voxels to file... but dilate has no effect on the saved points
auto cut_particles_op = [&](openvdb::points::PointDataTree::LeafNodeType& leaf, openvdb::Index leafpos) {
const openvdb::points::AttributeArray& positionArray = leaf.attributeArray("P");
openvdb::points::AttributeHandle positionHandle(positionArray);
for (openvdb::Index offset = 0; offset < leaf.SIZE; offset++) {
const openvdb::Index original_attribute_end = leaf.getValue(offset);
const auto ijk = leaf.offsetToGlobalCoord(offset);
const openvdb::Vec3d vec = ijk.asVec3d();
for (auto iter = leaf.beginIndexVoxel(ijk); iter; ++iter) {
const openvdb::Index index = *iter;// position
const openvdb::Vec3d pos = openvdb::Vec3d(positionHandle.get(index)) + vec;
Vec3d positionWorldSpace = transform->indexToWorld(pos);
here my points arent affected by any voxel bounding box dilated.... voxel size isnt 2.3 but remain 2.0 in size.
}
}
}
openvdb::tree::LeafManager points_iter(gridData->tree());
bool threaded = false; // for debug, set to false
points_iter.foreach(cut_particles_op, threaded );
```
i tried clip, clipGrid, ( to slow ), is there a fast way to slice/cut voxel volumes in a grid with an overlap/padding between voxels ? ( ex 0.3 )
Contributor guide
Research direction
Start by reviewing the PointDataGrid construction and the dilateActiveValues call in the issue, then trace how the LeafManager callback reads active voxels and point positions. Check whether dilation changes topology only or also point attributes, and compare it with the mentioned clip and clipGrid approaches. Done means identifying a supported way to produce the requested 0.3 overlap or documenting that the current APIs cannot do so.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100