diff --git a/Wrapping/Common/mitk_swig_classes.i b/Wrapping/Common/mitk_swig_classes.i index f9a3cae7b0..abaaa24294 100644 --- a/Wrapping/Common/mitk_swig_classes.i +++ b/Wrapping/Common/mitk_swig_classes.i @@ -1,56 +1,92 @@ // // Defining some Macros that make problems with SWIG as the // corresponding definitions are not included by default. // Luckely, these includes are not necessary for SWIG. // #define ITK_NOEXCEPT #define ITKCommon_EXPORT #define ITK_OVERRIDE #define MITKCORE_EXPORT #define MITKCLCORE_EXPORT #define MITKCLUTILITIES_EXPORT -#define DEPRECATED(func) func +#define ITKCommon_EXPORT + +#define ITKCommon_EXPORT +#define ITK_FORWARD_EXPORT +#define ITK_OVERRIDE +#define ITK_NOEXCEPT + %include %include %include %include %include %include #define DEPRECATED(func) func +#undef ITK_DISALLOW_COPY_AND_ASSIGN +#define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) %pythoncode %{ convertion_list = {} %} -SWIG_ADD_MITK_CLASS(TimeGeometry, mitkTimeGeometry.h) -SWIG_ADD_MITK_CLASS(ArbitraryTimeGeometry, mitkArbitraryTimeGeometry.h) -SWIG_ADD_MITK_CLASS(ProportionalTimeGeometry, mitkProportionalTimeGeometry.h) -SWIG_ADD_MITK_CLASS(BaseGeometry, mitkBaseGeometry.h) -SWIG_ADD_MITK_CLASS(Geometry3D, mitkGeometry3D.h) -SWIG_ADD_MITK_CLASS(SlicedGeometry3D, mitkSlicedGeometry3D.h) -SWIG_ADD_MITK_CLASS(PlaneGeometry , mitkPlaneGeometry.h) - - -SWIG_ADD_MITK_CLASS(BaseData, mitkBaseData.h) -SWIG_ADD_MITK_CLASS(SlicedData, mitkSlicedData.h) -SWIG_ADD_MITK_CLASS(Image, mitkImage.h) -SWIG_ADD_MITK_CLASS(PointSet, mitkPointSet.h) - -SWIG_ADD_MITK_CLASS(AbstractGlobalImageFeature, mitkAbstractGlobalImageFeature.h) -SWIG_ADD_MITK_CLASS(GIFImageDescriptionFeatures, mitkGIFImageDescriptionFeatures.h) -SWIG_ADD_MITK_CLASS(GIFFirstOrderStatistics, mitkGIFFirstOrderStatistics.h) -SWIG_ADD_MITK_CLASS(GIFFirstOrderHistogramStatistics, mitkGIFFirstOrderHistogramStatistics.h) -SWIG_ADD_MITK_CLASS(GIFVolumetricStatistics, mitkGIFVolumetricStatistics.h) -SWIG_ADD_MITK_CLASS(GIFVolumetricDensityStatistics, mitkGIFVolumetricDensityStatistics.h) -SWIG_ADD_MITK_CLASS(GIFCooccurenceMatrix2, mitkGIFCooccurenceMatrix2.h) -SWIG_ADD_MITK_CLASS(GIFNeighbouringGreyLevelDependenceFeature, mitkGIFNeighbouringGreyLevelDependenceFeatures.h) -SWIG_ADD_MITK_CLASS(GIFGreyLevelRunLength, mitkGIFGreyLevelRunLength.h) -SWIG_ADD_MITK_CLASS(GIFGreyLevelSizeZone, mitkGIFGreyLevelSizeZone.h) -SWIG_ADD_MITK_CLASS(GIFGreyLevelDistanceZone, mitkGIFGreyLevelDistanceZone.h) -SWIG_ADD_MITK_CLASS(GIFLocalIntensity, mitkGIFLocalIntensity.h) -SWIG_ADD_MITK_CLASS(GIFIntensityVolumeHistogramFeatures, mitkGIFIntensityVolumeHistogramFeatures.h) -SWIG_ADD_MITK_CLASS(GIFNeighbourhoodGreyToneDifferenceFeatures, mitkGIFNeighbourhoodGreyToneDifferenceFeatures.h) -SWIG_ADD_MITK_CLASS(GIFCurvatureStatistic, mitkGIFCurvatureStatistic.h) \ No newline at end of file +SWIG_ADD_MITK_CLASS(Object, itkObject.h, itk) +SWIG_ADD_MITK_CLASS(DataObject, itkDataObject.h, itk) + +SWIG_ADD_MITK_CLASS(TimeGeometry, mitkTimeGeometry.h, mitk) +SWIG_ADD_MITK_CLASS(ArbitraryTimeGeometry, mitkArbitraryTimeGeometry.h, mitk) +SWIG_ADD_MITK_CLASS(ProportionalTimeGeometry, mitkProportionalTimeGeometry.h, mitk) +SWIG_ADD_MITK_CLASS(BaseGeometry, mitkBaseGeometry.h, mitk) +SWIG_ADD_MITK_CLASS(Geometry3D, mitkGeometry3D.h, mitk) +SWIG_ADD_MITK_CLASS(SlicedGeometry3D, mitkSlicedGeometry3D.h, mitk) +SWIG_ADD_MITK_CLASS(PlaneGeometry , mitkPlaneGeometry.h, mitk) + +SWIG_ADD_NONOBJECT_NOVECTOR_CLASS(BoundingBox, mitkBaseGeometry.h, mitk) +SWIG_ADD_NONOBJECT_CLASS(TimeBounds, mitkBaseGeometry.h, mitk) +SWIG_ADD_NONOBJECT_CLASS(FixedArrayType, mitkBaseGeometry.h, mitk) + +SWIG_ADD_NONOBJECT_CLASS(Point2D, mitkPoint.h, mitk) + + %{ + #include < itkPoint.h > + %} + + // Include the given header, where the class definition is found + %include + + %template( itkPoint ) itk::Point; + +SWIG_ADD_NONOBJECT_TEMPLATECLASS(Point3D, mitkPoint.h, mitk, %arg(Point) ) +SWIG_ADD_NONOBJECT_TEMPLATECLASS(Point3D, mitkPoint.h, mitk, %arg(Point) ) +SWIG_ADD_NONOBJECT_CLASS(Point4D, mitkPoint.h, mitk) +SWIG_ADD_NONOBJECT_CLASS(Point2I, mitkPoint.h, mitk) +SWIG_ADD_NONOBJECT_CLASS(Point3I, mitkPoint.h, mitk) +SWIG_ADD_NONOBJECT_CLASS(Point4I, mitkPoint.h, mitk) +SWIG_ADD_NONOBJECT_CLASS(VnlVector, mitkVector.h, mitk) +SWIG_ADD_NONOBJECT_CLASS(Vector2D, mitkVector.h, mitk) +SWIG_ADD_NONOBJECT_CLASS(Vector3D, mitkVector.h, mitk) +SWIG_ADD_NONOBJECT_CLASS(Vector4D, mitkVector.h, mitk) + +SWIG_ADD_MITK_CLASS(BaseData, mitkBaseData.h, mitk) +SWIG_ADD_MITK_CLASS(SlicedData, mitkSlicedData.h, mitk) +SWIG_ADD_MITK_CLASS(Image, mitkImage.h, mitk) +SWIG_ADD_MITK_CLASS(PointSet, mitkPointSet.h, mitk) + +SWIG_ADD_MITK_CLASS(AbstractGlobalImageFeature, mitkAbstractGlobalImageFeature.h, mitk) +SWIG_ADD_MITK_CLASS(GIFImageDescriptionFeatures, mitkGIFImageDescriptionFeatures.h, mitk) +SWIG_ADD_MITK_CLASS(GIFFirstOrderStatistics, mitkGIFFirstOrderStatistics.h, mitk) +SWIG_ADD_MITK_CLASS(GIFFirstOrderHistogramStatistics, mitkGIFFirstOrderHistogramStatistics.h, mitk) +SWIG_ADD_MITK_CLASS(GIFVolumetricStatistics, mitkGIFVolumetricStatistics.h, mitk) +SWIG_ADD_MITK_CLASS(GIFVolumetricDensityStatistics, mitkGIFVolumetricDensityStatistics.h, mitk) +SWIG_ADD_MITK_CLASS(GIFCooccurenceMatrix2, mitkGIFCooccurenceMatrix2.h, mitk) +SWIG_ADD_MITK_CLASS(GIFNeighbouringGreyLevelDependenceFeature, mitkGIFNeighbouringGreyLevelDependenceFeatures.h, mitk) +SWIG_ADD_MITK_CLASS(GIFGreyLevelRunLength, mitkGIFGreyLevelRunLength.h, mitk) +SWIG_ADD_MITK_CLASS(GIFGreyLevelSizeZone, mitkGIFGreyLevelSizeZone.h, mitk) +SWIG_ADD_MITK_CLASS(GIFGreyLevelDistanceZone, mitkGIFGreyLevelDistanceZone.h, mitk) +SWIG_ADD_MITK_CLASS(GIFLocalIntensity, mitkGIFLocalIntensity.h, mitk) +SWIG_ADD_MITK_CLASS(GIFIntensityVolumeHistogramFeatures, mitkGIFIntensityVolumeHistogramFeatures.h, mitk) +SWIG_ADD_MITK_CLASS(GIFNeighbourhoodGreyToneDifferenceFeatures, mitkGIFNeighbourhoodGreyToneDifferenceFeatures.h, mitk) +SWIG_ADD_MITK_CLASS(GIFCurvatureStatistic, mitkGIFCurvatureStatistic.h, mitk) \ No newline at end of file diff --git a/Wrapping/Common/mitk_swig_cpp_include.i b/Wrapping/Common/mitk_swig_cpp_include.i index 776b250ea4..198e92ece6 100644 --- a/Wrapping/Common/mitk_swig_cpp_include.i +++ b/Wrapping/Common/mitk_swig_cpp_include.i @@ -1,131 +1,127 @@ %{ #include #include #include #include #include #include #include #include // SWIG Doesn't wrap namespaces. This leads to some problems, if the namespaces are not used. -// using namespace mitk; using mitk::DataStorage; using mitk::IFileReader; using mitk::IFileWriter; -using mitk::BaseData; -using mitk::TimeBounds; using mitk::ScalarType; -using mitk::Point3D; -using mitk::BaseGeometry; -using mitk::VnlVector; -using mitk::Vector3D; -using mitk::Point2D; using mitk::Operation; using mitk::GeometryTransformHolder; using mitk::AffineTransform3D; using mitk::BaseProperty; using mitk::ImageDescriptor; using mitk::PropertyList; using mitk::ImageDataItem; using mitk::PointSpecificationType; using mitk::IntensityQuantifier; -using mitk::BoundingBox; -using itk::DataObject; -// using namespace itk; +using itk::LightObject; +using itk::ModifiedTimeType; +using itk::TimeStamp; +using itk::EventObject; +using itk::MetaDataDictionary; +using itk::SmartPointerForwardReference; +using itk::RealTimeStamp; std::vector GetImageSize(mitk::Image::Pointer image) { std::vector< unsigned int > size; unsigned int dimension = image->GetDimension(); for (int i = 0; i < dimension; ++i) { size.push_back(image->GetDimension(i)); } return size; } std::vector GetImageSize(mitk::Image* image) { std::vector< unsigned int > size; unsigned int dimension = image->GetDimension(); for (int i = 0; i < dimension; ++i) { size.push_back(image->GetDimension(i)); } return size; } struct TypeDefinitions { static const int ComponentTypeUInt8 = mitk::MapPixelType::value>::IOComponentType; static const int ComponentTypeInt8 = mitk::MapPixelType::value>::IOComponentType; static const int ComponentTypeUInt16 = mitk::MapPixelType::value>::IOComponentType; static const int ComponentTypeInt16 = mitk::MapPixelType::value>::IOComponentType; static const int ComponentTypeUInt32 = mitk::MapPixelType::value>::IOComponentType; static const int ComponentTypeInt32 = mitk::MapPixelType::value>::IOComponentType; static const int ComponentTypeFloat = mitk::MapPixelType::value>::IOComponentType; static const int ComponentTypeDouble = mitk::MapPixelType::value>::IOComponentType; }; mitk::PixelType MakePixelTypeFromTypeID(int componentTypeID, int numberOfComponents) { switch (componentTypeID) { case TypeDefinitions::ComponentTypeUInt8 : return mitk::MakePixelType(numberOfComponents); case TypeDefinitions::ComponentTypeInt8 : return mitk::MakePixelType(numberOfComponents); case TypeDefinitions::ComponentTypeUInt16 : return mitk::MakePixelType(numberOfComponents); case TypeDefinitions::ComponentTypeInt16 : return mitk::MakePixelType(numberOfComponents); case TypeDefinitions::ComponentTypeUInt32 : return mitk::MakePixelType(numberOfComponents); case TypeDefinitions::ComponentTypeInt32 : return mitk::MakePixelType(numberOfComponents); case TypeDefinitions::ComponentTypeFloat : return mitk::MakePixelType(numberOfComponents); case TypeDefinitions::ComponentTypeDouble : return mitk::MakePixelType(numberOfComponents); default: return mitk::MakePixelType(numberOfComponents); } } mitk::Image::Pointer MakeImage(mitk::PixelType pixelType, std::vector shape) { mitk::Image::Pointer image = mitk::Image::New(); image->Initialize(pixelType, shape.size(), shape.data()); return image; } template -typename T::Pointer ConvertTo(mitk::BaseData::Pointer base) +typename T::Pointer ConvertTo(itk::Object::Pointer base) { typename T::Pointer erg = dynamic_cast(base.GetPointer()); return erg; } %} std::vector GetImageSize(mitk::Image::Pointer image); std::vector GetImageSize(mitk::Image* image); mitk::PixelType MakePixelTypeFromTypeID(int componentTypeID, int numberOfComponents); mitk::Image::Pointer MakeImage(mitk::PixelType pixelType, std::vector shape); %constant int ComponentTypeUInt8 = TypeDefinitions::ComponentTypeUInt8; %constant int ComponentTypeInt8 = TypeDefinitions::ComponentTypeInt8; %constant int ComponentTypeUInt16 = TypeDefinitions::ComponentTypeUInt16; %constant int ComponentTypeInt16 = TypeDefinitions::ComponentTypeInt16; %constant int ComponentTypeUInt32 = TypeDefinitions::ComponentTypeUInt32; %constant int ComponentTypeInt32 = TypeDefinitions::ComponentTypeInt32; %constant int ComponentTypeFloat = TypeDefinitions::ComponentTypeFloat; %constant int ComponentTypeDouble = TypeDefinitions::ComponentTypeDouble; template -typename T::Pointer ConvertTo(mitk::BaseData::Pointer base); +typename T::Pointer ConvertTo(itk::Object::Pointer base); diff --git a/Wrapping/Common/mitk_swig_macros.i b/Wrapping/Common/mitk_swig_macros.i index 0345f9dc8b..9ab07200c4 100644 --- a/Wrapping/Common/mitk_swig_macros.i +++ b/Wrapping/Common/mitk_swig_macros.i @@ -1,128 +1,196 @@ // // This file contains macros for swig. // // // SWIG_ADD_MITK_CLASS is a helper macro in order to do // all important stuff before an mitk::Class is included. // Requires the name of the class as it is in c++ as classname // and the include file, in which the class is defined. // It is assumed that the class is somehow inherited from // mitk::BaseData, and supports smartpointers. // -%define SWIG_ADD_MITK_CLASS(classname, classinclude) +%define SWIG_ADD_MITK_CLASS(classname, classinclude, nspace) // Include the include file in the generated cpp file %{ #include < classinclude > - typedef mitk:: ## classname classname ## ; - using mitk:: ## classname ; + typedef nspace ## :: ## classname classname ## ; + using nspace ## :: ## classname ; %} // Include the given header, where the class definition is found %include - using mitk:: ## classname ; + using nspace ##:: ## classname ; // Declaring that this class is a smart-pointer class, in order to handle // online upcasting where necessary (for example python) - %feature("smartptr", noblock=1) mitk:: ## classname { itk::SmartPointer } + %feature("smartptr", noblock=1) nspace ##:: ## classname { itk::SmartPointer } // Typedef is necessary to overcome ambigiouties resulting in the fact that SWIG // ignores namespaces. This can lead to some problems with templates. - typedef mitk:: ## classname classname ## ; + typedef nspace ## :: ## classname classname ## ; // Initianziation of std. vectors containing pointers to these classes. This allows to use // vectors of these types as target language arrays. - %template(Vector ## classname ## Pointer) std::vector< mitk:: ## classname ## ::Pointer >; - %template(Vector ## classname) std::vector< mitk:: ## classname ## ::Self *>; + %template(Vector ## classname ## Pointer) std::vector< nspace ## :: ## classname ## ::Pointer >; + %template(Vector ## classname) std::vector< nspace ## :: ## classname ## ::Self *>; // Defining the Smartpointer, allows easy access in target language - %template(classname ## Pointer) itk::SmartPointer; + %template(classname ## Pointer) itk::SmartPointer; // Define a conversion method to convert from and to types - %template(ConvertTo ## classname) ConvertTo; + %template(ConvertTo ## classname) ConvertTo< nspace ##:: ## classname ## >; // This extend is necessary to have the automatic cast methods available -%extend itk::SmartPointer { +%extend itk::SmartPointer< nspace ## :: ## classname ## ::Self> { %pythoncode %{ def _GetListOfValidItems(self): return [str(k) for k in self.GetClassHierarchy() if k in convertion_list.keys() ] %} %pythoncode %{ def __getattr__(self, item): if type(item)==str: if (len(item) > 9) and ('ConvertTo' in item): searchString=item[9:] if searchString in self._GetListOfValidItems(): def func_t(): return convertion_list[searchString](self) return func_t %} %pythoncode %{ def __dir__(self): return super().__dir__() + ['ConvertTo'+k for k in self._GetListOfValidItems()] %} } -%extend classname { +%extend std::vector< nspace ## :: ## classname *>::value_type { %pythoncode %{ def _GetListOfValidItems(self): return [str(k) for k in self.GetClassHierarchy() if k in convertion_list.keys() ] %} %pythoncode %{ def __getattr__(self, item): if type(item)==str: if (len(item) > 9) and ('ConvertTo' in item): searchString=item[9:] if searchString in self._GetListOfValidItems(): def func_t(): return convertion_list[searchString](self) return func_t %} %pythoncode %{ def __dir__(self): return super().__dir__() + ['ConvertTo'+k for k in self._GetListOfValidItems()] %} } %pythoncode %{ convertion_list['classname'] = ConvertTo ## classname %} %enddef - // -// This file contains macros for swig. +// SWIG_ADD_NONOBJECT_CLASS is a helper macro in order to do +// all important stuff before an mitk::Class is included. +// Requires the name of the class as it is in c++ as classname +// and the include file, in which the class is defined. +// It is assumed that the class is somehow inherited from +// mitk::BaseData, and supports smartpointers. // +%define SWIG_ADD_NONOBJECT_CLASS(classname, classinclude, nspace) + // Include the include file in the generated cpp file + %{ + #include < classinclude > + typedef nspace ## :: ## classname classname ## ; + using nspace ## :: ## classname ; + %} + + // Include the given header, where the class definition is found + %include + using nspace ##:: ## classname ; + + // Typedef is necessary to overcome ambigiouties resulting in the fact that SWIG + // ignores namespaces. This can lead to some problems with templates. + typedef nspace ## :: ## classname classname ## ; + + class nspace ## :: ## classname ## ; + + // Initianziation of std. vectors containing pointers to these classes. This allows to use + // vectors of these types as target language arrays. + %template(Vector ## classname ## Pointer) std::vector< nspace ## :: ## classname * >; + %template(Vector ## classname) std::vector< nspace ## :: ## classname >; + +%enddef + + // -// SWIG_ADD_ITK_OBJECT_CLASS is a helper macro in order to do +// SWIG_ADD_NONOBJECT_TEMPLATECLASS is a helper macro in order to do // all important stuff before an mitk::Class is included. // Requires the name of the class as it is in c++ as classname // and the include file, in which the class is defined. -// It assumes that the class is not part of a smartpointer!! +// It is assumed that the class is somehow inherited from +// mitk::BaseData, and supports smartpointers. // -%define SWIG_ADD_ITK_OBJECT_CLASS(classname, classinclude, derivedlist) - SWIG_ADD_MITK_CLASS(classname, classinclude) - -%extend itk::SmartPointer { - %pythoncode %{ - def GetClassHierarchy(self): - derived_list=eval( ## derivedlist ## ) - return derived_list +%define SWIG_ADD_NONOBJECT_TEMPLATECLASS(classname, classinclude, nspace, tmplstring) + // Include the include file in the generated cpp file + %{ + #include < classinclude > + typedef nspace ## :: ## classname classname ## ; + using nspace ## :: ## classname ; %} -} -%extend classname { - %pythoncode %{ - def GetClassHierarchy(self): - derived_list= eval( ## derivedlist ## ) - return derived_list + // Include the given header, where the class definition is found + %include + using nspace ##:: ## classname ; + + // Typedef is necessary to overcome ambigiouties resulting in the fact that SWIG + // ignores namespaces. This can lead to some problems with templates. + typedef nspace ## :: ## classname classname ## ; + + %template( classname ) nspace ## :: ## tmplstring ## ; + + // Initianziation of std. vectors containing pointers to these classes. This allows to use + // vectors of these types as target language arrays. + %template(Vector ## classname ## Pointer) std::vector< nspace ## :: ## classname * >; + %template(Vector ## classname) std::vector< nspace ## :: ## classname >; + +%enddef + + + + +// +// SWIG_ADD_NONOBJECT_CLASS is a helper macro in order to do +// all important stuff before an mitk::Class is included. +// Requires the name of the class as it is in c++ as classname +// and the include file, in which the class is defined. +// It is assumed that the class is somehow inherited from +// mitk::BaseData, and supports smartpointers. +// +%define SWIG_ADD_NONOBJECT_NOVECTOR_CLASS(classname, classinclude, nspace) + // Include the include file in the generated cpp file + %{ + #include < classinclude > + typedef nspace ## :: ## classname classname ## ; + using nspace ## :: ## classname ; %} -} -%enddef \ No newline at end of file + // Include the given header, where the class definition is found + %include + using nspace ##:: ## classname ; + + // Typedef is necessary to overcome ambigiouties resulting in the fact that SWIG + // ignores namespaces. This can lead to some problems with templates. + typedef nspace ## :: ## classname classname ## ; + + // Initianziation of std. vectors containing pointers to these classes. This allows to use + // vectors of these types as target language arrays. + %template(Vector ## classname ## Pointer) std::vector< nspace ## :: ## classname * >; + +%enddef