Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
mitkAutoSelectingDICOMReaderService.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 
14 
16 
17 namespace mitk {
18 
20  : BaseDICOMReaderService("MITK DICOM Reader v2 (autoselect)")
21 {
22  this->SetRanking(5);
23  this->RegisterService();
24 }
25 
26 DICOMFileReader::Pointer AutoSelectingDICOMReaderService::GetReader(const mitk::StringList& relevantFiles) const
27 {
28  mitk::DICOMFileReaderSelector::Pointer selector = mitk::DICOMFileReaderSelector::New();
29 
30  selector->LoadBuiltIn3DConfigs();
31  selector->LoadBuiltIn3DnTConfigs();
32  selector->SetInputFiles(relevantFiles);
33 
34  mitk::DICOMFileReader::Pointer reader = selector->GetFirstReaderWithMinimumNumberOfOutputImages();
35  if(reader.IsNotNull())
36  {
37  //reset tag cache to ensure that additional tags of interest
38  //will be regarded by the reader if set later on.
39  reader->SetTagCache(nullptr);
40  }
41 
42  return reader;
43 };
44 
45 AutoSelectingDICOMReaderService* AutoSelectingDICOMReaderService::Clone() const
46 {
47  return new AutoSelectingDICOMReaderService(*this);
48 }
49 
50 }
DataCollection - Class to facilitate loading/accessing structured data.
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
std::vector< std::string > StringList
void SetRanking(int ranking)
Set the service ranking for this file reader.
mitk::DICOMFileReader::Pointer GetReader(const mitk::StringList &relevantFiles) const override