28 #include "WDataSetDipoles.h"
35 m_maxMagnitude( 0.0f )
40 size_t firstTimeStep,
size_t lastTimeStep ) :
41 m_maxMagnitude( 0.0f )
43 WAssert( mags.size() == times.size(),
"There has to be a magnitude for every time and vice versa." );
44 for(
size_t id = 0;
id < times.size() - 1; ++id )
46 WAssert( times[
id] < times[
id+1],
"Times need to be ascending." );
48 addDipole( dipPos, mags, times, firstTimeStep, lastTimeStep );
66 size_t firstTimeStep,
size_t lastTimeStep )
76 for(
size_t id = 0u;
id < mags.size(); ++id )
89 return m_dipoles[dipoleId].m_dipolePosition;
105 const std::vector<float>::const_iterator& begin = dipole.
m_times.begin();
113 const std::vector<float>::const_iterator& begin = dipole.
m_magnitudes.begin();
130 std::vector<float>& times =
m_dipoles[dipoleId].m_times;
131 std::vector<float>& magnitudes =
m_dipoles[dipoleId].m_magnitudes;
133 if( time < times[0] || time > times.back() )
139 size_t upperBoundId = 1u;
140 for( ; upperBoundId < times.size() - 1u; ++upperBoundId )
142 if( time < times[upperBoundId] )
147 float scale = ( time - times[upperBoundId-1] ) / ( times[upperBoundId] - times[upperBoundId-1] );
148 float magnitude = magnitudes[upperBoundId-1] + scale * ( magnitudes[upperBoundId] - magnitudes[upperBoundId-1] );
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.
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.
This only is a 3d double vector.