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