27 #include "WDataSetDipoles.h"
34 m_maxMagnitude( 0.0f )
39 size_t firstTimeStep,
size_t lastTimeStep ) :
40 m_maxMagnitude( 0.0f )
42 WAssert( mags.size() == times.size(),
"There has to be a magnitude for every time and vice versa." );
43 for(
size_t id = 0;
id < times.size() - 1; ++id )
45 WAssert( times[
id] < times[
id+1],
"Times need to be ascending." );
47 addDipole( dipPos, mags, times, firstTimeStep, lastTimeStep );
65 size_t firstTimeStep,
size_t lastTimeStep )
75 for(
size_t id = 0u;
id < mags.size(); ++id )
88 return m_dipoles[dipoleId].m_dipolePosition;
104 const std::vector<float>::const_iterator& begin = dipole.
m_times.begin();
112 const std::vector<float>::const_iterator& begin = dipole.
m_magnitudes.begin();
129 std::vector<float>& times =
m_dipoles[dipoleId].m_times;
130 std::vector<float>& magnitudes =
m_dipoles[dipoleId].m_magnitudes;
132 if( time < times[0] || time > times.back() )
138 size_t upperBoundId = 1u;
139 for( ; upperBoundId < times.size() - 1u; ++upperBoundId )
141 if( time < times[upperBoundId] )
146 float scale = ( time - times[upperBoundId-1] ) / ( times[upperBoundId] - times[upperBoundId-1] );
147 float magnitude = magnitudes[upperBoundId-1] + scale * ( magnitudes[upperBoundId] - magnitudes[upperBoundId-1] );
float getEndTime(size_t dipoleId=0u) const
Return last time where the magnitude is not 0.
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.
static boost::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.