Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkToFImageWriter.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 #include <mitkToFImageWriter.h>
17 #include <mitkCommon.h>
18 
19 // itk includes
20 #include "itksys/SystemTools.hxx"
21 
22 namespace mitk
23 {
24  ToFImageWriter::ToFImageWriter():m_Extension(".nrrd"),
25  m_DistanceImageFileName(), m_AmplitudeImageFileName(), m_IntensityImageFileName(), m_RGBImageFileName(),
26  m_NumOfFrames(0), m_DistanceImageSelected(true), m_AmplitudeImageSelected(false),
27  m_IntensityImageSelected(false), m_RGBImageSelected(false), m_ToFCaptureWidth(200),m_ToFCaptureHeight(200),
28  m_RGBCaptureWidth(200),m_RGBCaptureHeight(200),
29  m_ToFPixelNumber(0), m_ToFImageSizeInBytes(0),
30  m_RGBPixelNumber(0), m_RGBImageSizeInBytes(0),
31  m_ToFImageType(ToFImageWriter::ToFImageType3D)
32  {
33  }
34 
36  {
37  }
38 
39  void ToFImageWriter::CheckForFileExtension(std::string& fileName)
40  {
41  std::string baseFilename = itksys::SystemTools::GetFilenameWithoutLastExtension( fileName );
42  std::string extension = itksys::SystemTools::GetFilenameLastExtension( fileName );
43 
44  if( extension.length() != 0 && extension != this->m_Extension)
45  {
46  MITK_ERROR << "Wrong file extension for " << baseFilename <<
47  " The default extension is " << this->m_Extension.c_str() <<
48  ", currently the requested file extension is " <<
49  extension.c_str() <<"!";
50  this->m_Extension = extension;
51  }
52 
53  size_t found = fileName.find( this->m_Extension ); // !!! HAS to be at the very end of the filename (not somewhere in the middle)
54  if( found == std::string::npos)
55  {
56  fileName.append(this->m_Extension);
57  }
58  }
59 
61  {
62  return this->m_ToFImageType;
63  }
64 
66  {
67  this->m_ToFImageType = toFImageType;
68  }
69 
70 } // end namespace mitk
void CheckForFileExtension(std::string &fileName)
Checks file name if file extension exists. If not an error message is returned.
#define MITK_ERROR
Definition: mitkLogMacros.h:24
void SetToFImageType(ToFImageWriter::ToFImageType toFImageType)
Set the type of image to be written.
DataCollection - Class to facilitate loading/accessing structured data.
std::string m_Extension
file extension used for saving images
Writer class for ToF images.
ToFImageWriter::ToFImageType GetToFImageType()
Get the type of image to be written.
ToFImageWriter::ToFImageType m_ToFImageType
type of image to be recorded: ToFImageType3D (0) or ToFImageType2DPlusT (1)