QUAOAR STUDIO // Mobius API
mobius::poly_MarchingCubes Class Reference

#include <poly_MarchingCubes.h>

Inheritance diagram for mobius::poly_MarchingCubes:
Collaboration diagram for mobius::poly_MarchingCubes:

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_ProgressEntryGetProgress () const
 
core_PlotterEntryGetPlotter () 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_meshPolygonizeVoxel (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_RealFuncm_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_meshm_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_vertexComparatort_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)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ poly_MarchingCubes()

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.

Parameters
[in]funcimplicit function defining the field.
[in]numSlicesnum of slices to discretize the space to get a regular grid.
[in]progressprogress notifier.
[in]plotterimperative plotter.

Member Function Documentation

◆ GetCubeIndex()

static mobiusPoly_EXPORT int mobius::poly_MarchingCubes::GetCubeIndex ( double  voxelScalars[2][2][2])
static

Returns lookup index of a cube.

Parameters
[in]voxelScalarseight scalars in the corners of a voxel.
Returns
topological situation as a lookup index.

◆ GetVoxelCorner()

static mobiusPoly_EXPORT t_xyz mobius::poly_MarchingCubes::GetVoxelCorner ( const t_xyz origin,
const double  dx,
const double  dy,
const double  dz,
const int  nx,
const int  ny,
const int  nz 
)
static

Returns the Cartesian coordinates of the voxel corner for the passed integer indices.

Parameters
[in]originlower corner of a voxel.
[in]dxslicing step in the OX direction.
[in]dyslicing step in the OY direction.
[in]dzslicing step in the OZ direction.
[in]nx0-based index of the X coordinate of the corner.
[in]ny0-based index of the Y coordinate of the corner.
[in]nz0-based index of the Z coordinate of the corner.
Returns
coordinates of the corner.

◆ InterpVertex()

static mobiusPoly_EXPORT t_xyz mobius::poly_MarchingCubes::InterpVertex ( const t_xyz point1,
const t_xyz point2,
const double  scalar1,
const double  scalar2 
)
static

Interpolates the intersection point between the given extremities based on the passed scalar values.

Parameters
[in]point1first point.
[in]point2second point.
[in]scalar1first scalar.
[in]scalar2second scalar.
Returns
interpolated point.

◆ PolygonizeVoxel()

static mobiusPoly_EXPORT t_ptr<t_mesh> mobius::poly_MarchingCubes::PolygonizeVoxel ( const t_xyz P0,
const t_xyz P7,
const t_ptr< poly_RealFunc > &  func,
const double  isoValue 
)
static

Polygonizes a single voxel.

Parameters
[in]P0lower corner of a voxel.
[in]P7upper corner of a voxel.
[in]funcimplicit function to evaluate.
[in]isoValuefunction level to polygonize at.
Returns
piece of mesh.

The documentation for this class was generated from the following file: