OpenWalnut
1.5.0dev
|
Implements basic Bresenham algorithm for rasterization. More...
#include <WBresenham.h>
Public Member Functions | |
WBresenham (std::shared_ptr< WGridRegular3D > grid, bool antialiased=true) | |
Initializes new raster algo. More... | |
virtual | ~WBresenham () |
Finishes this raster algo. More... | |
virtual void | raster (const WLine &line) |
Rasterize the given line into the grid of dataset. More... | |
Public Member Functions inherited from WRasterAlgorithm | |
WRasterAlgorithm (std::shared_ptr< WGridRegular3D > grid) | |
Creates new raster algorithm within the given grid. More... | |
virtual | ~WRasterAlgorithm () |
Dispose a this raster algorithm. More... | |
std::shared_ptr< WDataSetScalar > | generateDataSet () 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 | rasterSegment (const WPosition &start, const WPosition &end) |
Scans a line segment for voxels which are hit. More... | |
virtual void | markVoxel (const WVector3i &voxel, const int axis, const WPosition &start, const WPosition &end) |
Marks the given voxel as a hit. More... | |
virtual double | filter (const double distance) const |
Returns the value to mark the hit voxels with, depending on their distance to the line. More... | |
std::vector< double > | computeDistances (const size_t voxelNum, const WPosition &start, const WPosition &end) const |
Computes the distances for a voxel to the real line segment and also for its supporting voxels. More... | |
double | composeValue (double newValue, double existingValue) const |
Compose the new value for a voxel out of a new computed value and the already existing marking. More... | |
Protected Member Functions inherited from WRasterAlgorithm | |
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 | |
bool | m_antialiased |
If true also some supporting voxels are marked. More... | |
Protected Attributes inherited from WRasterAlgorithm | |
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< WGridRegular3D > | m_grid |
The grid is used for the following purposes: More... | |
std::vector< double > | m_values |
Stores the value of each voxel. More... | |
Friends | |
class | WBresenhamTest |
Only UnitTests may be friends. More... | |
Implements basic Bresenham algorithm for rasterization.
Definition at line 42 of file WBresenham.h.
WBresenham::WBresenham | ( | std::shared_ptr< WGridRegular3D > | grid, |
bool | antialiased = true |
||
) |
Initializes new raster algo.
grid | The grid which defines the voxels which should be marked. |
antialiased | If true then all voxels of a line are supported with anti-aliasing voxels around |
Definition at line 40 of file WBresenham.cpp.
|
virtual |
Finishes this raster algo.
Definition at line 46 of file WBresenham.cpp.
|
protected |
Compose the new value for a voxel out of a new computed value and the already existing marking.
newValue | Newly computed value |
existingValue | The mark already existing for the voxel (aka previous mark or markSoFar) |
Definition at line 189 of file WBresenham.cpp.
Referenced by markVoxel().
|
protected |
Computes the distances for a voxel to the real line segment and also for its supporting voxels.
voxelNum | The voxel number |
start | Start point of the line segment |
end | End point of the line segment |
Definition at line 160 of file WBresenham.cpp.
References WRasterAlgorithm::m_grid.
Referenced by markVoxel().
|
protectedvirtual |
Returns the value to mark the hit voxels with, depending on their distance to the line.
distance | Distance of the voxel to the line. |
Definition at line 281 of file WBresenham.cpp.
Referenced by markVoxel().
|
protectedvirtual |
Marks the given voxel as a hit.
If anti-aliasing is enabled also some supporting voxels nearby are marked. The value for marking the voxel depends on the distance from its center point to the real line.
voxel | The voxel to mark |
axis | Along which axis the traversal takes place. Since when walking in e.g. X-direction there are not supporting voxels in the same direction. |
start | Start point of the line segment (used to computed the distance) |
end | End point of the line segment (used to computed the distance) |
Definition at line 195 of file WBresenham.cpp.
References composeValue(), computeDistances(), filter(), m_antialiased, WRasterAlgorithm::m_grid, WRasterAlgorithm::m_values, and WRasterAlgorithm::parameterizeVoxel().
Referenced by rasterSegment(), and WBresenhamDBL::rasterSegment().
|
virtual |
Rasterize the given line into the grid of dataset.
The value of the voxel which will be hit changes its value.
line | Polyline which is about to be rastered. |
Implements WRasterAlgorithm.
Definition at line 50 of file WBresenham.cpp.
References wlog::debug(), WRasterAlgorithm::m_parameterizationsLock, WRasterAlgorithm::newLine(), WRasterAlgorithm::newSegment(), rasterSegment(), and WMixinVector< ValueT >::size().
Scans a line segment for voxels which are hit.
start | Start point of the line segment |
end | End point of the line segment |
Reimplemented in WBresenhamDBL.
Definition at line 70 of file WBresenham.cpp.
References WRasterAlgorithm::m_grid, and markVoxel().
Referenced by raster().
|
friend |
Only UnitTests may be friends.
Definition at line 47 of file WBresenham.h.
|
protected |
If true also some supporting voxels are marked.
Definition at line 140 of file WBresenham.h.
Referenced by markVoxel().