Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkVtiFileReader.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkVtiFileReader.h"
18 
19 #include <vtkImageData.h>
20 #include <vtkXMLImageDataReader.h>
21 
22 mitk::VtiFileReader::VtiFileReader() : m_FileName(""), m_FilePrefix(""), m_FilePattern("")
23 {
24 }
25 
27 {
28 }
29 
31 {
32  if (m_FileName != "")
33  {
34  vtkXMLImageDataReader *vtkReader = vtkXMLImageDataReader::New();
35  vtkReader->SetFileName(m_FileName.c_str());
36  vtkReader->Update();
37 
38  if (vtkReader->GetOutput() != nullptr)
39  {
40  mitk::Image::Pointer output = this->GetOutput();
41  output->Initialize(vtkReader->GetOutput());
42  output->SetVolume(vtkReader->GetOutput()->GetScalarPointer());
43  }
44  vtkReader->Delete();
45  }
46 }
47 
49  const std::string /*filePrefix*/,
50  const std::string /*filePattern*/)
51 {
52  // First check the extension
53  if (filename == "")
54  return false;
55 
56  bool extensionFound = false;
57  std::string::size_type VTIPos = filename.rfind(".vti");
58  if ((VTIPos != std::string::npos) && (VTIPos == filename.length() - 4))
59  extensionFound = true;
60 
61  VTIPos = filename.rfind(".VTI");
62  if ((VTIPos != std::string::npos) && (VTIPos == filename.length() - 4))
63  extensionFound = true;
64 
65  if (!extensionFound)
66  return false;
67 
68  return true;
69 }
static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern)
static const std::string filename
virtual void GenerateData() override
A version of GenerateData() specific for image processing filters.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.