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