template <class GridType>
void make_cube(GridType& grid, int size, const openvdb::Vec3f& c)
{
using ValueT = typename GridType::ValueType;
typename GridType::Accessor accessor = grid.getAccessor();
for (int i = c[0] - size; i <= c[0] + size; i++) {
for (int j = c[1] - size; j <= c[1] + size; j++) {
for (int k = c[2] - size; k <= c[2] + size; k++) {
openvdb::math::Coord voxel_coord = openvdb::math::Coord(i, j, k);
accessor.setValue(voxel_coord, ValueT(-2));
std::cout << i << j << k << std::endl;
}
}
}
}
openvdb::initialize();
// create three initial grids.
FloatGrid::Ptr gridA = FloatGrid::create(1);
FloatGrid::Ptr gridB = FloatGrid::create(1);
FloatGrid::Ptr current_view = tools::csgDifferenceCopy(*gridA, *gridC);
The previous code works fine for floatgrid but fails for vec2d and vec3d grids.
Basically I want to apply csg operations on the first element only for the vec2d grid if possible. What would be the smartest way to do that?