OpenWalnut  1.4.0
WDataSetVector.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 WDATASETVECTOR_H
00026 #define WDATASETVECTOR_H
00027 
00028 #include "WDataSetSingle.h"
00029 
00030 
00031 /**
00032  * This data set type contains vectors as values.
00033  * \ingroup dataHandler
00034  */
00035 class WDataSetVector : public WDataSetSingle // NOLINT
00036 {
00037 public:
00038     /**
00039      * shared_ptr abbreviation
00040      */
00041     typedef boost::shared_ptr< WDataSetVector > SPtr;
00042 
00043     /**
00044      * const shared_ptr abbreviation
00045      */
00046     typedef boost::shared_ptr< const WDataSetVector > ConstSPtr;
00047 
00048     /**
00049      * Constructs an instance out of an appropriate value set and a grid.
00050      *
00051      * \param newValueSet the vector value set to use
00052      * \param newGrid the grid which maps world space to the value set
00053      */
00054     WDataSetVector( boost::shared_ptr< WValueSetBase > newValueSet,
00055                     boost::shared_ptr< WGrid > newGrid );
00056 
00057     /**
00058      * Construct an empty and unusable instance. This is needed for the prototype mechanism.
00059      */
00060     WDataSetVector();
00061 
00062     /**
00063      * Destroys this DataSet instance
00064      */
00065     virtual ~WDataSetVector();
00066 
00067     /**
00068      * 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
00069      * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
00070      *
00071      * \param newValueSet the new valueset.
00072      *
00073      * \return the clone
00074      */
00075     virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WValueSetBase > newValueSet ) const;
00076 
00077     /**
00078      * 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
00079      * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
00080      *
00081      * \param newGrid the new grid.
00082      *
00083      * \return the clone
00084      */
00085     virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WGrid > newGrid ) const;
00086 
00087     /**
00088      * Creates a copy (clone) of this instance. Unlike copy construction, this is a very useful function if you
00089      * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
00090      *
00091      * \return the clone
00092      */
00093     virtual WDataSetSingle::SPtr clone() const;
00094 
00095     /**
00096      * Returns a prototype instantiated with the true type of the deriving class.
00097      *
00098      * \return the prototype.
00099      */
00100     static boost::shared_ptr< WPrototyped > getPrototype();
00101 
00102     /**
00103      * Interpolates the vector field at the given position
00104      *
00105      * \param pos position to interpolate
00106      * \param success if the position was inside the grid
00107      *
00108      * \return Vector beeing the interpolate.
00109      */
00110     WVector3d interpolate( const WPosition &pos, bool *success ) const;
00111 
00112     /**
00113      * Interpolates the very same way as \ref interpolate but it assures that all vecs are aligned to point into the same
00114      * half-space.  This is useful for eigenvector fields, where -v, and v both are eigenvectors.
00115      *
00116      * \param pos Position to interpolate a vector for
00117      * \param success return parameter which is true if pos was inside of the grid, false otherwise.
00118      *
00119      * \return The resulting interpolated vector.
00120      */
00121     WVector3d eigenVectorInterpolate( const WPosition &pos, bool *success ) const;
00122 
00123     /**
00124      * Get the vector on the given position in value set.
00125      * \note currently only implmented for WVector3d
00126      *
00127      * \param index the position where to get the vector from
00128      *
00129      * \return the vector
00130      */
00131     WVector3d getVectorAt( size_t index ) const;
00132 
00133     /**
00134      * Determines whether this dataset can be used as a texture.
00135      *
00136      * \return true if usable as texture.
00137      */
00138     virtual bool isTexture() const;
00139 
00140     /**
00141      * Overwrites the isVectorDataSet check.
00142      *
00143      * \return Non empty reference to the dataset if it is a vector dataset, empty if not.
00144      */
00145     boost::shared_ptr< WDataSetVector > isVectorDataSet();
00146 
00147 protected:
00148     /**
00149      * The prototype as singleton.
00150      */
00151     static boost::shared_ptr< WPrototyped > m_prototype;
00152 
00153 private:
00154 };
00155 
00156 inline boost::shared_ptr< WDataSetVector > WDataSetVector::isVectorDataSet()
00157 {
00158     return boost::static_pointer_cast< WDataSetVector >( shared_from_this() );
00159 }
00160 
00161 #endif  // WDATASETVECTOR_H