OpenWalnut  1.4.0
WFiberAccumulator.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 WFIBERACCUMULATOR_H
26 #define WFIBERACCUMULATOR_H
27 
28 #include <vector>
29 
30 #ifndef Q_MOC_RUN
31 #include <boost/shared_ptr.hpp>
32 #endif
33 #ifndef Q_MOC_RUN
34 #include <boost/thread.hpp>
35 #endif
36 
37 #include "../common/math/linearAlgebra/WVectorFixed.h"
38 #include "WDataSetFiberVector.h"
39 #include "WDataSetFibers.h"
40 
41 
42 /**
43  * A class that encapsulates the data needed to construct a WDataSetFibers.
44  */
45 class WFiberAccumulator // NOLINT
46 {
47 public:
48  /**
49  * Constructor.
50  */
52 
53  /**
54  * Destructor.
55  */
56  virtual ~WFiberAccumulator();
57 
58  /**
59  * Add a fiber to the dataset.
60  *
61  * \param in The fiber to add, stored as a vector of Positions.
62  *
63  * This function is threadsafe.
64  */
65  void add( std::vector< WVector3d > const& in );
66 
67  /**
68  * Return the dataset that has been accumulated to this point
69  * and start a new dataset.
70  *
71  * \return A shared_ptr pointing to the WDataSetFibers that has been accumulated.
72  *
73  * The returned shared_ptr is the sole owner of the WDataSetFibers.
74  */
75  boost::shared_ptr< WDataSetFibers > buildDataSet();
76 
77  /**
78  * Clears all data.
79  */
80  void clear();
81 
82 protected:
83 private:
84  /**
85  * A mutex needed to guarantee thread-safety.
86  */
87  boost::mutex m_fiberMutex;
88 
89  /**
90  * One of the vectors needed to construct a WDataSetFibers.
91  * Stores the points in a vector of floats.
92  */
93  boost::shared_ptr< std::vector< float > > m_points;
94 
95  /**
96  * One of the vectors needed to construct a WDataSetFibers.
97  * Stores the starting indices (refering to the points vector) of the fibers.
98  */
99  boost::shared_ptr< std::vector< size_t > > m_fiberIndices;
100 
101  /**
102  * One of the vectors needed to construct a WDataSetFibers.
103  * Stores the length of the fibers.
104  */
105  boost::shared_ptr< std::vector< size_t > > m_fiberLengths;
106 
107  /**
108  * One of the vectors needed to construct a WDataSetFibers.
109  * Stores information about what fiber a point in the points vector refers to.
110  */
111  boost::shared_ptr< std::vector< size_t > > m_pointToFiber;
112 };
113 
114 #endif // WFIBERACCUMULATOR_H
A class that encapsulates the data needed to construct a WDataSetFibers.
boost::shared_ptr< std::vector< size_t > > m_pointToFiber
One of the vectors needed to construct a WDataSetFibers.
boost::shared_ptr< WDataSetFibers > buildDataSet()
Return the dataset that has been accumulated to this point and start a new dataset.
WFiberAccumulator()
Constructor.
boost::shared_ptr< std::vector< size_t > > m_fiberLengths
One of the vectors needed to construct a WDataSetFibers.
void clear()
Clears all data.
void add(std::vector< WVector3d > const &in)
Add a fiber to the dataset.
boost::mutex m_fiberMutex
A mutex needed to guarantee thread-safety.
virtual ~WFiberAccumulator()
Destructor.
boost::shared_ptr< std::vector< float > > m_points
One of the vectors needed to construct a WDataSetFibers.
boost::shared_ptr< std::vector< size_t > > m_fiberIndices
One of the vectors needed to construct a WDataSetFibers.