OpenWalnut  1.5.0dev
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
WRasterAlgorithm Class Referenceabstract

Base class for all rasterization algorithms. More...

#include <WRasterAlgorithm.h>

+ Inheritance diagram for WRasterAlgorithm:
+ Collaboration diagram for WRasterAlgorithm:

Public Member Functions

 WRasterAlgorithm (std::shared_ptr< WGridRegular3D > grid)
 Creates new raster algorithm within the given grid. More...
 
virtual ~WRasterAlgorithm ()
 Dispose a this raster algorithm. More...
 
virtual void raster (const WLine &line)=0
 Rasterize the given line into the grid of dataset. More...
 
std::shared_ptr< WDataSetScalargenerateDataSet () const
 Computes a dataset out of our voxel values and the previously given grid. More...
 
void addParameterizationAlgorithm (std::shared_ptr< WRasterParameterization > algorithm)
 This method allows the user of the raster algorithm to add arbitrary parameterizations. More...
 
virtual void finished ()
 Called whenever all lines have been rasterized. More...
 

Protected Member Functions

virtual void parameterizeVoxel (const WVector3i &voxel, size_t voxelIdx, const int axis, const double value, const WPosition &start, const WPosition &end)
 This method allows all registered parameterization algorithms to update. More...
 
virtual void newLine (const WLine &line)
 Distribute a new line getting rasterized to all parameterize algorithms. More...
 
virtual void newSegment (const WPosition &start, const WPosition &end)
 Distribute a new segment of a line to all parameterization algorithms. More...
 

Protected Attributes

std::vector< std::shared_ptr< WRasterParameterization > > m_parameterizations
 All the parameterization algorithms to apply while rasterizing a line. More...
 
std::shared_mutex m_parameterizationsLock
 The mutex used to lock access to m_parameterizations. More...
 
std::shared_ptr< WGridRegular3Dm_grid
 The grid is used for the following purposes: More...
 
std::vector< double > m_values
 Stores the value of each voxel. More...
 

Detailed Description

Base class for all rasterization algorithms.

The interface will be as follows: You need a WGridRegular3D grid and some geometry. The grid specifies the volume where you raster the geometry. For other geometries than lines please overload the raster() member function.

Definition at line 46 of file WRasterAlgorithm.h.

Constructor & Destructor Documentation

◆ WRasterAlgorithm()

WRasterAlgorithm::WRasterAlgorithm ( std::shared_ptr< WGridRegular3D grid)
explicit

Creates new raster algorithm within the given grid.

The grid may later also be used to generate a real DataSet,

See also
generateDataSet() for further instructions.
Parameters
gridThe grid specifying the voxels.

Definition at line 36 of file WRasterAlgorithm.cpp.

References wlog::debug(), and m_values.

+ Here is the call graph for this function:

◆ ~WRasterAlgorithm()

WRasterAlgorithm::~WRasterAlgorithm ( )
virtual

Dispose a this raster algorithm.

Definition at line 45 of file WRasterAlgorithm.cpp.

Member Function Documentation

◆ addParameterizationAlgorithm()

void WRasterAlgorithm::addParameterizationAlgorithm ( std::shared_ptr< WRasterParameterization algorithm)

This method allows the user of the raster algorithm to add arbitrary parameterizations.

Each parameterization creates a new volume dataset parameterizing the voxelized line somehow.

Parameters
algorithmthe algorithm

Definition at line 59 of file WRasterAlgorithm.cpp.

References m_parameterizations, and m_parameterizationsLock.

◆ finished()

void WRasterAlgorithm::finished ( )
virtual

Called whenever all lines have been rasterized.

Definition at line 95 of file WRasterAlgorithm.cpp.

References m_parameterizations, and m_parameterizationsLock.

◆ generateDataSet()

std::shared_ptr< WDataSetScalar > WRasterAlgorithm::generateDataSet ( ) const

Computes a dataset out of our voxel values and the previously given grid.

Note this may take some time.

Returns
Dataset where all voxels which are hit by the rastered lines are non zero.

Definition at line 49 of file WRasterAlgorithm.cpp.

References m_values.

◆ newLine()

void WRasterAlgorithm::newLine ( const WLine line)
protectedvirtual

Distribute a new line getting rasterized to all parameterize algorithms.

Parameters
linethe new line.

Definition at line 66 of file WRasterAlgorithm.cpp.

References m_parameterizations.

Referenced by WBresenham::raster().

+ Here is the caller graph for this function:

◆ newSegment()

void WRasterAlgorithm::newSegment ( const WPosition start,
const WPosition end 
)
protectedvirtual

Distribute a new segment of a line to all parameterization algorithms.

Gets called for each new line segment getting rasterized, as one segment can have multiple voxels.

Parameters
startstart point of the new line segment
endend point of the new line segment

Definition at line 75 of file WRasterAlgorithm.cpp.

References m_parameterizations.

Referenced by WBresenham::raster().

+ Here is the caller graph for this function:

◆ parameterizeVoxel()

void WRasterAlgorithm::parameterizeVoxel ( const WVector3i voxel,
size_t  voxelIdx,
const int  axis,
const double  value,
const WPosition start,
const WPosition end 
)
protectedvirtual

This method allows all registered parameterization algorithms to update.

This basically simply calls all parameterizeVoxel methods in m_parameterizations vector.

Parameters
voxelthe voxel to parameterize
voxelIdxthe voxel index in the common grid calculated using "voxel" (this is for convenience)
axisAlong which axis the traversal takes place. Since when walking in e.g. X-direction there are not supporting voxels in the
valuethe new voxel value
startStart point of the line segment (used to computed the distance)
endEnd point of the line segment (used to computed the distance)

Definition at line 84 of file WRasterAlgorithm.cpp.

References m_parameterizations.

Referenced by WBresenham::markVoxel().

+ Here is the caller graph for this function:

◆ raster()

virtual void WRasterAlgorithm::raster ( const WLine line)
pure virtual

Rasterize the given line into the grid of dataset.

The value of the voxel which will be hit changes its value.

Parameters
linePolyline which is about to be rastered.

Implemented in WBresenham.

Member Data Documentation

◆ m_grid

std::shared_ptr< WGridRegular3D > WRasterAlgorithm::m_grid
protected

The grid is used for the following purposes:

  • First we need it when creating the final dataset
  • Second we need it to determine how many voxels are there at construction time
  • Third we need it when computing the value number out of a position

Definition at line 111 of file WRasterAlgorithm.h.

Referenced by WBresenham::computeDistances(), WBresenham::markVoxel(), WBresenham::rasterSegment(), and WBresenhamDBL::rasterSegment().

◆ m_parameterizations

std::vector< std::shared_ptr< WRasterParameterization > > WRasterAlgorithm::m_parameterizations
protected

All the parameterization algorithms to apply while rasterizing a line.

Definition at line 97 of file WRasterAlgorithm.h.

Referenced by addParameterizationAlgorithm(), finished(), newLine(), newSegment(), and parameterizeVoxel().

◆ m_parameterizationsLock

std::shared_mutex WRasterAlgorithm::m_parameterizationsLock
protected

The mutex used to lock access to m_parameterizations.

Definition at line 102 of file WRasterAlgorithm.h.

Referenced by addParameterizationAlgorithm(), finished(), and WBresenham::raster().

◆ m_values

std::vector< double > WRasterAlgorithm::m_values
protected

Stores the value of each voxel.

If and only if a voxel is not hit by a line segment its value is 0.0.

Definition at line 117 of file WRasterAlgorithm.h.

Referenced by generateDataSet(), WBresenham::markVoxel(), and WRasterAlgorithm().


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