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