OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
WDataSetFiberVector.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 WDATASETFIBERVECTOR_H
26 #define WDATASETFIBERVECTOR_H
27 
28 #include <string>
29 #include <vector>
30 
31 #include <boost/shared_ptr.hpp>
32 
33 #include "../common/datastructures/WFiber.h"
34 #include "WDataSet.h"
35 #include "WDataSetFibers.h"
36 #include "WExportDataHandler.h"
37 
38 /**
39  * Represents a simple set of WFibers.
40  */
41 class OWDATAHANDLER_EXPORT WDataSetFiberVector : public WMixinVector< WFiber >, public WDataSet // NOLINT
42 {
43 public:
44  /**
45  * Default constructor for creating an empty fiber vector.
46  */
48 
49  /**
50  * Constructs a new set of WFibers
51  *
52  * \param fibs Fiber vector to store in this data set
53  */
54  explicit WDataSetFiberVector( boost::shared_ptr< std::vector< WFiber > > fibs );
55 
56  /**
57  * Convert a WDataSetFibers into a fiber vector dataset.
58  *
59  * \param fiberDS Dataset which has to be converted
60  */
61  explicit WDataSetFiberVector( boost::shared_ptr< const WDataSetFibers > fiberDS );
62 
63  /**
64  * Copy constructor for fibers
65  *
66  * \param other Instance to copy from
67  */
68  // defined since rule of three
69  WDataSetFiberVector( const WDataSetFiberVector& other ); // NOLINT since cxxtest need it as unexcplicit!
70 
71  /**
72  * Destructs WDataSetFiberVector instances
73  */
74  virtual ~WDataSetFiberVector(); // defined since rule of three
75 
76  /**
77  * Operator for assigning instances of WDataSetFiberVector
78  *
79  * \param other Instance which should replace this
80  *
81  * \return Reference for further usage of the outcome of the assigment
82  */
83  WDataSetFiberVector& operator=( const WDataSetFiberVector& other ); // defined since rule of three
84 
85  /**
86  * Sort fibers descending on their length and update
87  */
88  void sortDescLength();
89 
90  /**
91  * Generates new WDataSetFiberVector out of the used fibers from this dataset.
92  *
93  * \param unused If the i'th postion of this vector is true, then this fiber is considered as used.
94  *
95  * \return A reference to the new generate WDataSetFiberVector
96  */
97  boost::shared_ptr< WDataSetFiberVector > generateDataSetOutOfUsedFibers( const std::vector< bool > &unused ) const;
98 
99  /**
100  * Determines whether this dataset can be used as a texture.
101  *
102  * \return true if usable as texture.
103  */
104  virtual bool isTexture() const;
105 
106  /**
107  * Gets the name of this prototype.
108  *
109  * \return the name.
110  */
111  virtual const std::string getName() const;
112 
113  /**
114  * Gets the description for this prototype.
115  *
116  * \return the description
117  */
118  virtual const std::string getDescription() const;
119 
120  /**
121  * Returns a prototype instantiated with the true type of the deriving class.
122  *
123  * \return the prototype.
124  */
125  static boost::shared_ptr< WPrototyped > getPrototype();
126 
127  /**
128  * Convert this dataset into WDataSetFibers format for other purposes if needed. (e.g. display)
129  *
130  * \return Reference to the dataset in WDataSetFibers format
131  */
132  boost::shared_ptr< WDataSetFibers > toWDataSetFibers() const;
133 
134 protected:
135  /**
136  * The prototype as singleton.
137  */
138  static boost::shared_ptr< WPrototyped > m_prototype;
139 };
140 
141 boost::shared_ptr< WFiber > centerLine( boost::shared_ptr< const WDataSetFibers > tracts );
142 
143 boost::shared_ptr< WFiber > longestLine( boost::shared_ptr< const WDataSetFibers > tracts );
144 
145 boost::shared_ptr< WFiber > centerLine( boost::shared_ptr< const WDataSetFiberVector > tracts );
146 
147 boost::shared_ptr< WFiber > longestLine( boost::shared_ptr< const WDataSetFiberVector > tracts );
148 
149 #endif // WDATASETFIBERVECTOR_H