Medical Imaging Interaction Toolkit  2018.4.99-ef453c4b
Medical Imaging Interaction Toolkit
mitkExtractTimeGrid.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkExtractTimeGrid.h"
14 
16 {
18  if (image)
19  {
20  result = ExtractTimeGrid(image->GetTimeGeometry());
21  }
22  return result;
23 };
24 
26 {
28  if (geometry)
29  {
30  unsigned int i = 0;
31  std::vector<double> tempGrid;
32  while(geometry->IsValidTimeStep(i))
33  {
34  tempGrid.push_back(geometry->TimeStepToTimePoint(i)/1000.0);
35  ++i;
36  }
37 
38  result.SetSize(tempGrid.size());
39 
40  mitk::ModelBase::TimeGridType::iterator destPost = result.begin();
41 
42  for(std::vector<double>::iterator sourcePos = tempGrid.begin(); sourcePos != tempGrid.end(); ++sourcePos, ++destPost)
43  {
44  *destPost = *sourcePos;
45  }
46  }
47 
48  return result;
49 };
itk::Array< double > TimeGridType
Definition: mitkModelBase.h:62
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:61
MITKMODELFIT_EXPORT ModelBase::TimeGridType ExtractTimeGrid(const Image *image)
Image class for storing images.
Definition: mitkImage.h:72
virtual TimePointType TimeStepToTimePoint(TimeStepType timeStep) const =0
Converts a time step to a time point.
mitk::Image::Pointer image
virtual bool IsValidTimeStep(TimeStepType timeStep) const =0
Test for the given time step if a geometry is availible.