diff --git a/Modules/Core/include/mitkChannelDescriptor.h b/Modules/Core/include/mitkChannelDescriptor.h index 0480b64b60..b18ffdf3b3 100644 --- a/Modules/Core/include/mitkChannelDescriptor.h +++ b/Modules/Core/include/mitkChannelDescriptor.h @@ -1,78 +1,76 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef MITKCHANNELDESCRIPTOR_H #define MITKCHANNELDESCRIPTOR_H -#include "mitkPixelType.h" +#include #include namespace mitk { /** \brief An object which holds all essential information about a single channel of an Image. The channel descriptor is designed to be used only as a part of the ImageDescriptor. A consequence to this is that the ChannelDescriptor does not hold the geometry information, only the PixelType. The pixel type is the single information that can differ among an image with multiple channels. */ class MITKCORE_EXPORT ChannelDescriptor { public: ChannelDescriptor(mitk::PixelType type, size_t numOfElements, bool allocate = false); ~ChannelDescriptor(); /** \brief Get the type of channel's elements */ PixelType GetPixelType() const { return m_PixelType; } /** \brief Get the size in bytes of the channel */ size_t GetSize() const { return m_Size; } /** \brief Get the pointer to the actual data of the channel \warning Such access to the image's data is not safe and will be replaced \todo new memory management design */ unsigned char *GetData() const { return m_Data; } protected: friend class Image; friend class ImageAccessorBase; void SetData(void *dataPtr) { if (dataPtr == nullptr) { m_Data = (unsigned char *)dataPtr; } } - void AllocateData(); - /** Name of the channel */ std::string m_Name; /** The type of each element of the channel \sa PixelType */ PixelType m_PixelType; /** Size of the channel in bytes */ size_t m_Size; /** Pointer to the data of the channel \warning Not safe \todo Replace in new memory management design */ unsigned char *m_Data; }; } // end namespace mitk #endif // MITKCHANNELDESCRIPTOR_H diff --git a/Modules/Core/src/DataManagement/mitkChannelDescriptor.cpp b/Modules/Core/src/DataManagement/mitkChannelDescriptor.cpp index 49ec3e82ff..9b7199b15b 100644 --- a/Modules/Core/src/DataManagement/mitkChannelDescriptor.cpp +++ b/Modules/Core/src/DataManagement/mitkChannelDescriptor.cpp @@ -1,56 +1,22 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ -#include "mitkChannelDescriptor.h" -#include "mitkMemoryUtilities.h" + +#include mitk::ChannelDescriptor::ChannelDescriptor(mitk::PixelType type, size_t numOfElements, bool /*allocate*/) : m_PixelType(type), m_Size(numOfElements), m_Data(nullptr) { - // MITK_INFO << "Entering ChannelDescriptor constructor."; } mitk::ChannelDescriptor::~ChannelDescriptor() { - // TODO: The following line should be correct but leads to an error. - // Solution might be: Hold PixelType on stack, return copy and implement - // copy constructor as well as assignment operator. - // delete m_PixelType; -} - -/* -void mitk::ChannelDescriptor::Initialize(mitk::PixelType &type, size_t numOfElements, bool allocate) -{ - if( m_PixelType.GetPixelTypeId() != type.GetPixelTypeId() ) - { - MITK_WARN << "Changing pixel type for channel: " << - m_PixelType.GetItkTypeAsString() << " -> " << - type.GetItkTypeAsString(); - } - - m_PixelType = type; - - m_Size = numOfElements * m_PixelType.GetSize(); - - if( allocate ) - { - this->AllocateData(); - } -} -*/ - -void mitk::ChannelDescriptor::AllocateData() -{ - if (m_Data == nullptr) - { - m_Data = mitk::MemoryUtilities::AllocateElements(m_Size); - } }