Medical Imaging Interaction Toolkit  2018.4.99-1640525a
Medical Imaging Interaction Toolkit
mitkDummyLsetReader.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 #include <mitkDummyLsetReader.h>
13 #include <itksys/SystemTools.hxx>
14 #include <itkImageFileReader.h>
15 #include <itkNrrdImageIO.h>
16 #include <mitkImageCast.h>
17 #include <mitkCustomMimeType.h>
18 
19 typedef itk::Image<unsigned char, 3> ImageType;
20 
21 std::vector<itk::SmartPointer<mitk::BaseData> > mitk::DummyLsetFileReader::DoRead()
22 {
23 
24  std::vector<itk::SmartPointer<mitk::BaseData> > result;
25  typedef itk::ImageFileReader<ImageType> FileReaderType;
26  FileReaderType::Pointer reader = FileReaderType::New();
27  reader->SetFileName(this->GetInputLocation());
28  itk::NrrdImageIO::Pointer io = itk::NrrdImageIO::New();
29  reader->SetImageIO(io);
30  reader->Update();
31 
33  mitk::CastToMitkImage(reader->GetOutput(),img);
34  result.push_back(img.GetPointer());
35 
36  return result;
37 }
38 
39 
41  : AbstractFileReader(other)
42 {
43 }
44 
45 
46 mitk::DummyLsetFileReader* mitk::DummyLsetFileReader::Clone() const
47 {
48  return new DummyLsetFileReader(*this);
49 }
50 
51 
53 {}
54 
55 
57 {
58  CustomMimeType mimeType(this->GetMimeTypePrefix() + "lset");
59  mimeType.AddExtension("lset");
60  mimeType.SetCategory("Images");
61  mimeType.SetComment("Experimental MBI LabelSetImage");
62  this->SetMimeType(mimeType);
63  this->SetDescription("MBI LabelSetImage");
64  this->RegisterService();
65 }
66 
itk::Image< unsigned char, 3 > ImageType
void SetComment(const std::string &comment)
void SetMimeType(const CustomMimeType &mimeType)
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
std::vector< itk::SmartPointer< BaseData > > DoRead() override
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
void SetDescription(const std::string &description)
void AddExtension(const std::string &extension)
void SetCategory(const std::string &category)
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
Definition: mitkImageCast.h:74
Base class for creating mitk::BaseData objects from files or streams.
std::string GetInputLocation() const override
Get the current input location.
std::string GetMimeTypePrefix() const