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