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