HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParticlesToLevelSet.h File Reference

Rasterize particles with position, radius and velocity into either a boolean mask grid or a narrow-band level set grid. More...

#include <openvdb/Types.h>
#include <openvdb/Grid.h>
#include <openvdb/math/Math.h>
#include <openvdb/math/Transform.h>
#include <openvdb/tree/LeafManager.h>
#include <openvdb/util/logging.h>
#include <openvdb/util/NullInterrupter.h>
#include <openvdb/thread/Threading.h>
#include "Composite.h"
#include "PointPartitioner.h"
#include "Prune.h"
#include "SignedFloodFill.h"
#include <tbb/parallel_reduce.h>
#include <tbb/blocked_range.h>
#include <functional>
#include <iostream>
#include <type_traits>
#include <vector>
+ Include dependency graph for ParticlesToLevelSet.h:

Go to the source code of this file.

Classes

class  openvdb::OPENVDB_VERSION_NAME::tools::ParticlesToLevelSet< SdfGridT, AttributeT, InterrupterT >
 

Namespaces

 openvdb
 
 openvdb::OPENVDB_VERSION_NAME
 
 openvdb::OPENVDB_VERSION_NAME::tools
 

Functions

template<typename GridT , typename ParticleListT , typename InterrupterT = util::NullInterrupter>
void openvdb::OPENVDB_VERSION_NAME::tools::particlesToSdf (const ParticleListT &, GridT &, InterrupterT *=nullptr)
 Populate a scalar, floating-point grid with CSG-unioned level set spheres described by the given particle positions and radii. More...
 
template<typename GridT , typename ParticleListT , typename InterrupterT = util::NullInterrupter>
void openvdb::OPENVDB_VERSION_NAME::tools::particlesToSdf (const ParticleListT &, GridT &, Real radius, InterrupterT *=nullptr)
 Populate a scalar, floating-point grid with fixed-size, CSG-unioned level set spheres described by the given particle positions and the specified radius. More...
 
template<typename GridT , typename ParticleListT , typename InterrupterT = util::NullInterrupter>
void openvdb::OPENVDB_VERSION_NAME::tools::particleTrailsToSdf (const ParticleListT &, GridT &, Real delta=1, InterrupterT *=nullptr)
 Populate a scalar, floating-point grid with CSG-unioned trails of level set spheres with decreasing radius, where the starting position and radius and the direction of each trail is given by particle attributes. More...
 
template<typename GridT , typename ParticleListT , typename InterrupterT = util::NullInterrupter>
void openvdb::OPENVDB_VERSION_NAME::tools::particlesToMask (const ParticleListT &, GridT &, InterrupterT *=nullptr)
 Activate a boolean grid wherever it intersects the spheres described by the given particle positions and radii. More...
 
template<typename GridT , typename ParticleListT , typename InterrupterT = util::NullInterrupter>
void openvdb::OPENVDB_VERSION_NAME::tools::particlesToMask (const ParticleListT &, GridT &, Real radius, InterrupterT *=nullptr)
 Activate a boolean grid wherever it intersects the fixed-size spheres described by the given particle positions and the specified radius. More...
 
template<typename GridT , typename ParticleListT , typename InterrupterT = util::NullInterrupter>
void openvdb::OPENVDB_VERSION_NAME::tools::particleTrailsToMask (const ParticleListT &, GridT &, Real delta=1, InterrupterT *=nullptr)
 Activate a boolean grid wherever it intersects trails of spheres with decreasing radius, where the starting position and radius and the direction of each trail is given by particle attributes. More...
 

Detailed Description

Rasterize particles with position, radius and velocity into either a boolean mask grid or a narrow-band level set grid.

Author
Ken Museth

Optionally, arbitrary attributes on the particles can be transferred, resulting in additional output grids with the same topology as the main grid.

Note
Particle to level set conversion is intended to be combined with some kind of surface postprocessing, using ::tools::LevelSetFilter LevelSetFilter, for example. Without such postprocessing the generated surface is typically too noisy and blobby. However, it serves as a great and fast starting point for subsequent level set surface processing and convolution.

For particle access, any class with the following interface may be used (see the unit test or the From Particles Houdini SOP for practical examples):

struct ParticleList
{
// Return the total number of particles in the list.
// Always required!
size_t size() const;
// Get the world-space position of the nth particle.
// Required by rasterizeSpheres().
void getPos(size_t n, Vec3R& xyz) const;
// Get the world-space position and radius of the nth particle.
// Required by rasterizeSpheres().
void getPosRad(size_t n, Vec3R& xyz, Real& radius) const;
// Get the world-space position, radius and velocity of the nth particle.
// Required by rasterizeTrails().
void getPosRadVel(size_t n, Vec3R& xyz, Real& radius, Vec3R& velocity) const;
// Get the value of the nth particle's user-defined attribute (of type @c AttributeType).
// Required only if attribute transfer is enabled in ParticlesToLevelSet.
void getAtt(size_t n, AttributeType& att) const;
};

Some functions accept an interrupter argument. This refers to any class with the following interface:

struct Interrupter
{
void start(const char* name = nullptr) // called when computations begin
void end() // called when computations end
bool wasInterrupted(int percent=-1) // return true to abort computation
};

The default interrupter is ::util::NullInterrupter NullInterrupter, for which all calls are no-ops that incur no computational overhead.

Definition in file ParticlesToLevelSet.h.