25 #ifndef WTHREADEDTRACKINGFUNCTION_H
26 #define WTHREADEDTRACKINGFUNCTION_H
34 #include <boost/array.hpp>
37 #include "../common/math/linearAlgebra/WVectorFixed.h"
38 #include "../common/WSharedObject.h"
39 #include "../common/WThreadedJobs.h"
41 #include "WDataSetSingle.h"
52 #if INTPTR_MAX == INT32_MAX
53 #define TRACKING_EPS 0.00001
55 #define TRACKING_EPS 0.0000001
67 typedef std::pair< WVector3d, WVector3d >
JobType;
73 typedef boost::shared_ptr< DataSetType const >
DataSetPtr;
76 typedef boost::function< WVector3d ( DataSetPtr, JobType const& ) >
DirFunc;
80 typedef boost::shared_ptr< WGridRegular3D >
Grid3DPtr;
91 static bool followToNextVoxel( DataSetPtr dataset, JobType& job, DirFunc
const& dirFunc );
152 friend class ::WThreadedTrackingFunctionTest;
167 typedef boost::shared_ptr< GridType >
GridPtr;
203 std::size_t seedPositions = 1, std::size_t seedsPerPos = 1,
204 std::vector< int > v0 = std::vector< int >(),
205 std::vector< int > v1 = std::vector< int >() );
219 virtual bool getJob( JobType& job );
227 virtual void compute( DataSetPtr input, JobType
const& job );
237 friend class ::WThreadedTrackingFunctionTest;
253 IndexType( GridPtr grid, std::vector< int >
const& v0,
254 std::vector< int >
const& v1, std::size_t seedPositions,
255 std::size_t seedsPerPosition );
286 boost::array< std::size_t, 4 >
m_pos;
289 boost::array< std::size_t, 4 >
m_min;
292 boost::array< std::size_t, 4 >
m_max;
322 #endif // WTHREADEDTRACKINGFUNCTION_H
A threaded functor base class for producer-consumer-style multithreaded computation.
WThreadedTrackingFunction This
this type
WTrackingUtility::DataSetPtr DataSetPtr
a pointer to a dataset
boost::function< bool(DataSetPtr, JobType &, DirFunc const &) > NextPositionFunc
the path integration function
A grid that has parallelepiped cells which all have the same proportion.
boost::shared_ptr< GridType > GridPtr
a pointer to the grid
WGridRegular3D GridType
the grid type
boost::function< void(std::vector< WVector3d > const &) > FiberVisitorFunc
a visitor function for fibers
DirFunc m_directionFunc
a function that returns the next direction
boost::function< void(WVector3d const &) > PointVisitorFunc
a visitor function type for points
std::pair< WVector3d, WVector3d > JobType
define a job type for tracking algorithms
bool m_done
true, iff there are no more seeds
bool done()
Check if there aren't any more seed positions.
boost::shared_ptr< DataSetType const > DataSetPtr
a pointer to a dataset
std::size_t m_maxPoints
the maximum number of points per forward/backward integration of a fiber
GridPtr m_grid
a pointer to the grid
boost::array< std::size_t, 4 > m_pos
the position in the seed space
A class that provides untility functions and typedefs for tracking algorithms.
PointVisitorFunc m_pointVisitor
the point visitor
virtual bool getJob(JobType &job)
The job generator.
double m_offset
the relative (to the size of a voxel) distance between seeds
virtual void compute(DataSetPtr input, JobType const &job)
The calculation per job.
IndexType()
Construct an invalid index.
WThreadedTrackingFunction(DataSetPtr dataset, DirFunc dirFunc, NextPositionFunc nextFunc, FiberVisitorFunc fiberVst, PointVisitorFunc pointVst, std::size_t seedPositions=1, std::size_t seedsPerPos=1, std::vector< int > v0=std::vector< int >(), std::vector< int > v1=std::vector< int >())
Constructor.
WTrackingUtility::DirFunc DirFunc
the direction calculation function
GridPtr m_grid
a pointer to the grid
boost::array< std::size_t, 4 > m_max
the maximum position in the seed space
boost::array< std::size_t, 4 > m_min
the minimum position in the seed space
static bool followToNextVoxel(DataSetPtr dataset, JobType &job, DirFunc const &dirFunc)
A function that follows a direction until leaving the current voxel.
A data set consisting of a set of values based on a grid.
WSharedObject< IndexType > m_currentIndex
the current index/seed position
Wrapper around an object/type for thread safe sharing of objects among multiple threads.
static double getDistanceToBoundary(Grid3DPtr grid, WVector3d const &pos, WVector3d const &dir)
Calculate the distance from a given position to the nearest voxel boundary on the ray from the positi...
Implements a generalized multithreaded tracking algorithm.
boost::shared_ptr< WGridRegular3D > Grid3DPtr
a pointer to a regular 3d grid
JobType job()
Create a job from this index.
An index for seed positions.
WTrackingUtility::DataSetType DataSetType
the dataset type
WThreadedJobs< DataSetType, JobType > Base
the base class, a threaded job function
virtual ~WThreadedTrackingFunction()
Destructor.
NextPositionFunc m_nextPosFunc
a function that calculates the next position
Test the WThreadedTrackingFunction class.
static bool onBoundary(Grid3DPtr grid, WVector3d const &pos)
Check if a point is on the boundary of the given grid, where boundary means a distance less then TRAC...
boost::function< WVector3d(DataSetPtr, JobType const &) > DirFunc
a function that calculates a direction to continue tracking
WTrackingUtility::JobType JobType
the job type
FiberVisitorFunc m_fiberVisitor
the fiber visitor
WDataSetSingle DataSetType
the dataset type
IndexType & operator++()
Increase the index by one, effectively generating the next seed position.