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