OpenWalnut  1.4.0
WDataSetDipoles.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 WDATASETDIPOLES_H
00026 #define WDATASETDIPOLES_H
00027 
00028 #include <vector>
00029 
00030 #include <boost/shared_ptr.hpp>
00031 
00032 #include "WDataSet.h"
00033 
00034 /**
00035  * Represents a dipole dataset.
00036  */
00037 class WDataSetDipoles : public WDataSet
00038 {
00039 public:
00040     /**
00041      * Creates a new dipole dataset.
00042      */
00043     WDataSetDipoles();
00044 
00045     /**
00046      * Creates a new dipole data set containing one dipole
00047      * with the given information and checks consistency of the information.
00048      *
00049      * \param dipPos Spatial location of the dipole
00050      * \param mags Magnitudes of dipole over time
00051      * \param times Times for the dipole activity
00052      * \param firstTimeStep First time where the magnitude is not 0
00053      * \param lastTimeStep Last time where the magnitude is not 0
00054      */
00055     explicit WDataSetDipoles( WPosition dipPos, std::vector<float> mags, std::vector<float> times,
00056                               size_t firstTimeStep, size_t lastTimeStep );
00057 
00058     /**
00059      * Destructs this dataset.
00060      */
00061     ~WDataSetDipoles();
00062 
00063     /**
00064      * Returns a prototype instantiated with the true type of the deriving class.
00065      *
00066      * \return the prototype.
00067      */
00068     static boost::shared_ptr< WPrototyped > getPrototype();
00069 
00070     /**
00071      * Adds a new dipole with given information and checks consistency of the information.
00072      *
00073      * \param dipPos Spatial location of the dipole
00074      * \param mags Magnitudes of dipole over time
00075      * \param times Times for the dipole activity
00076      * \param firstTimeStep First time where the magnitude is not 0
00077      * \param lastTimeStep Last time where the magnitude is not 0
00078      *
00079      * \return Id of the added dipole.
00080      */
00081     size_t addDipole( WPosition dipPos, std::vector<float> mags, std::vector<float> times,
00082                       size_t firstTimeStep, size_t lastTimeStep );
00083 
00084     /**
00085      * Return position of dipole.
00086      *
00087      * \param dipoleId Id number of dipole
00088      * \return Position of the dipole.
00089      */
00090     WPosition getPosition( size_t dipoleId = 0 );
00091 
00092     /**
00093      * Return magnitude of dipole for a given time.
00094      *
00095      * \param time The selected time.
00096      * \param dipoleId Id number of dipole
00097      * \return Magnitude of the dipole.
00098      */
00099     float getMagnitude( float time, size_t dipoleId = 0 );
00100 
00101     /**
00102      * Return first time where the magnitude is not 0.
00103      *
00104      * \param dipoleId Id number of dipole
00105      * \return First time where the magnitude is not 0.
00106      */
00107     float getStartTime( size_t dipoleId = 0u ) const;
00108 
00109     /**
00110      * Return last time where the magnitude is not 0.
00111      *
00112      * \param dipoleId Id number of dipole
00113      * \return Last time where the magnitude is not 0.
00114      */
00115     float getEndTime( size_t dipoleId = 0u ) const;
00116 
00117     /**
00118      * Return the times where the magnitude is not 0.
00119      *
00120      * \param dipoleId Id number of dipole
00121      * \return Times where the magnitude is not 0.
00122      */
00123     std::vector<float> getTimes( size_t dipoleId = 0u ) const;
00124 
00125     /**
00126      * Return the magnitudes where the magnitude is not 0.
00127      *
00128      * \param dipoleId Id number of dipole
00129      * \return Magnitudes where the magnitude is not 0.
00130      */
00131     std::vector<float> getMagnitudes( size_t dipoleId = 0u ) const;
00132 
00133     /**
00134      * Return number of dipoles in this dataset
00135      *
00136      * \return number of dipoles in this dataset.
00137      */
00138     size_t getNumberOfDipoles();
00139 
00140     /**
00141      * Return the biggest magnitude of all dipoles.
00142      *
00143      * \return Biggest magnitude of all dipoles.
00144      */
00145     float getMaxMagnitude() const;
00146 
00147 protected:
00148     /**
00149      * The prototype as singleton.
00150      */
00151     static boost::shared_ptr< WPrototyped > m_prototype;
00152 
00153 private:
00154     /**
00155      * Internal class representing one dipole
00156      */
00157     class Dipole
00158     {
00159     public:
00160         WPosition m_dipolePosition; //!< The location of the dipole
00161         std::vector<float> m_magnitudes; //!< The magnitude of the dipole
00162         std::vector<float> m_times; //!< Times for the different magnitudes
00163         size_t m_firstTimeStep; //!< First time where the magnitude is not 0
00164         size_t m_lastTimeStep; //!< Last time where the magnitude is not 0
00165     };
00166 
00167     std::vector< Dipole > m_dipoles; //!< List of dipoles representeing this dipoles dataset
00168     float m_maxMagnitude; //!< Biggest magnitude of all dipoles
00169 };
00170 
00171 #endif  // WDATASETDIPOLES_H