OpenWalnut  1.4.0
WDataSetDipoles.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 WDATASETDIPOLES_H
26 #define WDATASETDIPOLES_H
27 
28 #include <vector>
29 
30 #ifndef Q_MOC_RUN
31 #include <boost/shared_ptr.hpp>
32 #endif
33 
34 #include "WDataSet.h"
35 
36 /**
37  * Represents a dipole dataset.
38  */
39 class WDataSetDipoles : public WDataSet
40 {
41 public:
42  /**
43  * Creates a new dipole dataset.
44  */
46 
47  /**
48  * Creates a new dipole data set containing one dipole
49  * with the given information and checks consistency of the information.
50  *
51  * \param dipPos Spatial location of the dipole
52  * \param mags Magnitudes of dipole over time
53  * \param times Times for the dipole activity
54  * \param firstTimeStep First time where the magnitude is not 0
55  * \param lastTimeStep Last time where the magnitude is not 0
56  */
57  explicit WDataSetDipoles( WPosition dipPos, std::vector<float> mags, std::vector<float> times,
58  size_t firstTimeStep, size_t lastTimeStep );
59 
60  /**
61  * Destructs this dataset.
62  */
64 
65  /**
66  * Returns a prototype instantiated with the true type of the deriving class.
67  *
68  * \return the prototype.
69  */
70  static boost::shared_ptr< WPrototyped > getPrototype();
71 
72  /**
73  * Adds a new dipole with given information and checks consistency of the information.
74  *
75  * \param dipPos Spatial location of the dipole
76  * \param mags Magnitudes of dipole over time
77  * \param times Times for the dipole activity
78  * \param firstTimeStep First time where the magnitude is not 0
79  * \param lastTimeStep Last time where the magnitude is not 0
80  *
81  * \return Id of the added dipole.
82  */
83  size_t addDipole( WPosition dipPos, std::vector<float> mags, std::vector<float> times,
84  size_t firstTimeStep, size_t lastTimeStep );
85 
86  /**
87  * Return position of dipole.
88  *
89  * \param dipoleId Id number of dipole
90  * \return Position of the dipole.
91  */
92  WPosition getPosition( size_t dipoleId = 0 );
93 
94  /**
95  * Return magnitude of dipole for a given time.
96  *
97  * \param time The selected time.
98  * \param dipoleId Id number of dipole
99  * \return Magnitude of the dipole.
100  */
101  float getMagnitude( float time, size_t dipoleId = 0 );
102 
103  /**
104  * Return first time where the magnitude is not 0.
105  *
106  * \param dipoleId Id number of dipole
107  * \return First time where the magnitude is not 0.
108  */
109  float getStartTime( size_t dipoleId = 0u ) const;
110 
111  /**
112  * Return last time where the magnitude is not 0.
113  *
114  * \param dipoleId Id number of dipole
115  * \return Last time where the magnitude is not 0.
116  */
117  float getEndTime( size_t dipoleId = 0u ) const;
118 
119  /**
120  * Return the times where the magnitude is not 0.
121  *
122  * \param dipoleId Id number of dipole
123  * \return Times where the magnitude is not 0.
124  */
125  std::vector<float> getTimes( size_t dipoleId = 0u ) const;
126 
127  /**
128  * Return the magnitudes where the magnitude is not 0.
129  *
130  * \param dipoleId Id number of dipole
131  * \return Magnitudes where the magnitude is not 0.
132  */
133  std::vector<float> getMagnitudes( size_t dipoleId = 0u ) const;
134 
135  /**
136  * Return number of dipoles in this dataset
137  *
138  * \return number of dipoles in this dataset.
139  */
140  size_t getNumberOfDipoles();
141 
142  /**
143  * Return the biggest magnitude of all dipoles.
144  *
145  * \return Biggest magnitude of all dipoles.
146  */
147  float getMaxMagnitude() const;
148 
149 protected:
150  /**
151  * The prototype as singleton.
152  */
153  static boost::shared_ptr< WPrototyped > m_prototype;
154 
155 private:
156  /**
157  * Internal class representing one dipole
158  */
159  class Dipole
160  {
161  public:
162  WPosition m_dipolePosition; //!< The location of the dipole
163  std::vector<float> m_magnitudes; //!< The magnitude of the dipole
164  std::vector<float> m_times; //!< Times for the different magnitudes
165  size_t m_firstTimeStep; //!< First time where the magnitude is not 0
166  size_t m_lastTimeStep; //!< Last time where the magnitude is not 0
167  };
168 
169  std::vector< Dipole > m_dipoles; //!< List of dipoles representeing this dipoles dataset
170  float m_maxMagnitude; //!< Biggest magnitude of all dipoles
171 };
172 
173 #endif // WDATASETDIPOLES_H
float getEndTime(size_t dipoleId=0u) const
Return last time where the magnitude is not 0.
Base class for all data set types.
Definition: WDataSet.h:55
size_t addDipole(WPosition dipPos, std::vector< float > mags, std::vector< float > times, size_t firstTimeStep, size_t lastTimeStep)
Adds a new dipole with given information and checks consistency of the information.
WDataSetDipoles()
Creates a new dipole dataset.
std::vector< Dipole > m_dipoles
List of dipoles representeing this dipoles dataset.
std::vector< float > m_times
Times for the different magnitudes.
std::vector< float > m_magnitudes
The magnitude of the dipole.
float getMagnitude(float time, size_t dipoleId=0)
Return magnitude of dipole for a given time.
WPosition getPosition(size_t dipoleId=0)
Return position of dipole.
This only is a 3d double vector.
size_t getNumberOfDipoles()
Return number of dipoles in this dataset.
float getStartTime(size_t dipoleId=0u) const
Return first time where the magnitude is not 0.
float m_maxMagnitude
Biggest magnitude of all dipoles.
size_t m_firstTimeStep
First time where the magnitude is not 0.
WPosition m_dipolePosition
The location of the dipole.
static boost::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
std::vector< float > getTimes(size_t dipoleId=0u) const
Return the times where the magnitude is not 0.
size_t m_lastTimeStep
Last time where the magnitude is not 0.
~WDataSetDipoles()
Destructs this dataset.
std::vector< float > getMagnitudes(size_t dipoleId=0u) const
Return the magnitudes where the magnitude is not 0.
float getMaxMagnitude() const
Return the biggest magnitude of all dipoles.
Internal class representing one dipole.
Represents a dipole dataset.
static boost::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.