OpenWalnut 1.2.5

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