OpenWalnut  1.4.0
WCreateColorArraysThread.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WCREATECOLORARRAYSTHREAD_H
26 #define WCREATECOLORARRAYSTHREAD_H
27 
28 #include <vector>
29 
30 #include "../common/WThreadedRunner.h"
31 
32 /**
33  * Thread for computing directional color coding of fibers.
34  */
36 {
37 public:
38  /**
39  * default constructor
40  *
41  * \param left start position of the first line to comput colors for
42  * \param right last line for which the color is computed
43  * \param vertices vertices of all lines
44  * \param lineLengths line length in vertex array
45  * \param globalColors where to write global coloring
46  * \param localColors where to write local coloring
47  * \param tangents
48  */
49  WCreateColorArraysThread( int left, int right, boost::shared_ptr< std::vector< float > >vertices,
50  boost::shared_ptr< std::vector< size_t > > lineLengths,
51  boost::shared_ptr< std::vector< float > > globalColors,
52  boost::shared_ptr< std::vector< float > > localColors,
53  boost::shared_ptr< std::vector< float > > tangents );
54 
55  /**
56  * destructor
57  */
58  virtual ~WCreateColorArraysThread();
59 
60  /**
61  * entry for the run command
62  */
63  virtual void threadMain();
64 
65  /**
66  * Return the value of the finished flag.
67  *
68  * \return true if finished
69  */
70  inline bool isFinished();
71 
72 protected:
73 private:
74  bool m_myThreadFinished; //!< Has the thread finished?
75 
76  int m_left; //!< left boundary
77 
78  int m_right; //!< right boundary
79 
80  /**
81  * Point vector for all fibers
82  */
83  boost::shared_ptr< const std::vector< float > > m_vertices;
84 
85  /**
86  * Point vector for tangents at each vertex, used for fake tubes
87  */
88  boost::shared_ptr< std::vector< float > > m_tangents;
89 
90  /**
91  * Storing the global color value of the fibers for each point.
92  */
93  boost::shared_ptr< std::vector< float > > m_globalColors;
94 
95  /**
96  * Storing the local color value of the fibers for each point.
97  * \note it is mutable to allow getLocalColors creating it on demand.
98  */
99  boost::shared_ptr< std::vector< float > > m_localColors;
100 
101  /**
102  * Line vector that contains the number of vertices for each line
103  */
104  boost::shared_ptr< const std::vector< size_t > > m_lineLengths;
105 };
106 
107 #endif // WCREATECOLORARRAYSTHREAD_H