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