diff --git a/Modules/Core/include/mitkCommon.h b/Modules/Core/include/mitkCommon.h index 9d7496236e..ae0cfb0f04 100644 --- a/Modules/Core/include/mitkCommon.h +++ b/Modules/Core/include/mitkCommon.h @@ -1,149 +1,167 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITK_COMMON_H_DEFINED #define MITK_COMMON_H_DEFINED #ifdef _MSC_VER // This warns about truncation to 255 characters in debug/browse info #pragma warning (disable : 4786) #pragma warning (disable : 4068 ) /* disable unknown pragma warnings */ #endif //add only those headers here that are really necessary for all classes! #include "itkObject.h" #include "mitkConfig.h" #include "mitkLogMacros.h" #include "mitkExceptionMacro.h" #include "mitkGetClassHierarchy.h" #ifndef MITK_UNMANGLE_IPPIC #define mitkIpPicDescriptor mitkIpPicDescriptor #endif typedef unsigned int MapperSlotId; #define mitkClassMacro(className,SuperClassName) \ typedef className Self; \ typedef SuperClassName Superclass; \ typedef itk::SmartPointer Pointer; \ typedef itk::SmartPointer ConstPointer; \ static const char* GetStaticNameOfClass() { return #className; } \ virtual std::vector GetClassHierarchy() const { return mitk::GetClassHierarchy(); } \ itkTypeMacro(className,SuperClassName) /** * Macro for Constructors with one parameter for classes derived from itk::Lightobject **/ #define mitkNewMacro1Param(classname,type) \ static Pointer New(type _arg) \ { \ Pointer smartPtr = new classname ( _arg ); \ smartPtr->UnRegister(); \ return smartPtr; \ } \ /** * Macro for Constructors with two parameters for classes derived from itk::Lightobject **/ #define mitkNewMacro2Param(classname,typea,typeb) \ static Pointer New(typea _arga, typeb _argb) \ { \ Pointer smartPtr = new classname ( _arga, _argb ); \ smartPtr->UnRegister(); \ return smartPtr; \ } \ /** * Macro for Constructors with three parameters for classes derived from itk::Lightobject **/ #define mitkNewMacro3Param(classname,typea,typeb,typec) \ static Pointer New(typea _arga, typeb _argb, typec _argc) \ { \ Pointer smartPtr = new classname ( _arga, _argb, _argc ); \ smartPtr->UnRegister(); \ return smartPtr; \ } \ /** * Macro for Constructors with four parameters for classes derived from itk::Lightobject **/ #define mitkNewMacro4Param(classname,typea,typeb,typec,typed) \ static Pointer New(typea _arga, typeb _argb, typec _argc, typed _argd) \ { \ Pointer smartPtr = new classname ( _arga, _argb, _argc, _argd ); \ smartPtr->UnRegister(); \ return smartPtr; \ } \ /** * Macro for Constructors with five parameters for classes derived from itk::Lightobject **/ #define mitkNewMacro5Param(classname,typea,typeb,typec,typed,typee) \ static Pointer New(typea _arga, typeb _argb, typec _argc, typed _argd, typee _arge) \ { \ Pointer smartPtr = new classname ( _arga, _argb, _argc, _argd, _arge ); \ smartPtr->UnRegister(); \ return smartPtr; \ } \ /** * Macro for Constructors with six parameters for classes derived from itk::Lightobject **/ #define mitkNewMacro6Param(classname,typea,typeb,typec,typed,typee, typef) \ static Pointer New(typea _arga, typeb _argb, typec _argc, typed _argd, typee _arge, typef _argf) \ { \ Pointer smartPtr = new classname ( _arga, _argb, _argc, _argd, _arge, _argf ); \ smartPtr->UnRegister(); \ return smartPtr; \ } \ /** Get a smart const pointer to an object. Creates the member * Get"name"() (e.g., GetPoints()). */ #define mitkGetObjectMacroConst(name,type) \ virtual type * Get##name () const \ { \ itkDebugMacro("returning " #name " address " << this->m_##name ); \ return this->m_##name.GetPointer(); \ } /** Creates a Clone() method for "Classname". Returns a smartPtr of a clone of the calling object*/ #define mitkCloneMacro(classname) \ virtual itk::LightObject::Pointer InternalClone() const \ { \ Pointer smartPtr = new classname(*this); \ smartPtr->UnRegister(); \ return smartPtr.GetPointer(); \ } /** cross-platform deprecation macro \todo maybe there is something in external toolkits (ITK, VTK,...) that we could reulse -- would be much preferable */ #ifdef MITK_NO_DEPRECATED_WARNINGS #define DEPRECATED(func) func #elif defined(__GNUC__) #define DEPRECATED(...) __VA_ARGS__ __attribute__((deprecated)) #elif defined(_MSC_VER) #define DEPRECATED(...) __declspec(deprecated) ##__VA_ARGS__ #else #pragma message("WARNING: You need to implement DEPRECATED for your compiler!") #define DEPRECATED(func) func #endif +/** + * Mark templates as exported to generate public RTTI symbols which are + * needed for GCC and Clang to support e.g. dynamic_cast between DSOs. + */ +#if defined(__clang__) || defined(__GNUC__) + #define MITK_EXPORT __attribute__ ((visibility ("default"))) + #define MITK_IMPORT __attribute__ ((visibility ("default"))) + #define MITK_LOCAL __attribute__ ((visibility ("hidden"))) +#elif defined(WIN32) + #define MITK_EXPORT __declspec(dllexport) + #define MITK_IMPORT __declspec(dllimport) + #define MITK_LOCAL +#else + #define MITK_EXPORT + #define MITK_IMPORT + #define MITK_LOCAL +#endif + #endif // MITK_COMMON_H_DEFINED diff --git a/Modules/Core/include/mitkITKImageImport.h b/Modules/Core/include/mitkITKImageImport.h index 0d1f705508..f9b3d7f9a5 100644 --- a/Modules/Core/include/mitkITKImageImport.h +++ b/Modules/Core/include/mitkITKImageImport.h @@ -1,195 +1,195 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKITKIMAGEIMPORT_H_HEADER_INCLUDED_C1E4861D #define MITKITKIMAGEIMPORT_H_HEADER_INCLUDED_C1E4861D #include #include "mitkImageSource.h" #include "itkImageToImageFilterDetail.h" namespace mitk { /** * @brief Pipelined import of itk::Image * * The image data contained in the itk::Image is referenced, * not copied. * The easiest way of use is by the function * mitk::ImportItkImage * \code * mitkImage = mitk::ImportItkImage(itkImage); * \endcode * \sa ImportItkImage * @ingroup Adaptor */ template -class MITKCORE_EXPORT ITKImageImport : public ImageSource +class MITK_EXPORT ITKImageImport : public ImageSource { public: mitkClassMacro(ITKImageImport,ImageSource) itkFactorylessNewMacro(Self) itkCloneMacro(Self) /// \brief The type of the input image. typedef TInputImage InputImageType; typedef typename InputImageType::Pointer InputImagePointer; typedef typename InputImageType::ConstPointer InputImageConstPointer; typedef typename InputImageType::RegionType InputImageRegionType; typedef typename InputImageType::PixelType InputImagePixelType; /** ImageDimension constants */ itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension); itkStaticConstMacro(RegionDimension, unsigned int, mitk::SlicedData::RegionDimension); /** \brief Set the input itk::Image of this image importer. */ InputImageType * GetInput(void); /** \brief Set the input itk::Image of this image importer. */ void SetInput(const InputImageType*); using itk::ProcessObject::SetInput; /** * \brief Set the Geometry of the result image (optional) * * The Geometry has to fit the dimension and size of * the input image. The Geometry will be cloned, not * referenced! * * Providing the Geometry is optional. * The default behavior is to set the geometry by * the itk::Image::GetDirection() information. */ void SetGeometry(const BaseGeometry* geometry); protected: ITKImageImport(); virtual ~ITKImageImport(); virtual void GenerateOutputInformation(); virtual void GenerateInputRequestedRegion(); virtual void GenerateData(); virtual void SetNthOutput(DataObjectPointerArraySizeType num, itk::DataObject *output); /** Typedef for the region copier function object that converts an * output region to an input region. */ typedef itk::ImageToImageFilterDetail::ImageRegionCopier OutputToInputRegionCopierType; BaseGeometry::Pointer m_Geometry; }; /** * @brief Imports an itk::Image (with a specific type) as an mitk::Image. * @ingroup Adaptor * * Instantiates instance of ITKImageImport. * mitk::ITKImageImport does not cast pixel types etc., it just imports * image data. If you get a compile error, try image.GetPointer(). * * \param update: if \a true, fill mitk::Image, which will execute the * up-stream pipeline connected to the input itk::Image. Otherwise you * need to make sure that Update() is called on the mitk::Image before * its data is being used, e.g., by connecting it to an mitk-pipeline * and call Update of a downstream filter at some time. * \sa itk::Image::CastToMitkImage */ template Image::Pointer ImportItkImage(const itk::SmartPointer& itkimage, const BaseGeometry* geometry = NULL, bool update = true); /** * @brief Imports an itk::Image (with a specific type) as an mitk::Image. * @ingroup Adaptor * * Instantiates instance of ITKImageImport * mitk::ITKImageImport does not cast pixel types etc., it just imports * image data. If you get a compile error, try image.GetPointer(). * * \param update: if \a true, fill mitk::Image, which will execute the * up-stream pipeline connected to the input itk::Image. Otherwise you * need to make sure that Update() is called on the mitk::Image before * its data is being used, e.g., by connecting it to an mitk-pipeline * and call Update of a downstream filter at some time. * * * \note If the source (itk image) and the target (mitk image) do not share the same scope, the mitk::GrabItkImageMemory function * has to be used instead. Otherwise the image memory managed by the itk image is lost at a scope level change. This affects especially the * usage in combination with AccessByItk macros as in following example code * * \snippet Testing/mitkGrabItkImageMemoryTest.cpp OutOfScopeCall * * which calls an ITK-like filter * * \snippet Testing/mitkGrabItkImageMemoryTest.cpp ItkThresholdFilter * * * \sa itk::Image::CastToMitkImage * \sa GrabItkImageMemory */ template Image::Pointer ImportItkImage(const ItkOutputImageType* itkimage, const BaseGeometry* geometry = NULL, bool update = true); /** * @brief Grabs the memory of an itk::Image (with a specific type) * and puts it into an mitk::Image. * @ingroup Adaptor * * The memory is managed by the mitk::Image after calling this * function. The itk::Image remains valid until the mitk::Image * decides to free the memory. * \param update: if \a true, fill mitk::Image, which will execute the * up-stream pipeline connected to the input itk::Image. Otherwise you * need to make sure that Update() is called on the mitk::Image before * its data is being used, e.g., by connecting it to an mitk-pipeline * and call Update of a downstream filter at some time. * \sa ImportItkImage */ template Image::Pointer GrabItkImageMemory(itk::SmartPointer& itkimage, mitk::Image* mitkImage = NULL, const BaseGeometry* geometry = NULL, bool update = true); /** * @brief Grabs the memory of an itk::Image (with a specific type) * and puts it into an mitk::Image. * @ingroup Adaptor * * The memory is managed by the mitk::Image after calling this * function. The itk::Image remains valid until the mitk::Image * decides to free the memory. * \param update: if \a true, fill mitk::Image, which will execute the * up-stream pipeline connected to the input itk::Image. Otherwise you * need to make sure that Update() is called on the mitk::Image before * its data is being used, e.g., by connecting it to an mitk-pipeline * and call Update of a downstream filter at some time. * \sa ImportItkImage */ template Image::Pointer GrabItkImageMemory(ItkOutputImageType* itkimage, mitk::Image* mitkImage = NULL, const BaseGeometry* geometry = NULL, bool update = true); } // namespace mitk #ifndef MITK_MANUAL_INSTANTIATION #include "mitkITKImageImport.txx" #endif #endif /* MITKITKIMAGEIMPORT_H_HEADER_INCLUDED_C1E4861D */