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 );