29 m_FirstTimePoint = 0.0;
31 m_GeometryVector.resize(1);
36 return static_cast<TimeStepType>(m_GeometryVector.size());
41 return m_FirstTimePoint;
46 TimePointType timePoint = m_FirstTimePoint + m_StepDuration * CountTimeSteps();
47 if (timePoint > std::numeric_limits<TimePointType>().
max())
48 timePoint = std::numeric_limits<TimePointType>().
max();
55 bounds[0] = this->GetMinimumTimePoint();
56 bounds[1] = this->GetMaximumTimePoint();
65 timePoint = m_FirstTimePoint;
69 timePoint = m_FirstTimePoint + m_StepDuration * step;
71 if (timePoint > std::numeric_limits<TimePointType>().
max())
72 timePoint = std::numeric_limits<TimePointType>().
max();
78 TimePointType timePoint = m_FirstTimePoint + m_StepDuration * (step + 1);
79 if (timePoint > std::numeric_limits<TimePointType>().max())
80 timePoint = std::numeric_limits<TimePointType>().max();
87 bounds[0] = this->GetMinimumTimePoint(step);
88 bounds[1] = this->GetMaximumTimePoint(step);
94 return this->GetMinimumTimePoint() <= timePoint && timePoint < this->GetMaximumTimePoint();
99 return timeStep < this->CountTimeSteps();
104 if (m_FirstTimePoint <= itk::NumericTraits<TimePointType>::NonpositiveMin() ||
112 return m_FirstTimePoint + timeStep * m_StepDuration;
117 if (m_FirstTimePoint <= timePoint)
118 return static_cast<TimeStepType>((timePoint - m_FirstTimePoint) / m_StepDuration);
125 if (IsValidTimeStep(timeStep))
127 return dynamic_cast<BaseGeometry *
>(m_GeometryVector[timeStep].GetPointer());
137 if (this->IsValidTimePoint(timePoint))
139 TimeStepType timeStep = this->TimePointToTimeStep(timePoint);
140 return this->GetGeometryForTimeStep(timeStep);
150 if (timeStep >= m_GeometryVector.size())
152 return m_GeometryVector[timeStep]->Clone();
158 isValid &= m_GeometryVector.size() > 0;
159 isValid &= m_StepDuration > 0;
165 m_GeometryVector.clear();
170 m_GeometryVector.reserve(numberOfGeometries);
175 m_GeometryVector.reserve(size);
176 if (m_GeometryVector.size() == 0)
178 while (m_GeometryVector.size() < size)
181 m_GeometryVector.push_back(dynamic_cast<BaseGeometry *>(geo3D.GetPointer()));
186 while (m_GeometryVector.size() < size)
189 m_GeometryVector.push_back(clone);
196 assert(timeStep <= m_GeometryVector.size());
198 if (timeStep == m_GeometryVector.size())
199 m_GeometryVector.push_back(geometry);
201 m_GeometryVector[timeStep] = geometry;
208 newTimeGeometry->m_FirstTimePoint = this->m_FirstTimePoint;
209 newTimeGeometry->m_StepDuration = this->m_StepDuration;
210 newTimeGeometry->m_GeometryVector.clear();
211 newTimeGeometry->Expand(this->CountTimeSteps());
215 newTimeGeometry->SetTimeStepGeometry(tempGeometry, i);
222 for (
TimeStepType currentStep = 0; currentStep < this->CountTimeSteps(); ++currentStep)
225 this->SetTimeStepGeometry(clonedGeometry.GetPointer(), currentStep);
231 timeSteps = (timeSteps > 0) ? timeSteps : 1;
232 m_FirstTimePoint = 0.0;
233 m_StepDuration = 1.0;
237 m_StepDuration = std::numeric_limits<mitk::TimePointType>().infinity();
240 this->ReserveSpaceForGeometries(timeSteps);
243 for (
TimeStepType currentStep = 0; currentStep < timeSteps; ++currentStep)
246 this->SetTimeStepGeometry(clonedGeometry, currentStep);
251 MITK_INFO <<
"Cloning of geometry produced an error!";
260 geometry->Initialize();
262 this->Initialize(geometry.GetPointer(), timeSteps);
267 os << indent <<
" TimeSteps: " << this->CountTimeSteps() << std::endl;
268 os << indent <<
" FirstTimePoint: " << this->GetFirstTimePoint() << std::endl;
269 os << indent <<
" StepDuration: " << this->GetStepDuration() <<
" ms" << std::endl;
270 os << indent <<
" Time Bounds: " << this->GetTimeBounds()[0] <<
" - " << this->GetTimeBounds()[1] << std::endl;
273 os << indent <<
" GetGeometryForTimeStep(0): ";
274 if (GetGeometryForTimeStep(0).IsNull())
275 os <<
"NULL" << std::endl;
277 GetGeometryForTimeStep(0)->Print(os, indent);
286 static_cast<const TimeGeometry &>(leftHandSide), static_cast<const TimeGeometry &>(rightHandSide), eps, verbose);
virtual TimeStepType CountTimeSteps() const override
Returns the number of time steps.
virtual ~ProportionalTimeGeometry()
itk::SmartPointer< Self > Pointer
itk::FixedArray< ScalarType, 2 > TimeBounds
Standard typedef for time-bounds.
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const override
virtual BaseGeometry::Pointer GetGeometryForTimeStep(TimeStepType timeStep) const override
Returns the geometry which corresponds to the given time step.
ProportionalTimeGeometry()
virtual TimePointType GetMaximumTimePoint() const override
Returns the last time point for which the object is valid.
static void Update(vtkPolyData *)
void ClearAllGeometries()
virtual BaseGeometry::Pointer GetGeometryCloneForTimeStep(TimeStepType timeStep) const override
Returns the geometry which corresponds to the given time step.
void ReserveSpaceForGeometries(TimeStepType numberOfGeometries)
virtual itk::LightObject::Pointer InternalClone() const override
Makes a deep copy of the current object.
virtual BaseGeometry::Pointer GetGeometryForTimePoint(TimePointType timePoint) const override
Returns the geometry which corresponds to the given time point.
virtual void ReplaceTimeStepGeometries(const BaseGeometry *geometry) override
Replaces the geometry instances with clones of the passed geometry.
virtual bool IsValidTimeStep(TimeStepType timeStep) const override
Test for the given time step if a geometry is availible.
virtual TimeBounds GetTimeBounds() const override
Get the time bounds (in ms)
static void clone(T *&dst, S *src, int n)
virtual void Expand(TimeStepType size) override
Expands the time geometry to the given number of time steps.
virtual void SetTimeStepGeometry(BaseGeometry *geometry, TimeStepType timeStep) override
Sets the geometry for the given time step.
virtual bool IsValidTimePoint(TimePointType timePoint) const override
Tests if a given time point is covered by this object.
virtual TimePointType GetMinimumTimePoint() const override
Returns the first time point for which the object is valid.
mitk::ScalarType TimePointType
std::vcl_size_t TimeStepType
virtual bool IsValid() const override
Tests if all necessary informations are set and the object is valid.
virtual TimePointType TimeStepToTimePoint(TimeStepType timeStep) const override
Converts a time step to a time point.
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
MITKCORE_EXPORT const ScalarType eps
virtual TimeStepType TimePointToTimeStep(TimePointType timePoint) const override
Converts a time point to the corresponding time step.
virtual void Initialize() override
Initilizes a new object with one time steps which contains an empty geometry.
BaseGeometry Describes the geometry of a data object.