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