Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
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 (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 <mitkToFImageWriter.h>
13 #include <mitkCommon.h>
14 
15 // itk includes
16 #include "itksys/SystemTools.hxx"
17 
18 namespace mitk
19 {
20  ToFImageWriter::ToFImageWriter():m_Extension(".nrrd"),
21  m_DistanceImageFileName(), m_AmplitudeImageFileName(), m_IntensityImageFileName(), m_RGBImageFileName(),
22  m_NumOfFrames(0), m_DistanceImageSelected(true), m_AmplitudeImageSelected(false),
23  m_IntensityImageSelected(false), m_RGBImageSelected(false), m_ToFCaptureWidth(200),m_ToFCaptureHeight(200),
24  m_RGBCaptureWidth(200),m_RGBCaptureHeight(200),
25  m_ToFPixelNumber(0), m_ToFImageSizeInBytes(0),
26  m_RGBPixelNumber(0), m_RGBImageSizeInBytes(0),
27  m_ToFImageType(ToFImageWriter::ToFImageType3D)
28  {
29  }
30 
32  {
33  }
34 
35  void ToFImageWriter::CheckForFileExtension(std::string& fileName)
36  {
37  std::string baseFilename = itksys::SystemTools::GetFilenameWithoutLastExtension( fileName );
38  std::string extension = itksys::SystemTools::GetFilenameLastExtension( fileName );
39 
40  if( extension.length() != 0 && extension != this->m_Extension)
41  {
42  MITK_ERROR << "Wrong file extension for " << baseFilename <<
43  " The default extension is " << this->m_Extension.c_str() <<
44  ", currently the requested file extension is " <<
45  extension.c_str() <<"!";
46  this->m_Extension = extension;
47  }
48 
49  size_t found = fileName.find( this->m_Extension ); // !!! HAS to be at the very end of the filename (not somewhere in the middle)
50  if( found == std::string::npos)
51  {
52  fileName.append(this->m_Extension);
53  }
54  }
55 
57  {
58  return this->m_ToFImageType;
59  }
60 
62  {
63  this->m_ToFImageType = toFImageType;
64  }
65 
66 } // 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:20
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)