OpenWalnut  1.4.0
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  * Convenience typedef for a boost::shared_ptr
47  */
48  typedef boost::shared_ptr< WDataSetSphericalHarmonics > SPtr;
49 
50  /**
51  * Convenience typedef for a boost::shared_ptr; const
52  */
53  typedef boost::shared_ptr< const WDataSetSphericalHarmonics > ConstSPtr;
54 
55  /**
56  * Constructs an instance out of an appropriate value set and a grid.
57  *
58  * \param newValueSet the value set with the spherical harmonics coefficients to use
59  * \param newGrid the grid which maps world space to the value set
60  */
61  WDataSetSphericalHarmonics( boost::shared_ptr< WValueSetBase > newValueSet,
62  boost::shared_ptr< WGrid > newGrid );
63 
64  /**
65  * Construct an empty and unusable instance. This is needed for the prototype mechanism.
66  */
68 
69  /**
70  * Destroys this DataSet instance
71  */
73 
74  /**
75  * 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
76  * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
77  *
78  * \param newValueSet the new valueset.
79  *
80  * \return the clone
81  */
82  virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WValueSetBase > newValueSet ) const;
83 
84  /**
85  * 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
86  * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
87  *
88  * \param newGrid the new grid.
89  *
90  * \return the clone
91  */
92  virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WGrid > newGrid ) const;
93 
94  /**
95  * Creates a copy (clone) of this instance. 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  * \return the clone
99  */
100  virtual WDataSetSingle::SPtr clone() const;
101 
102  /**
103  * Returns a prototype instantiated with the true type of the deriving class.
104  *
105  * \return the prototype.
106  */
107  static boost::shared_ptr< WPrototyped > getPrototype();
108 
109  /**
110  * Interpolates the field of spherical harmonics at the given position
111  *
112  * \param pos position to interpolate
113  * \param success if the position was inside the grid
114  *
115  * \return Interpolated spherical harmonic.
116  */
117  WSymmetricSphericalHarmonic< double > interpolate( const WPosition &pos, bool *success ) const;
118 
119  /**
120  * Get the spherical harmonic on the given position in value set.
121  *
122  * \param index the position where to get the spherical harmonic from
123  *
124  * \return the spherical harmonic
125  */
127 
128  /**
129  * Gets the name of this prototype.
130  *
131  * \return the name.
132  */
133  virtual const std::string getName() const;
134 
135  /**
136  * Gets the description for this prototype.
137  *
138  * \return the description
139  */
140  virtual const std::string getDescription() const;
141 
142  /**
143  * Determines whether this dataset can be used as a texture.
144  *
145  * \return true if usable as texture.
146  */
147  virtual bool isTexture() const;
148 
149 protected:
150  /**
151  * The prototype as singleton.
152  */
153  static boost::shared_ptr< WPrototyped > m_prototype;
154 
155 private:
156  /**
157  * The regular 3d grid of the data set.
158  */
159  boost::shared_ptr< WGridRegular3D > m_gridRegular3D;
160 
161  /**
162  * The valueset of the data set
163  */
164  boost::shared_ptr< WValueSetBase > m_valueSet;
165 };
166 
167 #endif // WDATASETSPHERICALHARMONICS_H