CSG operations

107 views
Skip to first unread message

Mohamed El-Hamzawy

unread,
Apr 1, 2021, 7:49:36 AM4/1/21
to OpenVDB Forum
 Does CSG operations work on openvdb::Grid<openvdb::Vec2DTree>?

I want to do some csgDifference and csgIntersection on a grid of Vec2D type as mentioned above, but I get an error saying :
terminate called after throwing an instance of 'openvdb::v7_1::TypeError'
  what():  TypeError: signedFloodFill is supported only for signed value grids
Aborted (core dumped).


Is there a way to make that work? or do I have to make my own functions?

code snippet :

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?




Reply all
Reply to author
Forward
0 new messages