OpenWalnut  1.3.1
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 /**
34  * implements a thread that updates the fiber selection bit field
35  */
37 {
38 public:
39  /**
40  * default constructor
41  *
42  * \param left
43  * \param right
44  * \param vertices
45  * \param lineStartIndexes
46  * \param lineLengths
47  * \param globalColors
48  * \param localColors
49  * \param tangents
50  */
51  WCreateColorArraysThread( int left, int right, boost::shared_ptr< std::vector< float > >vertices,
52  boost::shared_ptr< std::vector< size_t > > lineStartIndexes,
53  boost::shared_ptr< std::vector< size_t > > lineLengths,
54  boost::shared_ptr< std::vector< float > > globalColors,
55  boost::shared_ptr< std::vector< float > > localColors,
56  boost::shared_ptr< std::vector< float > > tangents );
57 
58  /**
59  * destructor
60  */
61  virtual ~WCreateColorArraysThread();
62 
63  /**
64  * entry for the run command
65  */
66  virtual void threadMain();
67 
68  /**
69  * Return the value of the finished flag.
70  *
71  * \return true if finished
72  */
73  inline bool isFinished();
74 
75 protected:
76 private:
77  bool m_myThreadFinished; //!< Has the thread finished?
78 
79  int m_left; //!< left boundary
80 
81  int m_right; //!< right boundary
82 
83  /**
84  * Point vector for all fibers
85  */
86  boost::shared_ptr< std::vector< float > > m_vertices;
87 
88  /**
89  * Point vector for tangents at each vertex, used for fake tubes
90  */
91  boost::shared_ptr< std::vector< float > > m_tangents;
92 
93  /**
94  * Storing the global color value of the fibers for each point.
95  */
96  boost::shared_ptr< std::vector< float > > m_globalColors;
97 
98  /**
99  * Storing the local color value of the fibers for each point.
100  * \note it is mutable to allow getLocalColors creating it on demand.
101  */
102  mutable boost::shared_ptr< std::vector< float > > m_localColors;
103 
104  /**
105  * Line vector that contains the start index of its first point for each line.
106  * \warning The index returned cannot be used in the vertices array until
107  * the number of components for each point is multiplied.
108  */
109  boost::shared_ptr< std::vector< size_t > > m_lineStartIndexes;
110 
111  /**
112  * Line vector that contains the number of vertices for each line
113  */
114  boost::shared_ptr< std::vector< size_t > > m_lineLengths;
115 };
116 
117 #endif // WCREATECOLORARRAYSTHREAD_H