30 #include "../common/datastructures/WFiber.h"
31 #include "../common/WBoundingBox.h"
32 #include "../common/WColor.h"
33 #include "../common/WLogger.h"
34 #include "../common/WPredicateHelper.h"
35 #include "../common/WPropertyHelper.h"
36 #include "../graphicsEngine/WGEUtils.h"
37 #include "exceptions/WDHNoSuchDataSet.h"
38 #include "WCreateColorArraysThread.h"
40 #include "WDataSetFibers.h"
57 m_vertices( vertices ),
58 m_lineStartIndexes( lineStartIndexes ),
59 m_lineLengths( lineLengths ),
60 m_verticesReverse( verticesReverse ),
63 WAssert(
m_vertices->size() % 3 == 0,
"Invalid vertex array." );
72 m_vertices( vertices ),
73 m_lineStartIndexes( lineStartIndexes ),
74 m_lineLengths( lineLengths ),
75 m_verticesReverse( verticesReverse )
77 WAssert(
m_vertices->size() % 3 == 0,
"Invalid vertex array." );
79 for(
size_t i = 0; i < vertices->size()/3; ++i )
81 m_bb.
expandBy( (*vertices)[ 3 * i + 0 ], (*vertices)[ 3 * i + 1 ], (*vertices)[ 3 * i + 2 ] );
94 m_vertices( vertices ),
95 m_lineStartIndexes( lineStartIndexes ),
96 m_lineLengths( lineLengths ),
97 m_verticesReverse( verticesReverse ),
99 m_vertexParameters( vertexParameters )
101 WAssert(
m_vertices->size() % 3 == 0,
"Invalid vertex array." );
111 m_vertices( vertices ),
112 m_lineStartIndexes( lineStartIndexes ),
113 m_lineLengths( lineLengths ),
114 m_verticesReverse( verticesReverse ),
115 m_vertexParameters( vertexParameters )
117 WAssert(
m_vertices->size() % 3 == 0,
"Invalid vertex array." );
119 for(
size_t i = 0; i < vertices->size()/3; ++i )
121 m_bb.
expandBy( (*vertices)[ 3 * i + 0 ], (*vertices)[ 3 * i + 1 ], (*vertices)[ 3 * i + 2 ] );
130 m_tangents = boost::shared_ptr< std::vector< float > >(
new std::vector<float>(
size ) );
132 boost::shared_ptr< std::vector< float > > globalColors(
new std::vector<float>( size ) );
133 boost::shared_ptr< std::vector< float > > localColors(
new std::vector<float>( size ) );
134 boost::shared_ptr< std::vector< float > > customColors(
new std::vector<float>( size ) );
162 m_colors->push_back( boost::shared_ptr< WItemSelectionItem >(
163 new ColorScheme(
"Global Color",
"Colors direction by using start and end vertex per fiber.", NULL, globalColors,
ColorScheme::RGB )
166 m_colors->push_back( boost::shared_ptr< WItemSelectionItem >(
167 new ColorScheme(
"Local Color",
"Colors direction by using start and end vertex per segment.", NULL, localColors,
ColorScheme::RGB )
171 for(
size_t i = 0; i <
size; ++i )
173 ( *customColors )[i] = ( *globalColors )[i];
175 m_colors->push_back( boost::shared_ptr< WItemSelectionItem >(
176 new ColorScheme(
"Custom Color",
"Colors copied from the global colors, will be used for bundle coloring.",
185 m_infoProperties->addProperty(
"#Fibers",
"The number of fibers", static_cast< WPVBaseTypes::PV_INT >( m_lineLengths->size() ) );
186 m_infoProperties->addProperty(
"#Vertices",
"The number of vertices", static_cast< WPVBaseTypes::PV_INT >(
m_vertices->size() ) );
201 return "WDataSetFibers";
206 return "Contains tracked fiber data.";
250 size_t cols = colors->size();
251 if( cols / verts == 3 )
255 else if( cols / verts == 4 )
260 m_colors->push_back( boost::shared_ptr< WItemSelectionItem >(
261 new ColorScheme( name, description, NULL, colors, mode )
272 while( i != l->get().end() )
274 if( boost::static_pointer_cast< const ColorScheme >( *i )->getColor() == colors )
276 i = l->get().erase( i );
291 boost::shared_ptr< ColorScheme > ci = boost::static_pointer_cast<
ColorScheme >( *i );
292 if(ci->getColor() == oldColors )
305 if( i == l->get().end() )
307 throw WDHNoSuchDataSet( std::string(
"Color scheme with specified name could not be found." ) );
310 return boost::static_pointer_cast<
ColorScheme >( *i );
316 return boost::static_pointer_cast<
ColorScheme >( l->get()[ idx ] );
349 tangent = point - pointNext;
354 tangent = pointBefore - point;
360 tangent = pointBefore - pointNext;
363 return normalize( tangent );
373 WAssert( numTract < m_lineLengths->
size(),
"WDataSetFibers: out of bounds - invalid tract number requested." );
376 size_t vIdx = ( *m_lineStartIndexes )[ numTract ] * 3;
377 for(
size_t vertexNum = 0; vertexNum < ( *m_lineLengths )[ numTract ]; ++vertexNum )
402 : m_fibers( fibers ),
408 : m_fibers( iter.m_fibers ),
409 m_index( iter.m_index )
468 WAssert( m_index < m_fibers->getLineLengths()->size(),
"" );
516 : m_fibers( fibers ),
517 m_fiberIndex( fbIdx ),
524 : m_fibers( iter.m_fibers ),
525 m_fiberIndex( iter.m_fiberIndex ),
526 m_index( iter.m_index ),
527 m_reverse( iter.m_reverse )
579 WAssert( m_fiberIndex < m_fibers->getLineLengths()->size(),
"" );
580 WAssert( m_index < m_fibers->getLineLengths()->
operator[] (
m_fiberIndex ),
"" );
602 wlog::warn(
"FiberPointsIterator" ) <<
"Comparing a reverse and a normal iterator!";
635 switch( scheme->getMode() )
639 double r = scheme->getColor()->operator[]( 1 * v + 0 );
640 ret.set( r, r, r, 1.0 );
645 double r = scheme->getColor()->operator[]( 3 * v + 0 );
646 double g = scheme->getColor()->operator[]( 3 * v + 1 );
647 double b = scheme->getColor()->operator[]( 3 * v + 2 );
648 ret.set( r, g, b, 1.0 );
653 double r = scheme->getColor()->operator[]( 4 * v + 0 );
654 double g = scheme->getColor()->operator[]( 4 * v + 1 );
655 double b = scheme->getColor()->operator[]( 4 * v + 2 );
656 double a = scheme->getColor()->operator[]( 4 * v + 3 );
657 ret.set( r, g, b, a );
661 ret.set( 1.0, 1.0, 1.0, 1.0 );
WFiberPointsIterator & operator--()
Decrement operator.
double getParameter(double def=0.0) const
Returns the parameter specified in the vertex parameter array of the dataset.
boost::shared_ptr< WSharedObjectTicketWrite< std::vector< boost::shared_ptr< WItemSelectionItem > > > > WriteTicket
Type for write tickets.
VertexArray m_vertices
Point vector for all fibers.
Represents a simple set of WFibers.
bool m_reverse
Whether to iterate backwards.
virtual void run()
Run thread.
virtual bool isTexture() const
Determines whether this dataset can be used as a texture.
Thread for computing directional color coding of fibers.
Represents a neural pathway.
Base class for all data set types.
WFiberPointsIterator & operator=(WFiberPointsIterator const &iter)
Copy operator.
const_iterator end() const
Returns an iterator pointing beyond the last fiber.
static boost::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
WFiberIterator & operator++()
Increment operator.
void push_back(const value_type &value)
Wrapper around std::vector member function.
virtual const std::string getName() const
Gets the name of this prototype.
void expandBy(const WBoundingBoxImpl< VT > &bb)
Expands this bounding box to include the given bounding box.
Item used in the selection below also containing color info.
bool operator!=(WFiberIterator const &rhs) const
Compare to another fiber iterator.
std::size_t m_index
The index of the current point.
WPosition getPosition(size_t fiber, size_t vertex) const
returns the position in space for a vertex of a given fiber
WDataSetFibers const * m_fibers
The pointer to the fibers.
WFiberPointsIterator rbegin()
Creates a point iterator for backward iteration, pointing to the last point of the fiber...
~WFiberIterator()
Destructor.
void reserve(size_type new_capacity)
Wrapper around std::vector member function.
std::size_t getBaseIndex() const
Calculates the index of this point in the dataset arrays.
This only is a 3d double vector.
VertexParemeterArray m_vertexParameters
Parameter array.
WPropSelection m_colorProp
Property keeping track of the active color in m_colors.
WDataSetFibers const * m_fibers
The pointer to the fibers.
virtual const std::string getDescription() const
Gets the description for this prototype.
WBoundingBox getBoundingBox() const
Get the bounding box.
void replaceColorScheme(WDataSetFibers::ColorArray oldColors, WDataSetFibers::ColorArray newColors)
Replaces the specified old color scheme by the new color scheme.
void removeColorScheme(WDataSetFibers::ColorArray colors)
This method removes the specified color scheme from the list and triggers an update.
void setColor(ColorArray color, ColorMode mode=RGB)
Sets the color array for this item.
const boost::shared_ptr< ColorScheme > getColorScheme() const
Convenience method returning the currently selected scheme.
std::size_t m_index
The current index in the fiber data.
std::vector< boost::shared_ptr< WItemSelectionItem > >::const_iterator ConstIterator
A typedef for the correct const iterator useful to traverse this sequence container.
boost::shared_ptr< WProperties > m_properties
The property object for the dataset.
WPosition getTangent(size_t fiber, size_t vertex) const
calculates the tangent for a point on the fiber
LengthArray m_lineLengths
Line vector that contains the number of vertices for each line.
~WFiberPointsIterator()
Destructor.
const WPropSelection getColorSchemeProperty() const
Returns the property controlling the color scheme selection.
WFiberIterator & operator=(WFiberIterator const &iter)
Copy operator.
boost::shared_ptr< WProperties > m_infoProperties
The property object for the dataset containing only props whose purpose is "PV_PURPOSE_INFORMNATION"...
A class containing a list of named items.
std::size_t numPoints() const
Returns the number of points of the current fiber.
TangentArray getTangents() const
Returns an array containing the tangents of the fibers at the vertices.
WFiberPointsIterator begin()
Creates a point iterator for forward iteration, pointing to the first point of the fiber...
WPosition getTangent() const
The tangent of the point.
const_iterator begin() const
Returns an iterator to the first fiber of the dataset.
bool operator==(WFiberIterator const &rhs) const
Compare to another fiber iterator.
std::size_t m_fiberIndex
The index of the fiber.
bool operator==(WFiberPointsIterator const &rhs) const
Compare to another point iterator.
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.
An iterator for fibers of a fiber dataset.
WPosition operator*()
Returns the coordinates of the point currently pointed to.
bool operator!=(WFiberPointsIterator const &rhs) const
Compare to another point iterator.
boost::shared_ptr< std::vector< float > > VertexArray
List of vertex coordinates in term of components of vertices.
std::size_t getIndex() const
Get the index of the line.
IndexArray getVerticesReverse() const
Returns a reverse lookup table that allow do find out which vertex belongs to which line...
WDataSetFibers()
Constructs a new set of tracts.
WFiberPointsIterator rend()
Creates a point iterator for backward iteration, pointing beyond the first point of the fiber...
IndexArray getLineStartIndexes() const
Return the indices that indicate at which vertex ID each line begins in the vertex array...
boost::shared_ptr< std::vector< float > > ColorArray
Colors for each vertex in VertexArray.
std::size_t getLineStartIndex() const
Get the index in the point array where the points data starts for this line.
boost::shared_ptr< WItemSelection > m_colors
An array of color arrays.
boost::shared_ptr< std::vector< size_t > > LengthArray
Lengths of fibers in terms of vertices.
boost::shared_ptr< std::vector< float > > TangentArray
Tangents at each vertex in VertexArray.
ColorMode
different kinds of color arrays can be used in this class.
void init()
This does the common initialisation of the constructors.
WFiberPointsIterator()
Default contructor.
Should be thrown when an invalid index is used to get a WDataSet from the WSubject.
void wait(bool requestFinish=false)
Wait for the thread to be finished.
static boost::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
const boost::shared_ptr< ColorScheme > getColorScheme(std::string name) const
Get the color scheme with the specified name.
LengthArray getLineLengths() const
Return the number of vertices for all lines.
boost::shared_ptr< std::vector< double > > VertexParemeterArray
Parameter storage for each vertex.
WFiberPointsIterator end()
Creates a point iterator for forward iteration, pointing beyond the last point of the fiber...
boost::shared_ptr< std::vector< size_t > > IndexArray
Index list indexing fibers in VertexArray in terms of vertex numbers.
void addColorScheme(WDataSetFibers::ColorArray colors, std::string name, std::string description)
This method adds a new color scheme to the list of available colors.
WColor getColor() const
Return the color of the point.
WFiberIterator & operator--()
Decrement operator.
VertexParemeterArray getVertexParameters() const
Get the parameter values for each vertex.
WFiberPointsIterator & operator++()
Increment operator.
WBoundingBox m_bb
Axis aligned bounding box for all tract-vertices of this dataset.
IndexArray m_lineStartIndexes
Line vector that contains the start index of its first point for each line.
std::vector< boost::shared_ptr< WItemSelectionItem > >::iterator Iterator
A typedef for the correct iterator to traverse this sequence container.
boost::shared_ptr< WSharedObjectTicketRead< std::vector< boost::shared_ptr< WItemSelectionItem > > > > ReadTicket
Type for read tickets.
This class tests against the getName() method of the instances of type T.
size_t size() const
Get number of tracts in this data set.
WStreamedLogger warn(const std::string &source)
Logging a warning message.
IndexArray m_verticesReverse
Reverse lookup table for which point belongs to which fiber.
WFiberIterator()
Constructor.
VertexArray getVertices() const
Getter for the lines' vertices.
WFiber operator[](size_t numTract) const
Constructs a WFiber out of the given tract number.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.
TangentArray m_tangents
Point vector for tangents at each vertex, used for fake tubes.
An iterator for iterating the points of a fiber.