27 #include "../graphicsEngine/WROIBox.h"
28 #include "../graphicsEngine/WROIArbitrary.h"
31 #include "WSelectorRoi.h"
34 WSelectorRoi::WSelectorRoi( osg::ref_ptr< WROI > roi, boost::shared_ptr< const WDataSetFibers > fibers, boost::shared_ptr< WKdTree> kdTree ) :
38 m_size( fibers->size() ),
41 m_bitField = boost::shared_ptr< std::vector<bool> >(
new std::vector<bool>(
m_size, false ) );
47 = boost::shared_ptr< boost::function< void() > >(
new boost::function< void() >( boost::bind( &
WSelectorRoi::setDirty,
this ) ) );
65 if( osg::dynamic_pointer_cast<WROIBox>(
m_roi ).
get() )
70 osg::ref_ptr<WROIBox> box = osg::dynamic_pointer_cast<
WROIBox>(
m_roi );
74 m_boxMin[1] = box->getMinPos()[1];
76 m_boxMin[2] = box->getMinPos()[2];
82 if( osg::dynamic_pointer_cast<WROIArbitrary>(
m_roi ).get() )
86 float threshold =
static_cast<float>( roi->getThreshold() );
89 size_t ny = roi->getCoordDimensions()[1];
91 double dx = roi->getCoordOffsets()[0];
92 double dy = roi->getCoordOffsets()[1];
93 double dz = roi->getCoordOffsets()[2];
97 size_t x =
static_cast<size_t>( ( *m_currentArray )[i * 3 ] / dx );
98 size_t y =
static_cast<size_t>( ( *m_currentArray )[i * 3 + 1] / dy );
99 size_t z =
static_cast<size_t>( ( *m_currentArray )[i * 3 + 2] / dz );
100 int index = x + y * nx + z * nx * ny;
102 if( static_cast<float>( roi->getValue( index ) ) - threshold > 0.1 )
118 int root = left + ( ( right - left ) / 2 );
119 int axis1 = ( axis + 1 ) % 3;
120 int pointIndex =
m_kdTree->m_tree[root] * 3;
124 boxTest( root + 1, right, axis1 );
128 boxTest( left, root - 1, axis1 );
132 int axis2 = ( axis + 2 ) % 3;
134 >=
m_boxMin[axis1] && ( *m_currentArray )[pointIndex + axis2] <=
m_boxMax[axis2]
135 && ( *m_currentArray )[pointIndex + axis2] >=
m_boxMin[axis2] )
139 boxTest( left, root - 1, axis1 );
140 boxTest( root + 1, right, axis1 );
void boxTest(int left, int right, int axis)
recursive function to check for intersections with the roi
~WSelectorRoi()
destructor
osg::ref_ptr< WROI > m_roi
pointer to the roi
void setDirty()
setter sets the dirty flag
boost::shared_ptr< std::vector< float > > m_currentArray
pointer to the array that is used for updating this is used for the recurse update function...
void recalculate()
updates the output bitfiel when something with the rois has changed
boost::shared_ptr< std::vector< bool > > m_bitField
the bitfield that is given to the outside world
boost::shared_ptr< WKdTree > m_kdTree
Stores a pointer to the kdTree used for fiber selection.
size_t m_size
size of the fiber dataset, stored for convinience
A box representing a region of interest.
size_t getLineForPoint(size_t point)
getter
boost::shared_ptr< const WDataSetFibers > m_fibers
Pointer to the fiber data set.
A box containing information on an arbitrarily shaped a region of interest.
std::vector< float > m_boxMin
lower boundary of the box, used for boxtest
std::vector< float > m_boxMax
upper boundary of the box, used for boxtest
boost::shared_ptr< boost::function< void() > > m_changeRoiSignal
Signal that can be used to update the selector ROI.
boost::shared_ptr< std::vector< size_t > > m_currentReverse
pointer to the reverse array that is used for updating this is used for the recurse update function...
boost::shared_ptr< std::vector< bool > > m_workerBitfield
the bitfield we work on
std::vector< size_t > getCoordDimensions()
Get the number of vertices in the three coordinate directions.
WSelectorRoi(osg::ref_ptr< WROI > roi, boost::shared_ptr< const WDataSetFibers > fibers, boost::shared_ptr< WKdTree > kdTree)
constructor