Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkChannelDescriptor.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 "mitkChannelDescriptor.h"
17 #include "mitkMemoryUtilities.h"
18 
19 mitk::ChannelDescriptor::ChannelDescriptor(mitk::PixelType type, size_t numOfElements, bool /*allocate*/)
20  : m_PixelType(type), m_Size(numOfElements), m_Data(nullptr)
21 {
22  // MITK_INFO << "Entering ChannelDescriptor constructor.";
23 }
24 
26 {
27  // TODO: The following line should be correct but leads to an error.
28  // Solution might be: Hold PixelType on stack, return copy and implement
29  // copy constructor as well as assignment operator.
30  // delete m_PixelType;
31 }
32 
33 /*
34 void mitk::ChannelDescriptor::Initialize(mitk::PixelType &type, size_t numOfElements, bool allocate)
35 {
36  if( m_PixelType.GetPixelTypeId() != type.GetPixelTypeId() )
37  {
38  MITK_WARN << "Changing pixel type for channel: " <<
39  m_PixelType.GetItkTypeAsString() << " -> " <<
40  type.GetItkTypeAsString();
41  }
42 
43  m_PixelType = type;
44 
45  m_Size = numOfElements * m_PixelType.GetSize();
46 
47  if( allocate )
48  {
49  this->AllocateData();
50  }
51 }
52 */
53 
55 {
56  if (m_Data == nullptr)
57  {
58  m_Data = mitk::MemoryUtilities::AllocateElements<unsigned char>(m_Size);
59  }
60 }
ChannelDescriptor(mitk::PixelType type, vcl_size_t numOfElements, bool allocate=false)
Class for defining the data type of pixels.
Definition: mitkPixelType.h:55