Commit dbe4f8e5 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Further work on new image representation conversion API:

Removed all code fragments in core code that was ITK specific (conversion from/to GenericImageRepresentationItk). The functionality was replaced by the new conversion functors in imagerepresentationconversionitk.h and imagerepresentationconversionitk.cpp.

refs #553
refs #474
parent d2f44909
......@@ -43,6 +43,7 @@
#include "core/datastructures/facegeometry.h"
#include "core/datastructures/geometrydata.h"
#include "core/datastructures/imagerepresentationgl.h"
#include "core/datastructures/imagerepresentationlocal.h"
#include "core/datastructures/renderdata.h"
#ifdef CAMPVIS_HAS_MODULE_COLUMBIA
......
......@@ -25,7 +25,6 @@
#ifndef GENERICIMAGEREPRESENTATIONLOCAL_H__
#define GENERICIMAGEREPRESENTATIONLOCAL_H__
#include "core/datastructures/imagerepresentationdisk.h"
#include "core/datastructures/imagerepresentationlocal.h"
#include "core/tools/typetraits.h"
......
......@@ -24,12 +24,6 @@
#include "imagedata.h"
#include "core/datastructures/imagerepresentationlocal.h"
#ifdef CAMPVIS_HAS_MODULE_ITK
#include "modules/itk/core/genericimagerepresentationitk.h"
#endif
namespace campvis {
const std::string ImageData::loggerCat_ = "CAMPVis.core.datastructures.ImageData";
......@@ -136,36 +130,4 @@ namespace campvis {
addRepresentation(representation);
}
template<>
const ImageRepresentationLocal* ImageData::getRepresentation<ImageRepresentationLocal>(bool performConversion /*= true*/) const {
// look, whether we already have a suitable representation
for (tbb::concurrent_vector<const AbstractImageRepresentation*>::const_iterator it = _representations.begin(); it != _representations.end(); ++it) {
if (const ImageRepresentationLocal* tester = dynamic_cast<const ImageRepresentationLocal*>(*it))
return tester;
}
if (performConversion) {
return tryPerformConversion<ImageRepresentationLocal>();
}
return 0;
}
#ifdef CAMPVIS_HAS_MODULE_ITK
template<>
const AbstractImageRepresentationItk* ImageData::getRepresentation<AbstractImageRepresentationItk>(bool performConversion /*= true*/) const {
// look, whether we already have a suitable representation
for (tbb::concurrent_vector<const AbstractImageRepresentation*>::const_iterator it = _representations.begin(); it != _representations.end(); ++it) {
if (const AbstractImageRepresentationItk* tester = dynamic_cast<const AbstractImageRepresentationItk*>(*it))
return tester;
}
if (performConversion) {
tgtAssert(false, "Conversion to AbstractImageRepresentationItk not implemented - is it really needed?");
LWARNING("Could not convert to AbstractImageRepresentationItk");
}
return 0;
}
#endif
}
\ No newline at end of file
......@@ -35,18 +35,14 @@
#include "core/datastructures/imagemappinginformation.h"
#include "core/datastructures/imagerepresentationconverter.h"
#include <vector>
namespace campvis {
class ImageRepresentationLocal;
/**
* Stores basic information about one (semantic) image of arbitrary dimension.
* Different representations (e.g. local memory, OpenGL texture) are
* to be defined by inheritance.
*
* \todo
*/
class CAMPVIS_CORE_API ImageData : public AbstractData, public IHasWorldBounds {
// friend so that it can add itself as representation
......@@ -209,8 +205,8 @@ namespace campvis {
const T* campvis::ImageData::getRepresentation(bool performConversion) const {
// look, whether we already have a suitable representation
for (tbb::concurrent_vector<const AbstractImageRepresentation*>::const_iterator it = _representations.begin(); it != _representations.end(); ++it) {
if (typeid(T) == typeid(**it)) {
return static_cast<const T*>(*it);
if (const T* tester = dynamic_cast<const T*>(*it)) {
return tester;
}
}
......@@ -222,16 +218,6 @@ namespace campvis {
return 0;
}
template<>
CAMPVIS_CORE_API const campvis::ImageRepresentationLocal* campvis::ImageData::getRepresentation<ImageRepresentationLocal>(bool performConversion) const;
#ifdef CAMPVIS_HAS_MODULE_ITK
class AbstractImageRepresentationItk;
template<>
CAMPVIS_CORE_API const campvis::AbstractImageRepresentationItk* campvis::ImageData::getRepresentation<AbstractImageRepresentationItk>(bool performConversion) const;
#endif
template<typename T>
const T* campvis::ImageData::tryPerformConversion() const {
// TODO: Currently, we do not check, for multiple parallel conversions into the same
......
......@@ -82,12 +82,6 @@ namespace conversion {
ImageRepresentationGL* toReturn = ImageRepresentationGL::create(const_cast<ImageData*>(tester->getParent()), tester->getWeaklyTypedPointer());
return toReturn;
}
#ifdef CAMPVIS_HAS_MODULE_ITK
else if (const AbstractImageRepresentationItk* tester = dynamic_cast<const AbstractImageRepresentationItk*>(source)) {
ImageRepresentationGL* toReturn = ImageRepresentationGL::create(const_cast<ImageData*>(tester->getParent()), tester->getWeaklyTypedPointer());
return toReturn;
}
#endif
return nullptr;
}
......@@ -110,55 +104,7 @@ namespace conversion {
return nullptr;
}
#ifdef CAMPVIS_HAS_MODULE_ITK
// There is no way to determine basetype, number of channels and dimensionality of
// an ITK image at runtime. So there are currently 7*4*2 = 56 different possibilities
// what source could be. Thank god, there exists macro magic to create the 56
// different templated conversion codes.
#define CONVERT_ITK_TO_GENERIC_LOCAL(basetype, numchannels, dimensionality) \
if (const GenericImageRepresentationItk<basetype, numchannels, dimensionality>* tester = dynamic_cast< const GenericImageRepresentationItk<basetype, numchannels, dimensionality>* >(source)) { \
typedef GenericImageRepresentationItk<basetype, numchannels, dimensionality>::ItkImageType ItkImageType; \
typedef ItkImageType::PixelType ItkElementType; \
typedef GenericImageRepresentationItk<basetype, numchannels, dimensionality>::ElementType ElementType; \
const ItkElementType* pixelData = tester->getItkImage()->GetBufferPointer(); \
\
ItkImageType::RegionType region; \
region = tester->getItkImage()->GetBufferedRegion(); \
\
ItkImageType::SizeType s = region.GetSize(); \
tgt::svec3 size(s[0], 1, 1); \
if (dimensionality >= 2) \
size.y = s[1]; \
if (dimensionality == 3) \
size.z = s[2]; \
\
ElementType* pixelDataCopy = new ElementType[tgt::hmul(size)]; \
memcpy(pixelDataCopy, pixelData, tgt::hmul(size) * TypeTraits<basetype, numchannels>::elementSize); \
return GenericImageRepresentationLocal<basetype, numchannels>::create(const_cast<ImageData*>(source->getParent()), pixelDataCopy); \
}
#define DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_ND(numchannels, dimensionality) \
CONVERT_ITK_TO_GENERIC_LOCAL(uint8_t, numchannels, dimensionality) \
else CONVERT_ITK_TO_GENERIC_LOCAL(int8_t, numchannels, dimensionality) \
else CONVERT_ITK_TO_GENERIC_LOCAL(uint16_t, numchannels, dimensionality) \
else CONVERT_ITK_TO_GENERIC_LOCAL(int16_t, numchannels, dimensionality) \
else CONVERT_ITK_TO_GENERIC_LOCAL(uint32_t, numchannels, dimensionality) \
else CONVERT_ITK_TO_GENERIC_LOCAL(int32_t, numchannels, dimensionality) \
else CONVERT_ITK_TO_GENERIC_LOCAL(float, numchannels, dimensionality)
#define DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_D(dimensionality) \
DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_ND(1, dimensionality) \
else DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_ND(2, dimensionality) \
else DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_ND(3, dimensionality) \
else DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_ND(4, dimensionality)
// okay we've defined our macros. Now we just need to call them so that they call
// each other and create 56 different conversion checks - hooray
DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_D(2)
else DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_D(3)
#endif
return 0;
return nullptr;
}
}
......
......@@ -30,11 +30,6 @@
#include "tgt/tgt_gl.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagerepresentationdisk.h"
#include "core/datastructures/imagerepresentationlocal.h"
#ifdef CAMPVIS_HAS_MODULE_ITK
#include "modules/itk/core/genericimagerepresentationitk.h"
#endif
namespace campvis {
......
......@@ -29,9 +29,10 @@
#include "tgt/texture.h"
#include "core/datastructures/genericabstractimagerepresentation.h"
#include "core/datastructures/genericimagerepresentationlocal.h"
#include "core/tools/weaklytypedpointer.h"
#include <string>
namespace tgt {
class Shader;
class TextureUnit;
......@@ -163,16 +164,6 @@ namespace campvis {
*/
ImageRepresentationGL(ImageData* parent, const WeaklyTypedPointer& wtp);
/**
* Creates a new ImageRepresentationGL representation from GenericImageRepresentationLocal.
*
* \param parent Image this representation represents, must not be 0.
* \param data Pointer to the GenericImageRepresentationLocal instance, must not be 0
* \tparam BASETYPE Base type of image data
* \tparam NUMCHANNELS Number of channels per element
*/
template<typename BASETYPE, size_t NUMCHANNELS>
ImageRepresentationGL(ImageData* parent, const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* data);
/**
* Binds the texture without activating a texture unit.
......@@ -193,45 +184,11 @@ namespace campvis {
void setupAndUploadTexture(tgt::Texture* texture, bool isInteger, bool isSigned);
/**
* Creates the OpenGL texture from the given GenericImageRepresentationLocal \a data.
* \param data Pointer to the GenericImageRepresentationLocal instance, must not be 0
* \tparam BASETYPE Base type of image data
* \tparam NUMCHANNELS Number of channels per element
*/
template<typename BASETYPE, size_t NUMCHANNELS>
void createTexture(const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* data);
tgt::Texture* _texture; //< OpenGL texture
static const std::string loggerCat_;
};
// = Template definition ==========================================================================
template<typename BASETYPE, size_t NUMCHANNELS>
campvis::ImageRepresentationGL::ImageRepresentationGL(ImageData* parent, const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* data)
: AbstractImageRepresentation(parent)
{
createTexture<BASETYPE, NUMCHANNELS>(data);
}
template<typename BASETYPE, size_t NUMCHANNELS>
void campvis::ImageRepresentationGL::createTexture(const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* data) {
tgtAssert(data != 0, "Pointer to image must not be 0!");
_texture = new tgt::Texture(
reinterpret_cast<GLubyte*>(data->getImageData()),
this->getSize(),
TypeTraits<BASETYPE, NUMCHANNELS>::glFormat,
TypeTraits<BASETYPE, NUMCHANNELS>::glInternalFormat,
TypeTraits<BASETYPE, NUMCHANNELS>::glDataType,
tgt::Texture::LINEAR);
setupAndUploadTexture(_texture, TypeTraitsHelperPerBasetype<BASETYPE>::isInteger, TypeTraitsHelperPerBasetype<BASETYPE>::isSigned);
}
}
#endif // IMAGEREPRESENTATIONGL_H__
......@@ -24,18 +24,10 @@
#include "imagerepresentationlocal.h"
#include "tgt/glcontextmanager.h"
#include <tbb/tbb.h>
#include <tbb/spin_mutex.h>
#include "core/datastructures/imagerepresentationdisk.h"
#include "core/datastructures/imagerepresentationgl.h"
#include "core/datastructures/genericimagerepresentationlocal.h"
#include "core/tools/opengljobprocessor.h"
#include "core/tools/job.h"
#ifdef CAMPVIS_HAS_MODULE_ITK
#include "modules/itk/core/genericimagerepresentationitk.h"
#endif
#include "core/datastructures/genericimagerepresentationlocal.h"
#include <limits>
......
......@@ -25,6 +25,8 @@
#ifndef IMAGEREPRESENTATIONLOCAL_H__
#define IMAGEREPRESENTATIONLOCAL_H__
#include "tgt/vector.h"
#include "core/datastructures/genericabstractimagerepresentation.h"
#include "core/tools/concurrenthistogram.h"
#include "core/tools/endianhelper.h"
......@@ -32,7 +34,6 @@
#include "core/tools/weaklytypedpointer.h"
namespace campvis {
class ImageRepresentationDisk;
/**
* Abstract base class for storing image data in the local memory.
......
......@@ -25,7 +25,6 @@
#ifndef JOB_H__
#define JOB_H__
#include "sigslot/sigslot.h"
#include "tgt/assert.h"
#include "core/coreapi.h"
......
......@@ -26,8 +26,6 @@
#define GENERICIMAGEREPRESENTATIONITK_H__
#include "core/datastructures/abstractimagerepresentation.h"
#include "core/datastructures/genericimagerepresentationlocal.h"
#include "core/tools/typetraits.h"
#include "core/tools/weaklytypedpointer.h"
#include "modules/itk/core/itktypetraits.h"
......@@ -183,15 +181,6 @@ namespace campvis {
virtual ~GenericImageRepresentationItk();
/**
* Performs a conversion of \a source to an GenericImageRepresentationItk<...> if feasible.
* Returns 0 if conversion was not successful or source representation type is not compatible.
* \note The caller has to take ownership of the returned pointer if not 0.
* \param source Source image representation for conversion.
* \return A pointer to a local representation of \a source or 0 on failure. The caller has to take ownership.
*/
static ThisType* tryConvertFrom(const AbstractImageRepresentation* source);
/// \see AbstractImageRepresentation::clone()
virtual ThisType* clone(ImageData* newParent) const;
......@@ -260,52 +249,6 @@ namespace campvis {
}
template<typename BASETYPE, size_t NUMCHANNELS, size_t DIMENSIONALITY>
GenericImageRepresentationItk<BASETYPE, NUMCHANNELS, DIMENSIONALITY>* campvis::GenericImageRepresentationItk<BASETYPE, NUMCHANNELS, DIMENSIONALITY>::tryConvertFrom(const AbstractImageRepresentation* source) {
if (source == 0)
return 0;
if (source->getDimensionality() != DIMENSIONALITY) {
LWARNINGC("campvis.modules.itk.core.GenericImageRepresentationItk<>::tryConvertFrom", "Dimensionality does not match");
return 0;
}
if (const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* tester = dynamic_cast< const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* >(source)) {
typename itk::ImportImageFilter<ItkElementType, DIMENSIONALITY>::Pointer importer = itk::ImportImageFilter<ItkElementType, DIMENSIONALITY>::New();
typename ItkImageType::SizeType size;
size[0] = tester->getSize().x;
if (DIMENSIONALITY >= 2)
size[1] = tester->getSize().y;
if (DIMENSIONALITY >= 3)
size[2] = tester->getSize().z;
typename ItkImageType::IndexType start;
start.Fill(0);
typename ItkImageType::RegionType region;
region.SetSize(size);
region.SetIndex(start);
importer->SetRegion(region);
importer->SetSpacing(tester->getParent()->getMappingInformation().getVoxelSize().elem);
importer->SetOrigin(tester->getParent()->getMappingInformation().getOffset().elem);
typedef typename ItkImageType::PixelType PixelType;
const PixelType* pixelData = reinterpret_cast<const PixelType*>(tester->getImageData());
importer->SetImportPointer(const_cast<PixelType*>(pixelData), tester->getNumElements(), false);
importer->Update();
typename ItkImageType::Pointer itkImage = importer->GetOutput();
if (itkImage.IsNotNull())
return ThisType::create(const_cast<ImageData*>(tester->getParent()), itkImage); // const_cast perfectly valid here
else
return 0;
}
return 0;
}
template<typename BASETYPE, size_t NUMCHANNELS, size_t DIMENSIONALITY>
GenericImageRepresentationItk<BASETYPE, NUMCHANNELS, DIMENSIONALITY>* campvis::GenericImageRepresentationItk<BASETYPE, NUMCHANNELS, DIMENSIONALITY>::clone(ImageData* newParent) const {
typename ItkImageType::Pointer newItkImage = _itkImage->Clone();
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "imagerepresentationconversionitk.h"
#include "tgt/assert.h"
#include "tgt/logmanager.h"
#include "core/tools/opengljobprocessor.h"
namespace campvis {
namespace conversion {
ImageRepresentationGL* GlFromItkConversion::tryConvertFrom(const AbstractImageRepresentation* source) {
if (source == nullptr)
return nullptr;
if (const AbstractImageRepresentationItk* tester = dynamic_cast<const AbstractImageRepresentationItk*>(source)) {
OpenGLJobProcessor::ScopedSynchronousGlJobExecution jobGuard;
ImageRepresentationGL* toReturn = ImageRepresentationGL::create(const_cast<ImageData*>(tester->getParent()), tester->getWeaklyTypedPointer());
return toReturn;
}
return nullptr;
}
ImageRepresentationLocal* LocalFromItkConversion::tryConvertFrom(const AbstractImageRepresentation* source) {
if (source == nullptr)
return nullptr;
// There is no way to determine basetype, number of channels and dimensionality of
// an ITK image at runtime. So there are currently 7*4*2 = 56 different possibilities
// what source could be. Thank god, there exists macro magic to create the 56
// different templated conversion codes.
#define CONVERT_ITK_TO_GENERIC_LOCAL(basetype, numchannels, dimensionality) \
if (const GenericImageRepresentationItk<basetype, numchannels, dimensionality>* tester = dynamic_cast< const GenericImageRepresentationItk<basetype, numchannels, dimensionality>* >(source)) { \
typedef GenericImageRepresentationItk<basetype, numchannels, dimensionality>::ItkImageType ItkImageType; \
typedef ItkImageType::PixelType ItkElementType; \
typedef GenericImageRepresentationItk<basetype, numchannels, dimensionality>::ElementType ElementType; \
const ItkElementType* pixelData = tester->getItkImage()->GetBufferPointer(); \
\
ItkImageType::RegionType region; \
region = tester->getItkImage()->GetBufferedRegion(); \
\
ItkImageType::SizeType s = region.GetSize(); \
tgt::svec3 size(s[0], 1, 1); \
if (dimensionality >= 2) \
size.y = s[1]; \
if (dimensionality == 3) \
size.z = s[2]; \
\
ElementType* pixelDataCopy = new ElementType[tgt::hmul(size)]; \
memcpy(pixelDataCopy, pixelData, tgt::hmul(size) * TypeTraits<basetype, numchannels>::elementSize); \
return GenericImageRepresentationLocal<basetype, numchannels>::create(const_cast<ImageData*>(source->getParent()), pixelDataCopy); \
}
#define DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_ND(numchannels, dimensionality) \
CONVERT_ITK_TO_GENERIC_LOCAL(uint8_t, numchannels, dimensionality) \
else CONVERT_ITK_TO_GENERIC_LOCAL(int8_t, numchannels, dimensionality) \
else CONVERT_ITK_TO_GENERIC_LOCAL(uint16_t, numchannels, dimensionality) \
else CONVERT_ITK_TO_GENERIC_LOCAL(int16_t, numchannels, dimensionality) \
else CONVERT_ITK_TO_GENERIC_LOCAL(uint32_t, numchannels, dimensionality) \
else CONVERT_ITK_TO_GENERIC_LOCAL(int32_t, numchannels, dimensionality) \
else CONVERT_ITK_TO_GENERIC_LOCAL(float, numchannels, dimensionality)
#define DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_D(dimensionality) \
DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_ND(1, dimensionality) \
else DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_ND(2, dimensionality) \
else DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_ND(3, dimensionality) \
else DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_ND(4, dimensionality)
// okay we've defined our macros. Now we just need to call them so that they call
// each other and create 56 different conversion checks - hooray
DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_D(2)
else DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_D(3)
return nullptr;
}
}
}
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef IMAGEREPRESENTATIONCONVERSIONITK_H__
#define IMAGEREPRESENTATIONCONVERSIONITK_H__
#include "core/coreapi.h"
#include "core/datastructures/imagerepresentationconversioncore.h"
#include "core/datastructures/imagerepresentationdisk.h"
#include "core/datastructures/imagerepresentationlocal.h"
#include "core/datastructures/imagerepresentationgl.h"
#include "core/datastructures/genericimagerepresentationlocal.h"
#include "modules/itk/core/genericimagerepresentationitk.h"
namespace campvis {
namespace conversion {
// = Declare converter classes ====================================================================
/// Conversion class to convert to ImageRepresentationGL.
struct CAMPVIS_CORE_API GlFromItkConversion {
static ImageRepresentationGL* tryConvertFrom(const AbstractImageRepresentation* source);
};
/// Conversion class to convert to ImageRepresentationLocal.
struct CAMPVIS_CORE_API LocalFromItkConversion {
static ImageRepresentationLocal* tryConvertFrom(const AbstractImageRepresentation* source);
};
/// Conversion class to convert to GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>.
template<typename BASETYPE, size_t NUMCHANNELS>
struct GenericLocalFromItkConversion {
static GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* tryConvertFrom(const AbstractImageRepresentation* source);
};
/// Conversion class to convert to GenericImageRepresentationItk<BASETYPE, NUMCHANNELS, DIMENSIONALITY>.
template<typename BASETYPE, size_t NUMCHANNELS, size_t DIMENSIONALITY>
struct GenericItkConversion {
static GenericImageRepresentationItk<BASETYPE, NUMCHANNELS, DIMENSIONALITY>* tryConvertFrom(const AbstractImageRepresentation* source);
};
// = Instantiate converter templates to register converters =======================================
// Register converters with corresponding target representations
template class ConversionFunctionRegistrar<ImageRepresentationGL, GlFromItkConversion>;
template class ConversionFunctionRegistrar<ImageRepresentationLocal, LocalFromItkConversion>;
// for GenericImageRepresentationLocal<> we use some macro magic to instantiate all necessary converters:
#define INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_BN(BASETYPE, NUMCHANNELS) template class ConversionFunctionRegistrar< GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS> , GenericLocalFromItkConversion<BASETYPE, NUMCHANNELS> >
#define INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_N(NUMCHANNELS) \
INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_BN(uint8_t, NUMCHANNELS); INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_BN(int8_t, NUMCHANNELS); \
INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_BN(uint16_t, NUMCHANNELS); INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_BN(int16_t, NUMCHANNELS); \
INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_BN(uint32_t, NUMCHANNELS); INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_BN(int32_t, NUMCHANNELS); \
INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_BN(float, NUMCHANNELS);
INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_N(1);
INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_N(2);
INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_N(3);
INSTANTIATE_TEMPLATE_ITK_FROM_LOCAL_N(4);
// same for conversion to GenericImageRepresentationItk<>
#define INSTANTIATE_TEMPLATE_GENERIC_ITK_BND(BASETYPE, NUMCHANNELS, DIMENSIONALITY) template class ConversionFunctionRegistrar< GenericImageRepresentationItk<BASETYPE, NUMCHANNELS, DIMENSIONALITY> , GenericItkConversion<BASETYPE, NUMCHANNELS, DIMENSIONALITY> >
#define INSTANTIATE_TEMPLATE_GENERIC_ITK_BN(BASETYPE, NUMCHANNELS) \
INSTANTIATE_TEMPLATE_GENERIC_ITK_BND(BASETYPE, NUMCHANNELS, 2); \
INSTANTIATE_TEMPLATE_GENERIC_ITK_BND(BASETYPE, NUMCHANNELS, 3);
#define INSTANTIATE_TEMPLATE_GENERIC_ITK_N(NUMCHANNELS) \
INSTANTIATE_TEMPLATE_GENERIC_ITK_BN(uint8_t, NUMCHANNELS); INSTANTIATE_TEMPLATE_GENERIC_ITK_BN(int8_t, NUMCHANNELS); \
INSTANTIATE_TEMPLATE_GENERIC_ITK_BN(uint16_t, NUMCHANNELS); INSTANTIATE_TEMPLATE_GENERIC_ITK_BN(int16_t, NUMCHANNELS); \
INSTANTIATE_TEMPLATE_GENERIC_ITK_BN(uint32_t, NUMCHANNELS); INSTANTIATE_TEMPLATE_GENERIC_ITK_BN(int32_t, NUMCHANNELS); \
INSTANTIATE_TEMPLATE_GENERIC_ITK_BN(float, NUMCHANNELS);
INSTANTIATE_TEMPLATE_GENERIC_ITK_N(1);
INSTANTIATE_TEMPLATE_GENERIC_ITK_N(2);
INSTANTIATE_TEMPLATE_GENERIC_ITK_N(3);
INSTANTIATE_TEMPLATE_GENERIC_ITK_N(4);
// = Template definition ==========================================================================