31 #include <boost/filesystem/fstream.hpp>
33 #include "../common/datastructures/WFiber.h"
34 #include "../common/WBoundingBox.h"
35 #include "../common/WColor.h"
36 #include "../common/WLogger.h"
37 #include "../common/WPredicateHelper.h"
38 #include "../common/WPropertyHelper.h"
39 #include "../graphicsEngine/WGEUtils.h"
40 #include "exceptions/WDHNoSuchDataSet.h"
41 #include "WCreateColorArraysThread.h"
43 #include "WDataSetFibers.h"
60 m_vertices( vertices ),
61 m_lineStartIndexes( lineStartIndexes ),
62 m_lineLengths( lineLengths ),
63 m_verticesReverse( verticesReverse ),
66 WAssert(
m_vertices->size() % 3 == 0,
"Invalid vertex array." );
75 m_vertices( vertices ),
76 m_lineStartIndexes( lineStartIndexes ),
77 m_lineLengths( lineLengths ),
78 m_verticesReverse( verticesReverse )
80 WAssert(
m_vertices->size() % 3 == 0,
"Invalid vertex array." );
82 for(
size_t i = 0; i < vertices->size()/3; ++i )
84 m_bb.
expandBy( (*vertices)[ 3 * i + 0 ], (*vertices)[ 3 * i + 1 ], (*vertices)[ 3 * i + 2 ] );
93 m_tangents = boost::shared_ptr< std::vector< float > >(
new std::vector<float>(
size ) );
95 boost::shared_ptr< std::vector< float > > globalColors = boost::shared_ptr< std::vector< float > >(
new std::vector<float>(
size ) );
96 boost::shared_ptr< std::vector< float > > localColors = boost::shared_ptr< std::vector< float > >(
new std::vector<float>(
size ) );
97 boost::shared_ptr< std::vector< float > > customColors = boost::shared_ptr< std::vector< float > >(
new std::vector<float>(
size ) );
126 m_colors->push_back( boost::shared_ptr< WItemSelectionItem >(
127 new ColorScheme(
"Global Color",
"Colors direction by using start and end vertex per fiber.", NULL, globalColors,
ColorScheme::RGB )
130 m_colors->push_back( boost::shared_ptr< WItemSelectionItem >(
131 new ColorScheme(
"Local Color",
"Colors direction by using start and end vertex per segment.", NULL, localColors,
ColorScheme::RGB )
135 for(
size_t i = 0; i <
size; ++i )
137 ( *customColors )[i] = ( *globalColors )[i];
139 m_colors->push_back( boost::shared_ptr< WItemSelectionItem >(
140 new ColorScheme(
"Custom Color",
"Colors copied from the global colors, will be used for bundle coloring.",
163 return "WDataSetFibers";
168 return "Contains tracked fiber data.";
208 return boost::static_pointer_cast<
const ColorScheme >( ( *m_colors )[0] )->getColor();
213 return boost::static_pointer_cast<
const ColorScheme >( ( *m_colors )[1] )->getColor();
222 size_t cols = colors->size();
223 if( cols / verts == 3 )
227 else if( cols / verts == 4 )
232 m_colors->push_back( boost::shared_ptr< WItemSelectionItem >(
233 new ColorScheme( name, description, NULL, colors, mode )
244 while( i != l->get().end() )
246 if( boost::static_pointer_cast< const ColorScheme >( *i )->getColor() == colors )
248 i = l->get().erase( i );
263 boost::shared_ptr< ColorScheme > ci = boost::static_pointer_cast<
ColorScheme >( *i );
264 if(ci->getColor() == oldColors )
277 if( i == l->get().end() )
279 throw WDHNoSuchDataSet( std::string(
"Color scheme with specified name could not be found." ) );
282 return boost::static_pointer_cast<
ColorScheme >( *i );
288 return boost::static_pointer_cast<
ColorScheme >( l->get()[ idx ] );
316 tangent = point - pointNext;
321 tangent = pointBefore - point;
327 tangent = pointBefore - pointNext;
330 return normalize( tangent );
340 WAssert( numTract < m_lineLengths->
size(),
"WDataSetFibers: out of bounds - invalid tract number requested." );
343 size_t vIdx = ( *m_lineStartIndexes )[ numTract ] * 3;
344 for(
size_t vertexNum = 0; vertexNum < ( *m_lineLengths )[ numTract ]; ++vertexNum )