OpenWalnut  1.3.1
WDataSetSphericalHarmonics.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 WDATASETSPHERICALHARMONICS_H
26 #define WDATASETSPHERICALHARMONICS_H
27 
28 #include <string>
29 #include <vector>
30 
31 #include "../common/math/WSymmetricSphericalHarmonic.h"
32 
33 #include "WValueSet.h"
34 
35 #include "WDataSetSingle.h"
36 
37 
38 /**
39  * This data set type contains spherical harmonic coefficients as values. The index scheme is like in the Descoteaux paper "Regularized, Fast, and Robust Analytical Q-Ball Imaging".
40  * \ingroup dataHandler
41  */
43 {
44 public:
45  /**
46  * Constructs an instance out of an appropriate value set and a grid.
47  *
48  * \param newValueSet the value set with the spherical harmonics coefficients to use
49  * \param newGrid the grid which maps world space to the value set
50  */
51  WDataSetSphericalHarmonics( boost::shared_ptr< WValueSetBase > newValueSet,
52  boost::shared_ptr< WGrid > newGrid );
53 
54  /**
55  * Construct an empty and unusable instance. This is needed for the prototype mechanism.
56  */
58 
59  /**
60  * Destroys this DataSet instance
61  */
63 
64  /**
65  * Creates a copy (clone) of this instance but allows one to change the valueset. Unlike copy construction, this is a very useful function if you
66  * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
67  *
68  * \param newValueSet the new valueset.
69  *
70  * \return the clone
71  */
72  virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WValueSetBase > newValueSet ) const;
73 
74  /**
75  * Creates a copy (clone) of this instance but allows one to change the grid. Unlike copy construction, this is a very useful function if you
76  * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
77  *
78  * \param newGrid the new grid.
79  *
80  * \return the clone
81  */
82  virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WGrid > newGrid ) const;
83 
84  /**
85  * Creates a copy (clone) of this instance. Unlike copy construction, this is a very useful function if you
86  * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
87  *
88  * \return the clone
89  */
90  virtual WDataSetSingle::SPtr clone() const;
91 
92  /**
93  * Returns a prototype instantiated with the true type of the deriving class.
94  *
95  * \return the prototype.
96  */
97  static boost::shared_ptr< WPrototyped > getPrototype();
98 
99  /**
100  * Interpolates the field of spherical harmonics at the given position
101  *
102  * \param pos position to interpolate
103  * \param success if the position was inside the grid
104  *
105  * \return Interpolated spherical harmonic.
106  */
107  WSymmetricSphericalHarmonic interpolate( const WPosition &pos, bool *success ) const;
108 
109  /**
110  * Get the spherical harmonic on the given position in value set.
111  *
112  * \param index the position where to get the spherical harmonic from
113  *
114  * \return the spherical harmonic
115  */
117 
118  /**
119  * Gets the name of this prototype.
120  *
121  * \return the name.
122  */
123  virtual const std::string getName() const;
124 
125  /**
126  * Gets the description for this prototype.
127  *
128  * \return the description
129  */
130  virtual const std::string getDescription() const;
131 
132  /**
133  * Determines whether this dataset can be used as a texture.
134  *
135  * \return true if usable as texture.
136  */
137  virtual bool isTexture() const;
138 
139 protected:
140  /**
141  * The prototype as singleton.
142  */
143  static boost::shared_ptr< WPrototyped > m_prototype;
144 
145 private:
146  /**
147  * The regular 3d grid of the data set.
148  */
149  boost::shared_ptr< WGridRegular3D > m_gridRegular3D;
150 
151  /**
152  * The valueset of the data set
153  */
154  boost::shared_ptr< WValueSetBase > m_valueSet;
155 };
156 
157 #endif // WDATASETSPHERICALHARMONICS_H