32 #ifndef BOOST_FILESYSTEM_VERSION
33 #define BOOST_FILESYSTEM_VERSION 2
35 #include <boost/filesystem/fstream.hpp>
36 #include <boost/lexical_cast.hpp>
38 #include "../common/datastructures/WFiber.h"
39 #include "../common/WBoundingBox.h"
40 #include "../common/WColor.h"
41 #include "../common/WLogger.h"
42 #include "../common/WPredicateHelper.h"
43 #include "../common/WPropertyHelper.h"
44 #include "../graphicsEngine/WGEUtils.h"
45 #include "exceptions/WDHNoSuchDataSet.h"
46 #include "WCreateColorArraysThread.h"
48 #include "WDataSetFibers.h"
65 m_vertices( vertices ),
66 m_lineStartIndexes( lineStartIndexes ),
67 m_lineLengths( lineLengths ),
68 m_verticesReverse( verticesReverse ),
71 WAssert(
m_vertices->size() % 3 == 0,
"Invalid vertex array." );
80 m_vertices( vertices ),
81 m_lineStartIndexes( lineStartIndexes ),
82 m_lineLengths( lineLengths ),
83 m_verticesReverse( verticesReverse )
85 WAssert(
m_vertices->size() % 3 == 0,
"Invalid vertex array." );
87 for(
size_t i = 0; i < vertices->size()/3; ++i )
89 m_bb.
expandBy( (*vertices)[ 3 * i + 0 ], (*vertices)[ 3 * i + 1 ], (*vertices)[ 3 * i + 2 ] );
98 m_tangents = boost::shared_ptr< std::vector< float > >(
new std::vector<float>(
size ) );
100 boost::shared_ptr< std::vector< float > > globalColors = boost::shared_ptr< std::vector< float > >(
new std::vector<float>(
size ) );
101 boost::shared_ptr< std::vector< float > > localColors = boost::shared_ptr< std::vector< float > >(
new std::vector<float>(
size ) );
102 boost::shared_ptr< std::vector< float > > customColors = boost::shared_ptr< std::vector< float > >(
new std::vector<float>(
size ) );
131 m_colors->push_back( boost::shared_ptr< WItemSelectionItem >(
132 new ColorScheme(
"Global Color",
"Colors direction by using start and end vertex per fiber.", NULL, globalColors,
ColorScheme::RGB )
135 m_colors->push_back( boost::shared_ptr< WItemSelectionItem >(
136 new ColorScheme(
"Local Color",
"Colors direction by using start and end vertex per segment.", NULL, localColors,
ColorScheme::RGB )
140 for(
size_t i = 0; i <
size; ++i )
142 ( *customColors )[i] = ( *globalColors )[i];
144 m_colors->push_back( boost::shared_ptr< WItemSelectionItem >(
145 new ColorScheme(
"Custom Color",
"Colors copied from the global colors, will be used for bundle coloring.",
168 return "WDataSetFibers";
173 return "Contains tracked fiber data.";
213 return boost::shared_static_cast<
const ColorScheme >( ( *m_colors )[0] )->getColor();
218 return boost::shared_static_cast<
const ColorScheme >( ( *m_colors )[1] )->getColor();
227 size_t cols = colors->size();
228 if( cols / verts == 3 )
232 else if( cols / verts == 4 )
237 m_colors->push_back( boost::shared_ptr< WItemSelectionItem >(
238 new ColorScheme( name, description, NULL, colors, mode )
249 while( i != l->get().end() )
251 if( boost::shared_static_cast< const ColorScheme >( *i )->getColor() == colors )
253 i = l->get().erase( i );
268 boost::shared_ptr< ColorScheme > ci = boost::shared_static_cast<
ColorScheme >( *i );
269 if(ci->getColor() == oldColors )
282 if( i == l->get().end() )
284 throw WDHNoSuchDataSet( std::string(
"Color scheme with specified name could not be found." ) );
287 return boost::shared_static_cast<
ColorScheme >( *i );
293 return boost::shared_static_cast<
ColorScheme >( l->get()[ idx ] );
321 tangent = point - pointNext;
326 tangent = pointBefore - point;
332 tangent = pointBefore - pointNext;
335 return normalize( tangent );
345 WAssert( numTract < m_lineLengths->
size(),
"WDataSetFibers: out of bounds - invalid tract number requested." );
348 size_t vIdx = ( *m_lineStartIndexes )[ numTract ] * 3;
349 for(
size_t vertexNum = 0; vertexNum < ( *m_lineLengths )[ numTract ]; ++vertexNum )