OpenWalnut 1.3.1
WCreateColorArraysThread.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WCREATECOLORARRAYSTHREAD_H
00026 #define WCREATECOLORARRAYSTHREAD_H
00027 
00028 #include <vector>
00029 
00030 #include "../common/WThreadedRunner.h"
00031 
00032 
00033 /**
00034  * implements a thread that updates the fiber selection bit field
00035  */
00036 class WCreateColorArraysThread: public WThreadedRunner // NOLINT
00037 {
00038 public:
00039     /**
00040      * default constructor
00041      *
00042      * \param left
00043      * \param right
00044      * \param vertices
00045      * \param lineStartIndexes
00046      * \param lineLengths
00047      * \param globalColors
00048      * \param localColors
00049      * \param tangents
00050      */
00051     WCreateColorArraysThread( int left, int right, boost::shared_ptr< std::vector< float > >vertices,
00052                                                    boost::shared_ptr< std::vector< size_t > > lineStartIndexes,
00053                                                    boost::shared_ptr< std::vector< size_t > > lineLengths,
00054                                                    boost::shared_ptr< std::vector< float > > globalColors,
00055                                                    boost::shared_ptr< std::vector< float > > localColors,
00056                                                    boost::shared_ptr< std::vector< float > > tangents );
00057 
00058     /**
00059      * destructor
00060      */
00061     virtual ~WCreateColorArraysThread();
00062 
00063     /**
00064      * entry for the run command
00065      */
00066     virtual void threadMain();
00067 
00068     /**
00069      * Return the value of the finished flag.
00070      *
00071      * \return true if finished
00072      */
00073     inline bool isFinished();
00074 
00075 protected:
00076 private:
00077     bool m_myThreadFinished; //!< Has the thread finished?
00078 
00079     int m_left; //!< left boundary
00080 
00081     int m_right; //!< right boundary
00082 
00083     /**
00084      * Point vector for all fibers
00085      */
00086     boost::shared_ptr< std::vector< float > > m_vertices;
00087 
00088     /**
00089      * Point vector for tangents at each vertex, used for fake tubes
00090      */
00091     boost::shared_ptr< std::vector< float > > m_tangents;
00092 
00093     /**
00094      * Storing the global color value of the fibers for each point.
00095      */
00096     boost::shared_ptr< std::vector< float > > m_globalColors;
00097 
00098     /**
00099      * Storing the local color value of the fibers for each point.
00100      * \note it is mutable to allow getLocalColors creating it on demand.
00101      */
00102     mutable boost::shared_ptr< std::vector< float > > m_localColors;
00103 
00104     /**
00105      * Line vector that contains the start index of its first point for each line.
00106      * \warning The index returned cannot be used in the vertices array until
00107      * the number of components for each point is multiplied.
00108      */
00109     boost::shared_ptr< std::vector< size_t > > m_lineStartIndexes;
00110 
00111     /**
00112      * Line vector that contains the number of vertices for each line
00113      */
00114     boost::shared_ptr< std::vector< size_t > > m_lineLengths;
00115 };
00116 
00117 #endif  // WCREATECOLORARRAYSTHREAD_H