0

I have an openvdb grid and I would like to reset the active state of all voxels that are not background.

Currently I am using an operator and the function openvdb::tools::foreach that iterates over all value nodes. In particular I might want to do it only for elements inside a given bounding box

openvdb::CoordBBox myBoundingBox;

struct Activator {
    static inline void op(const openvdb::FloatGrid::ValueAllIter& iter) {

        if ( [not background] )
          iter->setActiveState(myBoundingBox.isInside(iter->getCoord()));
    }
};

// Apply the function to all values.
openvdb::tools::foreach(grid->beginValueAll(), Activator ::op);

1) Is there a better way of setting all these voxels on/off?

2) Moreover it is possible to quickly set to on (or off) all voxels that lay withing the given axis aligned bounding box and are not background?

E.g.. something like

openvdb::tree::setActiveState(const CoordBBox &bbox, bool on)
Pierluigi
  • 2,212
  • 1
  • 25
  • 39

1 Answers1

0

openvdb::Grid exposes the following methods that may be useful in this situation

void clear()

Empty this grid, so that all voxels become inactive background voxels.

void fill   (   const CoordBBox &   bbox,
                const ValueType &   value,
                bool                active = true 
             ) 

Set all voxels within a given axis-aligned box to a constant value.

ldgorman
  • 1,553
  • 1
  • 14
  • 39
  • 1
    These method changes the value of the corresponding voxels. I would like to do the same but only changing the active state leaving the values untouched. – Pierluigi Sep 20 '14 at 16:25