30 #include "WCenterlineParameterization.h"
31 #include "core/common/math/linearAlgebra/WVectorFixed.h"
35 m_paramValues( grid->size(), 0.0 ),
36 m_paramFinalValues( grid->size(), 0.0 ),
37 m_paramSetValues( grid->size(), false ),
38 m_centerline( centerline ),
39 m_currentStartParameter( 0.0 ),
40 m_currentEndParameter( 0.0 )
54 std::shared_ptr< std::vector< double > >(
62 size_t index(
int x,
int y,
int z, std::shared_ptr< WGridRegular3D > grid )
68 x = x >=
static_cast< int >( grid->getNbCoordsX() ) ?
static_cast< int >( grid->getNbCoordsX() ) - 1 : x;
69 y = y >=
static_cast< int >( grid->getNbCoordsY() ) ?
static_cast< int >( grid->getNbCoordsY() ) - 1 : y;
70 z = z >=
static_cast< int >( grid->getNbCoordsZ() ) ?
static_cast< int >( grid->getNbCoordsZ() ) - 1 : z;
73 size_t nbX = grid->getNbCoordsX();
74 size_t nbXY = grid->getNbCoordsX() * grid->getNbCoordsY();
75 return x + y * nbX + z * nbXY;
87 Neighbourhood neighbourhood(
int x,
int y,
int z, std::shared_ptr< WGridRegular3D > grid )
90 n.
indices[0] = index( x, y, z, grid );
91 n.
indices[1] = index( x, y, z+1, grid );
92 n.
indices[2] = index( x, y, z-1, grid );
93 n.
indices[3] = index( x, y+1, z, grid );
94 n.
indices[4] = index( x, y+1, z+1, grid );
95 n.
indices[5] = index( x, y+1, z-1, grid );
96 n.
indices[6] = index( x, y-1, z, grid );
97 n.
indices[7] = index( x, y-1, z+1, grid );
98 n.
indices[8] = index( x, y-1, z-1, grid );
100 n.
indices[9] = index( x+1, y, z, grid );
101 n.
indices[10] = index( x+1, y, z+1, grid );
102 n.
indices[11] = index( x+1, y, z-1, grid );
103 n.
indices[12] = index( x+1, y+1, z, grid );
104 n.
indices[13] = index( x+1, y+1, z+1, grid );
105 n.
indices[14] = index( x+1, y+1, z-1, grid );
106 n.
indices[15] = index( x+1, y-1, z, grid );
107 n.
indices[16] = index( x+1, y-1, z+1, grid );
108 n.
indices[17] = index( x+1, y-1, z-1, grid );
110 n.
indices[18] = index( x-1, y, z, grid );
111 n.
indices[19] = index( x-1, y, z+1, grid );
112 n.
indices[20] = index( x-1, y, z-1, grid );
113 n.
indices[21] = index( x-1, y+1, z, grid );
114 n.
indices[22] = index( x-1, y+1, z+1, grid );
115 n.
indices[23] = index( x-1, y+1, z-1, grid );
116 n.
indices[24] = index( x-1, y-1, z, grid );
117 n.
indices[25] = index( x-1, y-1, z+1, grid );
118 n.
indices[26] = index( x-1, y-1, z-1, grid );
133 for(
unsigned int i = 0; i < 27; ++i )
157 double curLength = 0.0;
158 double bestDistStart = length(
m_centerline->at( 0 ) - start );
159 double bestDistEnd = length(
m_centerline->at( 0 ) - end );
171 double curDist = length(
m_centerline->at( i ) - start );
172 if( bestDistStart >= curDist )
174 bestDistStart = curDist;
178 if( bestDistEnd >= curDist )
180 bestDistEnd = curDist;
192 for(
size_t x = 0; x <
m_grid->getNbCoordsX(); ++x )
194 for(
size_t y = 0; y <
m_grid->getNbCoordsY(); ++y )
196 for(
size_t z = 0; z <
m_grid->getNbCoordsZ(); ++z )
198 size_t idx = wcp::index( x, y, z,
m_grid );
212 for(
unsigned int i = 1; i < 27; ++i )
std::vector< bool > m_paramSetValues
Stores whether the voxel has been set in the past or not.
virtual void newSegment(const WPosition &start, const WPosition &end)
Gets called for each new line segment getting rasterized, as one segment can have multiple voxels.
double m_currentStartParameter
The current start parameter for the current segment.
virtual ~WCenterlineParameterization()
Destructor.
std::vector< double > m_paramFinalValues
The values with applied selective dilatation.
virtual std::shared_ptr< WDataSetScalar > getDataSet()
Gets the dataset representing the parameterization.
double m_currentEndParameter
The current end parameter for the current segment.
WCenterlineParameterization(std::shared_ptr< WGridRegular3D > grid, std::shared_ptr< WFiber > centerline)
Default constructor.
std::shared_ptr< WFiber > m_centerline
The centerline of the cluster.
virtual void newLine(const WLine &line)
Gets called for each new line getting rasterized.
std::vector< double > m_paramValues
Stores the current length of the centerline fiber at each voxel.
virtual void parameterizeVoxel(const WVector3i &voxel, size_t voxelIdx, const int axis, const double value, const WPosition &start, const WPosition &end)
This method allows this parameterization to update.
virtual void finished()
Gets called whenever all lines have been rasterized.
This data set type contains scalars as values.
A line is an ordered sequence of WPositions.
A fixed size matrix class.
This only is a 3d double vector.
This class is the base for all specific parameterization algorithms.
std::shared_ptr< WGridRegular3D > m_grid
The grid, which needs to be used for the created dataset and to which the parameterizeVoxel method is...
virtual void newSegment(const WPosition &start, const WPosition &end)
Gets called for each new line segment getting rasterized, as one segment can have multiple voxels.
virtual void newLine(const WLine &line)
Gets called for each new line getting rasterized.
Base Class for all value set types.
size_t indices[27]
The indices of the neighbors.