OpenWalnut
1.4.0
|
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 WFIBERACCUMULATOR_H 00026 #define WFIBERACCUMULATOR_H 00027 00028 #include <vector> 00029 00030 #include <boost/shared_ptr.hpp> 00031 #include <boost/thread.hpp> 00032 00033 #include "../common/math/linearAlgebra/WVectorFixed.h" 00034 #include "WDataSetFiberVector.h" 00035 #include "WDataSetFibers.h" 00036 00037 00038 /** 00039 * A class that encapsulates the data needed to construct a WDataSetFibers. 00040 */ 00041 class WFiberAccumulator // NOLINT 00042 { 00043 public: 00044 /** 00045 * Constructor. 00046 */ 00047 WFiberAccumulator(); 00048 00049 /** 00050 * Destructor. 00051 */ 00052 virtual ~WFiberAccumulator(); 00053 00054 /** 00055 * Add a fiber to the dataset. 00056 * 00057 * \param in The fiber to add, stored as a vector of Positions. 00058 * 00059 * This function is threadsafe. 00060 */ 00061 void add( std::vector< WVector3d > const& in ); 00062 00063 /** 00064 * Return the dataset that has been accumulated to this point 00065 * and start a new dataset. 00066 * 00067 * \return A shared_ptr pointing to the WDataSetFibers that has been accumulated. 00068 * 00069 * The returned shared_ptr is the sole owner of the WDataSetFibers. 00070 */ 00071 boost::shared_ptr< WDataSetFibers > buildDataSet(); 00072 00073 /** 00074 * Clears all data. 00075 */ 00076 void clear(); 00077 00078 protected: 00079 private: 00080 /** 00081 * A mutex needed to guarantee thread-safety. 00082 */ 00083 boost::mutex m_fiberMutex; 00084 00085 /** 00086 * One of the vectors needed to construct a WDataSetFibers. 00087 * Stores the points in a vector of floats. 00088 */ 00089 boost::shared_ptr< std::vector< float > > m_points; 00090 00091 /** 00092 * One of the vectors needed to construct a WDataSetFibers. 00093 * Stores the starting indices (refering to the points vector) of the fibers. 00094 */ 00095 boost::shared_ptr< std::vector< size_t > > m_fiberIndices; 00096 00097 /** 00098 * One of the vectors needed to construct a WDataSetFibers. 00099 * Stores the length of the fibers. 00100 */ 00101 boost::shared_ptr< std::vector< size_t > > m_fiberLengths; 00102 00103 /** 00104 * One of the vectors needed to construct a WDataSetFibers. 00105 * Stores information about what fiber a point in the points vector refers to. 00106 */ 00107 boost::shared_ptr< std::vector< size_t > > m_pointToFiber; 00108 }; 00109 00110 #endif // WFIBERACCUMULATOR_H