#include <poly_MarchingCubes.h>
Public Member Functions | |
mobiusPoly_EXPORT | poly_MarchingCubes (const t_ptr< poly_RealFunc > &func, const int numSlices=128, core_ProgressEntry progress=nullptr, core_PlotterEntry plotter=nullptr) |
virtual | ~poly_MarchingCubes ()=default |
Dtor. | |
Public Member Functions inherited from mobius::poly_GridTessellator | |
mobiusPoly_EXPORT | poly_GridTessellator (const t_xyz &Pmin, const t_xyz &Pmax, const int numSlices=128, core_ProgressEntry progress=nullptr, core_PlotterEntry plotter=nullptr) |
virtual mobiusPoly_EXPORT | ~poly_GridTessellator () |
Dtor. | |
Public Member Functions inherited from mobius::poly_Tessellator | |
mobiusPoly_EXPORT | poly_Tessellator (core_ProgressEntry progress=nullptr, core_PlotterEntry plotter=nullptr) |
virtual mobiusPoly_EXPORT | ~poly_Tessellator () |
Dtor. | |
mobiusPoly_EXPORT bool | Perform (const double isoValue) |
const t_ptr< t_mesh > & | GetResult () const |
Public Member Functions inherited from mobius::core_IAlgorithm | |
core_ProgressEntry & | GetProgress () const |
core_PlotterEntry & | GetPlotter () const |
void | SetStatusCode (const int status) |
int | GetStatusCode () const |
void | AddStatusCode (const int statBit) |
bool | HasStatusCode (const int statBit) const |
Public Member Functions inherited from mobius::core_OBJECT | |
mobiusCore_EXPORT void | IncRef () |
mobiusCore_EXPORT void | DecRef () |
mobiusCore_EXPORT int | NbRefs () const |
virtual mobiusCore_EXPORT void | Dump (std::ostream *out) const |
const mobiusCore_EXPORT std::string & | GetName () const |
mobiusCore_EXPORT void | SetName (const std::string &name) |
mobiusCore_EXPORT bool | HasName () const |
Static Public Member Functions | |
static mobiusPoly_EXPORT t_ptr< t_mesh > | PolygonizeVoxel (const t_xyz &P0, const t_xyz &P7, const t_ptr< poly_RealFunc > &func, const double isoValue) |
static mobiusPoly_EXPORT int | GetCubeIndex (double voxelScalars[2][2][2]) |
static mobiusPoly_EXPORT t_xyz | GetVoxelCorner (const t_xyz &origin, const double dx, const double dy, const double dz, const int nx, const int ny, const int nz) |
static mobiusPoly_EXPORT t_xyz | InterpVertex (const t_xyz &point1, const t_xyz &point2, const double scalar1, const double scalar2) |
Protected Attributes | |
t_ptr< poly_RealFunc > | m_func |
Implicit function defining the field. | |
Protected Attributes inherited from mobius::poly_GridTessellator | |
t_xyz | m_Pmin |
Min corner of the function domain. | |
t_xyz | m_Pmax |
Max corner of the function domain. | |
int | m_iNumSlices |
Num of slices for space discretization. | |
int | m_iNumSlicesX |
Num of slices along OX axis. | |
int | m_iNumSlicesY |
Num of slices along OY axis. | |
int | m_iNumSlicesZ |
Num of slices along OZ axis. | |
double | m_fGrainX |
Grain size along OX axis. | |
double | m_fGrainY |
Grain size along OY axis. | |
double | m_fGrainZ |
Grain size along OZ axis. | |
Protected Attributes inherited from mobius::poly_Tessellator | |
t_ptr< t_mesh > | m_result |
Reconstructed mesh. | |
Protected Attributes inherited from mobius::core_IAlgorithm | |
core_ProgressEntry | m_progress |
Progress Notifier. | |
core_PlotterEntry | m_plotter |
Imperative Plotter. | |
int | m_iStatusCode |
Additional Inherited Members | |
Protected Types inherited from mobius::poly_Tessellator | |
typedef std::map< t_xyz, int, t_vertexComparator > | t_vertexMap |
Map to store the set of indices for 3D mesh point. | |
Protected Member Functions inherited from mobius::core_OPERATOR | |
mobiusCore_EXPORT | core_OPERATOR (core_ProgressEntry progress, core_PlotterEntry plotter) |
Protected Member Functions inherited from mobius::core_IAlgorithm | |
mobiusCore_EXPORT | core_IAlgorithm (core_ProgressEntry progress, core_PlotterEntry plotter) |
This class provides implementation of the classical marching cubes algorithm introduced in the seminal paper by W. Lorensen
[Lorensen, W.E. and Cline, H.E. 1987. Marching cubes: A high resolution 3D surface construction algorithm. ACM SIGGRAPH Computer Graphics 21, 4, 163-169]
for the contouring of medical data. There is a plenty of open source implementations of this algorithm, e.g., the one from VTK or the algorithm by Paul Bourke
[Bourke, P. 1994. Polygonising a scalar field. URL: http://paulbourke.net/geometry/polygonise/].
Our implementation is no different from the "standard" ones. It is introduced here just to support the native data structures of the library, hence avoiding conversion between different mesh representations.
The marching cubes algorithm combines simplicity with high speed since it works almost entirely on lookup tables. We use MC as a reconstruction operator for our adaptive scalar fields (hosted by SVO nodes). MC is used for creating a 3D contour of a mathematical scalar field. In this case, the function is known everywhere but is sampled at the vertices of a regular 3D grid.
mobiusPoly_EXPORT mobius::poly_MarchingCubes::poly_MarchingCubes | ( | const t_ptr< poly_RealFunc > & | func, |
const int | numSlices = 128 , |
||
core_ProgressEntry | progress = nullptr , |
||
core_PlotterEntry | plotter = nullptr |
||
) |
Ctor with initialization.
[in] | func | implicit function defining the field. |
[in] | numSlices | num of slices to discretize the space to get a regular grid. |
[in] | progress | progress notifier. |
[in] | plotter | imperative plotter. |
|
static |
Returns lookup index of a cube.
[in] | voxelScalars | eight scalars in the corners of a voxel. |
|
static |
Returns the Cartesian coordinates of the voxel corner for the passed integer indices.
[in] | origin | lower corner of a voxel. |
[in] | dx | slicing step in the OX direction. |
[in] | dy | slicing step in the OY direction. |
[in] | dz | slicing step in the OZ direction. |
[in] | nx | 0-based index of the X coordinate of the corner. |
[in] | ny | 0-based index of the Y coordinate of the corner. |
[in] | nz | 0-based index of the Z coordinate of the corner. |
|
static |
Interpolates the intersection point between the given extremities based on the passed scalar values.
[in] | point1 | first point. |
[in] | point2 | second point. |
[in] | scalar1 | first scalar. |
[in] | scalar2 | second scalar. |
|
static |
Polygonizes a single voxel.
[in] | P0 | lower corner of a voxel. |
[in] | P7 | upper corner of a voxel. |
[in] | func | implicit function to evaluate. |
[in] | isoValue | function level to polygonize at. |