[Insight-users] Python Wrapping Additions ( for MultiResMIRegistration )

Hua Qian hqian at imaging . robarts . ca
Thu, 06 Nov 2003 12:33:45 -0500


This is a multi-part message in MIME format.
--------------020306000500070505010400
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi Lius,

Attached please find a few file that I modified to get
MultiResMIRegistraion application work in python.
Here is the summary:

CSwig/Algorithms
  CMakeLists.txt
    Added entry for
      wrap_itkRecursiveMultiResolutionPyramidImageFilter
  wrap_ITKAlgorithms.cxx
    Added entries for
      ITK_WRAP_GROUP(itkMattesMutualInformationImageToImageMetric)
      ITK_WRAP_GROUP(itkRecursiveMultiResolutionPyramidImageFilter)
  wrap_itkRecursiveMultiResolutionPyramidImageFilter.cxx
    wrapped with superclass

CSwig/Common
  wrap_itkFixedArray.cxx
    Added itkFixedArrayUI that is needed for shrink factors
    of multi resolution pyramid

Regards,
Hua

--------------020306000500070505010400
Content-Type: text/plain;
 name="CMakeLists.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="CMakeLists.txt"

# create the ITKAlgorithmsTcl libraries
SET(WRAP_SOURCES
    wrap_itkCurvatureFlowImageFilter
    wrap_itkHistogramMatchingImageFilter
    wrap_itkImageRegistrationMethod
    wrap_itkImageToImageMetric
    wrap_itkMattesMutualInformationImageToImageMetric
    wrap_itkMeanSquaresImageToImageMetric
    wrap_itkMutualInformationImageToImageMetric
    wrap_itkMultiResolutionImageRegistrationMethod
    wrap_itkNormalizedCorrelationImageToImageMetric
    wrap_itkOtsuThresholdImageCalculator
    wrap_itkMeanReciprocalSquareDifferenceImageToImageMetric
    wrap_itkSimpleFuzzyConnectednessImageFilterBase
    wrap_itkSimpleFuzzyConnectednessScalarImageFilter
    wrap_itkThresholdSegmentationLevelSetImageFilter
    wrap_itkGeodesicActiveContourLevelSetImageFilter
    wrap_itkShapeDetectionLevelSetImageFilter
    wrap_itkCurvesLevelSetImageFilter
    wrap_itkNarrowBandCurvesLevelSetImageFilter
    wrap_itkRecursiveMultiResolutionPyramidImageFilter
)

# loop over cable config files creating two lists:
# WRAP_TCL_SOURCES: list of generated files
FOREACH(Source ${WRAP_SOURCES})
   SET(WRAP_TCL_SOURCES ${WRAP_TCL_SOURCES} ${Source}Tcl.cxx)
   SET(WRAP_PYTHON_SOURCES ${WRAP_PYTHON_SOURCES} ${Source}Python.cxx)
   SET(ALL_IDX_FILES ${ALL_IDX_FILES} ${WrapITK_BINARY_DIR}/Algorithms/${Source}.idx )
   SET(INDEX_FILE_CONTENT "${INDEX_FILE_CONTENT}${WrapITK_BINARY_DIR}/Algorithms/${Source}.idx\n")
ENDFOREACH(Source)

SET(WRAP_TCL_SOURCES ${WRAP_TCL_SOURCES} wrap_ITKAlgorithmsTclTcl.cxx)
SET(WRAP_PYTHON_SOURCES ${WRAP_PYTHON_SOURCES} wrap_ITKAlgorithmsPythonPython.cxx)

# set the generated sources as generated
SET_SOURCE_FILES_PROPERTIES(${WRAP_TCL_SOURCES} ${WRAP_PYTHON_SOURCES} GENERATED )
IF(ITK_CSWIG_TCL)
  ADD_LIBRARY(ITKAlgorithmsTcl SHARED ${WRAP_TCL_SOURCES})
  SET_TARGET_PROPERTIES(ITKAlgorithmsTcl PROPERTIES LINK_FLAGS "${CSWIG_EXTRA_LINKFLAGS}")
  TARGET_LINK_LIBRARIES(ITKAlgorithmsTcl ITKAlgorithms VXLNumericsTcl 
                        ITKBasicFiltersTcl ITKNumericsTcl ITKCommonTcl SwigRuntimeTcl ${TCL_LIBRARY})
  INSTALL_TARGETS(/lib/InsightToolkit ITKAlgorithmsTcl)
ENDIF(ITK_CSWIG_TCL)

IF(ITK_CSWIG_PYTHON)
  ADD_LIBRARY(_ITKAlgorithmsPython MODULE ${WRAP_PYTHON_SOURCES})
  IF(ITK_PYTHON_NEEDS_DEPENDS)
    ADD_DEPENDENCIES(_ITKAlgorithmsPython _ITKNumericsPython _ITKCommonPython _ITKBasicFiltersPython )
  ENDIF(ITK_PYTHON_NEEDS_DEPENDS)
  SET_TARGET_PROPERTIES( _ITKAlgorithmsPython PROPERTIES PREFIX "")
  TARGET_LINK_LIBRARIES(_ITKAlgorithmsPython ITKAlgorithms SwigRuntimePython ${PYTHON_LIBRARY})
  INSTALL_TARGETS(/lib/InsightToolkit _ITKAlgorithmsPython)
ENDIF(ITK_CSWIG_PYTHON)

CONFIGURE_FILE(
${WrapITK_SOURCE_DIR}/Master.mdx.in
${WrapITK_BINARY_DIR}/Algorithms/ITKAlgorithms.mdx IMMEDIATE
)

SET(MASTER_INDEX_FILES "${WrapITK_BINARY_DIR}/VXLNumerics/VXLNumericsTcl.mdx"
                       "${WrapITK_BINARY_DIR}/Numerics/ITKNumericsTcl.mdx"
                       "${WrapITK_BINARY_DIR}/Common/ITKCommonTcl.mdx"
                       "${WrapITK_BINARY_DIR}/BasicFilters/ITKBasicFilters.mdx"
                       "${WrapITK_BINARY_DIR}/Algorithms/ITKAlgorithms.mdx"
)

FOREACH(Source ${WRAP_SOURCES})
  IF(ITK_CSWIG_TCL) 
     WRAP_TCL_SOURCES(${ITK_TOP}/Wrapping/CSwig/Algorithms ${WrapITK_BINARY_DIR}/Algorithms
                     ${Source} ITKAlgorithmsTcl "${MASTER_INDEX_FILES}" "${ALL_IDX_FILES}")
  ENDIF(ITK_CSWIG_TCL)
  IF(ITK_CSWIG_PYTHON)
    WRAP_PYTHON_SOURCES(${ITK_TOP}/Wrapping/CSwig/Algorithms ${WrapITK_BINARY_DIR}/Algorithms
                        ${Source} _ITKAlgorithmsPython "${MASTER_INDEX_FILES}" "${ALL_IDX_FILES}")
  ENDIF(ITK_CSWIG_PYTHON)
ENDFOREACH(Source)

IF(ITK_CSWIG_TCL)
  WRAP_TCL_SOURCES(${ITK_TOP}/Wrapping/CSwig/Algorithms ${WrapITK_BINARY_DIR}/Algorithms
                   wrap_ITKAlgorithmsTcl ITKAlgorithmsTcl "${MASTER_INDEX_FILES}" "${ALL_IDX_FILES}")
ENDIF(ITK_CSWIG_TCL)
   
IF(ITK_CSWIG_PYTHON)
  WRAP_PYTHON_SOURCES(${ITK_TOP}/Wrapping/CSwig/Algorithms ${WrapITK_BINARY_DIR}/Algorithms
                      wrap_ITKAlgorithmsPython _ITKAlgorithmsPython "${MASTER_INDEX_FILES}" "${ALL_IDX_FILES}")
ENDIF(ITK_CSWIG_PYTHON)

--------------020306000500070505010400
Content-Type: text/plain;
 name="wrap_ITKAlgorithms.cxx"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="wrap_ITKAlgorithms.cxx"

/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    $RCSfile: wrap_ITKAlgorithms.cxx,v $
  Language:  C++
  Date:      $Date: 2003/10/14 17:59:55 $
  Version:   $Revision: 1.6 $

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www . itk . org/HTML/Copyright . htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifdef CABLE_CONFIGURATION
#include "itkCSwigMacros.h"

namespace _cable_
{
  const char* const package = ITK_WRAP_PACKAGE_NAME(ITK_WRAP_PACKAGE);
  const char* const groups[] =
  {
    ITK_WRAP_GROUP(itkCurvatureFlowImageFilter),
    ITK_WRAP_GROUP(itkHistogramMatchingImageFilter),
    ITK_WRAP_GROUP(itkImageRegistrationMethod),
    ITK_WRAP_GROUP(itkImageToImageMetric),
    ITK_WRAP_GROUP(itkMattesMutualInformationImageToImageMetric),
    ITK_WRAP_GROUP(itkMeanSquaresImageToImageMetric),
    ITK_WRAP_GROUP(itkMutualInformationImageToImageMetric),
    ITK_WRAP_GROUP(itkMultiResolutionImageRegistrationMethod),
    ITK_WRAP_GROUP(itkNormalizedCorrelationImageToImageMetric),
    ITK_WRAP_GROUP(itkOtsuThresholdImageCalculator),
    ITK_WRAP_GROUP(itkMeanReciprocalSquareDifferenceImageToImageMetric),
    ITK_WRAP_GROUP(itkSimpleFuzzyConnectednessImageFilterBase),
    ITK_WRAP_GROUP(itkSimpleFuzzyConnectednessScalarImageFilter),
    ITK_WRAP_GROUP(itkThresholdSegmentationLevelSetImageFilter),
    ITK_WRAP_GROUP(itkGeodesicActiveContourLevelSetImageFilter),
    ITK_WRAP_GROUP(itkShapeDetectionLevelSetImageFilter),
    ITK_WRAP_GROUP(itkCurvesLevelSetImageFilter),
    ITK_WRAP_GROUP(itkNarrowBandCurvesLevelSetImageFilter),
    ITK_WRAP_GROUP(itkRecursiveMultiResolutionPyramidImageFilter)
  };
}
#endif

--------------020306000500070505010400
Content-Type: text/plain;
 name="wrap_itkRecursiveMultiResolutionPyramidImageFilter.cxx"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="wrap_itkRecursiveMultiResolutionPyramidImageFilter.cxx"

/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    $RCSfile: wrap_itkRecursiveMultiResolutionPyramidImageFilter.cxx,v $
  Language:  C++
  Date:      $Date: 2003/10/14 17:59:55 $
  Version:   $Revision: 1.1 $

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www . itk . org/HTML/Copyright . htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "itkImage.h"
#include "itkRecursiveMultiResolutionPyramidImageFilter.h"

#ifdef CABLE_CONFIGURATION
#include "itkCSwigMacros.h"
#include "itkCSwigImages.h"

namespace _cable_
{
  const char* const group = ITK_WRAP_GROUP(itkRecursiveMultiResolutionPyramidImageFilter);
  namespace wrappers
  {
    ITK_WRAP_OBJECT2_WITH_SUPERCLASS(RecursiveMultiResolutionPyramidImageFilter, image::F2, image::F2,
                     itkRecursiveMultiResolutionPyramidImageFilterF2F2);
    ITK_WRAP_OBJECT2_WITH_SUPERCLASS(RecursiveMultiResolutionPyramidImageFilter, image::F3, image::F3,
                     itkRecursiveMultiResolutionPyramidImageFilterF3F3);
    ITK_WRAP_OBJECT2_WITH_SUPERCLASS(RecursiveMultiResolutionPyramidImageFilter, image::US2, image::US2,
                     itkRecursiveMultiResolutionPyramidImageFilterUS2US2);
    ITK_WRAP_OBJECT2_WITH_SUPERCLASS(RecursiveMultiResolutionPyramidImageFilter, image::US3, image::US3,
                     itkRecursiveMultiResolutionPyramidImageFilterUS3US3);
  }
}

#endif

--------------020306000500070505010400
Content-Type: text/plain;
 name="wrap_itkFixedArray.cxx"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="wrap_itkFixedArray.cxx"

/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    $RCSfile: wrap_itkFixedArray.cxx,v $
  Language:  C++
  Date:      $Date: 2003/09/10 14:30:12 $
  Version:   $Revision: 1.2 $

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www . itk . org/HTML/Copyright . htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "itkFixedArray.h"

#ifdef CABLE_CONFIGURATION
#include "itkCSwigMacros.h"
namespace _cable_
{
  const char* const group = ITK_WRAP_GROUP(itkFixedArray);
  namespace wrappers
  {
    typedef itk::FixedArray<double, 2 >::FixedArray itkFixedArrayD2;
    typedef itk::FixedArray<double, 3 >::FixedArray itkFixedArrayD3;
    typedef itk::FixedArray<unsigned int, 2 >::FixedArray itkFixedArrayUI2;
    typedef itk::FixedArray<unsigned int, 3 >::FixedArray itkFixedArrayUI3;
  }
}
#endif

--------------020306000500070505010400--