OpenWalnut  1.4.0
WDataSetSphericalHarmonics.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WDATASETSPHERICALHARMONICS_H
00026 #define WDATASETSPHERICALHARMONICS_H
00027 
00028 #include <string>
00029 #include <vector>
00030 
00031 #include "../common/math/WSymmetricSphericalHarmonic.h"
00032 
00033 #include "WValueSet.h"
00034 
00035 #include "WDataSetSingle.h"
00036 
00037 
00038 /**
00039  * 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".
00040  * \ingroup dataHandler
00041  */
00042 class WDataSetSphericalHarmonics : public WDataSetSingle // NOLINT
00043 {
00044 public:
00045     /**
00046      * Convenience typedef for a boost::shared_ptr
00047      */
00048     typedef boost::shared_ptr< WDataSetSphericalHarmonics > SPtr;
00049 
00050     /**
00051      * Convenience typedef for a boost::shared_ptr; const
00052      */
00053     typedef boost::shared_ptr< const WDataSetSphericalHarmonics > ConstSPtr;
00054 
00055     /**
00056      * Constructs an instance out of an appropriate value set and a grid.
00057      *
00058      * \param newValueSet the value set with the spherical harmonics coefficients to use
00059      * \param newGrid the grid which maps world space to the value set
00060      */
00061     WDataSetSphericalHarmonics( boost::shared_ptr< WValueSetBase > newValueSet,
00062                                 boost::shared_ptr< WGrid > newGrid );
00063 
00064     /**
00065      * Construct an empty and unusable instance. This is needed for the prototype mechanism.
00066      */
00067     WDataSetSphericalHarmonics();
00068 
00069     /**
00070      * Destroys this DataSet instance
00071      */
00072     virtual ~WDataSetSphericalHarmonics();
00073 
00074     /**
00075      * 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
00076      * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
00077      *
00078      * \param newValueSet the new valueset.
00079      *
00080      * \return the clone
00081      */
00082     virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WValueSetBase > newValueSet ) const;
00083 
00084     /**
00085      * 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
00086      * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
00087      *
00088      * \param newGrid the new grid.
00089      *
00090      * \return the clone
00091      */
00092     virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WGrid > newGrid ) const;
00093 
00094     /**
00095      * Creates a copy (clone) of this instance. Unlike copy construction, this is a very useful function if you
00096      * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
00097      *
00098      * \return the clone
00099      */
00100     virtual WDataSetSingle::SPtr clone() const;
00101 
00102     /**
00103      * Returns a prototype instantiated with the true type of the deriving class.
00104      *
00105      * \return the prototype.
00106      */
00107     static boost::shared_ptr< WPrototyped > getPrototype();
00108 
00109     /**
00110      * Interpolates the field of spherical harmonics at the given position
00111      *
00112      * \param pos position to interpolate
00113      * \param success if the position was inside the grid
00114      *
00115      * \return Interpolated spherical harmonic.
00116      */
00117     WSymmetricSphericalHarmonic< double > interpolate( const WPosition &pos, bool *success ) const;
00118 
00119     /**
00120      * Get the spherical harmonic on the given position in value set.
00121      *
00122      * \param index the position where to get the spherical harmonic from
00123      *
00124      * \return the spherical harmonic
00125      */
00126     WSymmetricSphericalHarmonic< double > getSphericalHarmonicAt( size_t index ) const;
00127 
00128     /**
00129      * Gets the name of this prototype.
00130      *
00131      * \return the name.
00132      */
00133     virtual const std::string getName() const;
00134 
00135     /**
00136      * Gets the description for this prototype.
00137      *
00138      * \return the description
00139      */
00140     virtual const std::string getDescription() const;
00141 
00142     /**
00143      * Determines whether this dataset can be used as a texture.
00144      *
00145      * \return true if usable as texture.
00146      */
00147     virtual bool isTexture() const;
00148 
00149 protected:
00150     /**
00151      * The prototype as singleton.
00152      */
00153     static boost::shared_ptr< WPrototyped > m_prototype;
00154 
00155 private:
00156     /**
00157      * The regular 3d grid of the data set.
00158      */
00159     boost::shared_ptr< WGridRegular3D > m_gridRegular3D;
00160 
00161     /**
00162      * The valueset of the data set
00163      */
00164     boost::shared_ptr< WValueSetBase > m_valueSet;
00165 };
00166 
00167 #endif  // WDATASETSPHERICALHARMONICS_H