Skip to content

Commit

Permalink
BUG: fix wrappings for 1D and double
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Rit committed Apr 16, 2020
1 parent 72ed4df commit b36a044
Show file tree
Hide file tree
Showing 16 changed files with 157 additions and 200 deletions.
2 changes: 1 addition & 1 deletion wrapping/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(WRAPPER_SUBMODULE_ORDER
itkVectorRTK
itkCovariantVectorRTK
itkPointRTK
#itkContinuousIndexRTK
itkContinuousIndexRTK
itkMatrixRTK
itkVariableLengthVectorRTK
itkImageBaseRTK
Expand Down
17 changes: 0 additions & 17 deletions wrapping/itkContinuousIndexRTK.nowrap

This file was deleted.

6 changes: 6 additions & 0 deletions wrapping/itkContinuousIndexRTK.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
itk_wrap_class("itk::ContinuousIndex")
itk_wrap_template("${ITKM_D}1" "double, 1")
itk_end_wrap_class()
endif()
21 changes: 6 additions & 15 deletions wrapping/itkCovariantVectorRTK.wrap
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
itk_wrap_class("itk::CovariantVector")
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
itk_wrap_class("itk::CovariantVector")
itk_wrap_template("${ITKM_D}1" "${ITKT_D}, 1")
itk_end_wrap_class()
endif()

# Wrap ITK double missing types
if (NOT ITK_WRAP_double)
itk_wrap_template("D1" "${ITKT_D}, 1")
endif()

# Wrap ITK dimension 1 missing types
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
if (ITK_WRAP_double)
itk_wrap_template("D1" "double, 1")
endif()
endif()

itk_end_wrap_class()
35 changes: 13 additions & 22 deletions wrapping/itkImageBaseRTK.wrap
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
itk_wrap_class("itk::ContinuousIndex")

# Wrap ITK double missing types
if (NOT ITK_WRAP_double)
itk_wrap_template("${ITKM_D}1" "${ITKT_D}, 1")
endif()

# Wrap ITK dimension 1 missing types
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
if (ITK_WRAP_double)
itk_wrap_template("${ITKM_D}1" "double, 1")
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
itk_wrap_class("itk::ImageBase" POINTER)
# See ITK_DIR/Wrapping/Generators/Python/CMakeLists.txt to understand the next 3 lines
set(ITK_WRAP_PYTHON_SWIG_EXT "${ITK_WRAP_PYTHON_SWIG_EXT}%inline %{\n")
set(ITK_WRAP_PYTHON_SWIG_EXT "${ITK_WRAP_PYTHON_SWIG_EXT}#include \"itkContinuousIndexRTKSwigInterface.h\"\n")
set(ITK_WRAP_PYTHON_SWIG_EXT "${ITK_WRAP_PYTHON_SWIG_EXT}%}\n")

list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
itk_wrap_template("1" "1")
endif()
endif()

itk_end_wrap_class()
itk_wrap_class("itk::ImageBase" POINTER)

list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
itk_wrap_template("1" "1")
endif()
itk_end_wrap_class()
endif()

itk_end_wrap_class()
23 changes: 12 additions & 11 deletions wrapping/itkImageDuplicatorRTK.wrap
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
itk_wrap_class("itk::ImageDuplicator" POINTER)
# Making sure that all types wrapped in PyBuffer are also wrapped for ImageDuplicator
# as this filter is used in the Python NumPy bridge.
UNIQUE(types "D;UC;US;${WRAP_ITK_REAL}")
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
foreach(t ${types})
if (${_index} EQUAL -1)
itk_wrap_template("I${ITKM_${t}}1" "itk::Image<${ITKT_${t}}, 1>")
endif()
endforeach()
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
itk_wrap_class("itk::ImageDuplicator" POINTER)
# Making sure that all types wrapped in PyBuffer are also wrapped for ImageDuplicator
# as this filter is used in the Python NumPy bridge.
UNIQUE(types "D;UC;US;${WRAP_ITK_REAL}")
foreach(t ${types})
itk_wrap_template("I${ITKM_${t}}1" "itk::Image<${ITKT_${t}}, 1>")
endforeach()

itk_end_wrap_class()
endif()

itk_end_wrap_class()
48 changes: 18 additions & 30 deletions wrapping/itkImageRTK.wrap
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
itk_wrap_class("itk::Image" POINTER)

# Wrap ITK double missing types
if (NOT ITK_WRAP_double)
itk_wrap_template("D1" "${ITKT_D}, 1")
endif()

# Wrap ITK unsigned char missing types
if (NOT ITK_WRAP_unsigned_char)
itk_wrap_template("UC1" "${ITKT_UC}, 1")
endif()

# Wrap ITK unsigned short missing types
if (NOT ITK_WRAP_unsigned_short)
itk_wrap_template("US1" "${ITKT_US}, 1")
itk_wrap_template("US2" "${ITKT_US}, 2")
itk_wrap_template("US3" "${ITKT_US}, 3")
itk_wrap_template("US4" "${ITKT_US}, 4")
endif()
foreach(d 1 2 3 4)
list(FIND ITK_WRAP_IMAGE_DIMS ${d} _index)
if (${_index} EQUAL -1 OR NOT ITK_WRAP_unsigned_short)
itk_wrap_template("US${d}" "${ITKT_US}, ${d}")
endif()
endforeach()

# Wrap ITK unsigned int missing types
itk_wrap_template("UI2" "${ITKT_UI}, 2")
itk_wrap_template("UI3" "${ITKT_UI}, 3")

# Wrap ITK short combination (required by : rtkLookupTableImageFilter)
# Wrap ITK short combination (required by: rtkLookupTableImageFilter)
if (NOT ITK_WRAP_signed_short)
itk_wrap_template("SS3" "${ITKT_SS}, 3")
endif()

# Wrap ITK dimension 1 missing types
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
if (${_index} EQUAL -1 OR NOT ITK_WRAP_unsigned_char)
itk_wrap_template("UC1" "${ITKT_UC}, 1")
endif()
if (${_index} EQUAL -1 OR NOT ITK_WRAP_float)
itk_wrap_template("F1" "${ITKT_F}, 1")
if (ITK_WRAP_double)
itk_wrap_template("D1" "${ITKT_D}, 1")
endif()
if (ITK_WRAP_unsigned_char)
itk_wrap_template("UC1" "${ITKT_UC}, 1")
endif()
if (ITK_WRAP_unsigned_short)
itk_wrap_template("US1" "${ITKT_US}, 1")
endif()
endif()
if (${_index} EQUAL -1)
itk_wrap_template("D1" "${ITKT_D}, 1")
endif()

# Wrap ITK dimension 4 missing types
Expand All @@ -45,9 +36,6 @@ itk_wrap_class("itk::Image" POINTER)
if (ITK_WRAP_double)
itk_wrap_template("D4" "${ITKT_D}, 4")
endif()
if (ITK_WRAP_unsigned_short)
itk_wrap_template("US4" "${ITKT_US}, 4")
endif()
endif()

# Force ITK_WRAP_IMAGE_DIMS to contain "2;3;4"
Expand Down
11 changes: 6 additions & 5 deletions wrapping/itkImageRegionRTK.wrap
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
itk_wrap_class("itk::ImageRegion")
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
itk_wrap_class("itk::ImageRegion")
itk_wrap_template(1 1)
endif()
itk_end_wrap_class()
itk_end_wrap_class()
endif()

48 changes: 26 additions & 22 deletions wrapping/itkImageToImageFilterRTK.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ itk_wrap_class("itk::ImageToImageFilter" POINTER)
itk_wrap_template("ID3ID2" "itk::Image<${ITKT_D}, 3>, itk::Image<${ITKT_D}, 2>")
endif()

# Wrap ITK dimension 1 missing types
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
itk_wrap_template("IF1IF1" "itk::Image<${ITKT_F}, 1>, itk::Image<${ITKT_F}, 1>")
if (ITK_WRAP_double)
itk_wrap_template("ID1ID1" "itk::Image<${ITKT_D}, 1>, itk::Image<${ITKT_D}, 1>")
endif()
endif()

# Wrap ITK unsigned short missing types
if (NOT ITK_WRAP_unsigned_short)
itk_wrap_template("IUS2IUS2" "itk::Image<${ITKT_US}, 2>, itk::Image<${ITKT_US}, 2>")
Expand All @@ -14,18 +23,22 @@ itk_wrap_class("itk::ImageToImageFilter" POINTER)

# Wrap ITK unsigned short combination (required by : rtkLookupTableImageFilter)
if (NOT ITK_WRAP_unsigned_short)
if (NOT ITK_WRAP_double)
itk_wrap_template("IUS3ID3" "itk::Image<${ITKT_US}, 3>, itk::Image<${ITKT_D}, 3>")
endif()
itk_wrap_template("IUS4IF4" "itk::Image<${ITKT_US}, 4>, itk::Image<${ITKT_F}, 4>")
itk_wrap_template("IUS3IF3" "itk::Image<${ITKT_US}, 3>, itk::Image<${ITKT_F}, 3>")
itk_wrap_template("IUS2IF2" "itk::Image<${ITKT_US}, 2>, itk::Image<${ITKT_F}, 2>")
foreach(t ${WRAP_ITK_REAL})
itk_wrap_template("IUS2I${ITKM_${t}}2" "itk::Image<${ITKT_US}, 2>, itk::Image<${ITKT_${t}}, 2>")
itk_wrap_template("IUS3I${ITKM_${t}}3" "itk::Image<${ITKT_US}, 3>, itk::Image<${ITKT_${t}}, 3>")
endforeach()
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (NOT ${_index} EQUAL -1)
itk_wrap_template("IUS1IF1" "itk::Image<${ITKT_US}, 1>, itk::Image<${ITKT_F}, 1>")
endif()
endif()

# Wrap ITK unsigned int missing types
foreach(t ${WRAP_ITK_REAL})
itk_wrap_template("IUI2I${ITKM_${t}}2" "itk::Image<${ITKT_UI}, 2>, itk::Image<${ITKT_${t}}, 2>")
itk_wrap_template("IUI3I${ITKM_${t}}3" "itk::Image<${ITKT_UI}, 3>, itk::Image<${ITKT_${t}}, 3>")
endforeach()

# Wrap ITK short combination (required by : rtkLookupTableImageFilter)
if (NOT ITK_WRAP_signed_short)
itk_wrap_template("ISS3IF3" "itk::Image<${ITKT_SS}, 3>, itk::Image<${ITKT_F}, 3>")
Expand All @@ -34,15 +47,6 @@ itk_wrap_class("itk::ImageToImageFilter" POINTER)
# Wrap ITK real type combination
itk_wrap_template("IF3ID2" "itk::Image<${ITKT_F}, 3>, itk::Image<${ITKT_D}, 2>")

# Wrap ITK dimension 1 missing types
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
itk_wrap_template("IF1IF1" "itk::Image<${ITKT_F}, 1>, itk::Image<${ITKT_F}, 1>")
if (ITK_WRAP_double)
itk_wrap_template("ID1ID1" "itk::Image<${ITKT_D}, 1>, itk::Image<${ITKT_D}, 1>")
endif()
endif()

# Wrap ITK dimension 4 missing types
list(FIND ITK_WRAP_IMAGE_DIMS "4" _index)
if (${_index} EQUAL -1)
Expand Down Expand Up @@ -81,21 +85,18 @@ itk_wrap_class("itk::ImageToImageFilter" POINTER)

endif()


# Force ITK_WRAP_IMAGE_DIMS to contain "2;3;4"
UNIQUE(imageDimensions "${ITK_WRAP_IMAGE_DIMS};2;3;4")
set(vectorComponents 2 3 4 5)
foreach(component ${vectorComponents})
list(FIND ITK_WRAP_VECTOR_COMPONENTS "${component}" _index)
if (${_index} EQUAL -1)

foreach(vt ${WRAP_ITK_VECTOR_REAL})
if (${_index} EQUAL -1)
foreach(vt ${WRAP_ITK_VECTOR_REAL})
foreach(d ${imageDimensions})
itk_wrap_template("I${ITKM_${vt}${component}}${d}I${ITKM_${vt}${component}}${d}"
"itk::Image<${ITKT_${vt}${component}}, ${d}>, itk::Image<${ITKT_${vt}${component}}, ${d}>")
endforeach()
endforeach()

endforeach()
endif()
endforeach()

Expand Down Expand Up @@ -136,8 +137,11 @@ itk_wrap_class("itk::ImageToImageFilter" POINTER)

endif()

list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
foreach(t ${WRAP_ITK_REAL})
itk_wrap_template("I${ITKM_${t}}2I${ITKM_${t}}1" "itk::Image<${ITKT_${t}}, 2>, itk::Image<${ITKT_${t}}, 1>")
if (${_index} EQUAL -1)
itk_wrap_template("I${ITKM_${t}}2I${ITKM_${t}}1" "itk::Image<${ITKT_${t}}, 2>, itk::Image<${ITKT_${t}}, 1>")
endif()
itk_wrap_template("I${ITKM_${t}}3VI${ITKM_${t}}2" "itk::Image<${ITKT_${t}}, 3>, itk::VectorImage<${ITKT_${t}}, 2>")
itk_wrap_template("VI${ITKM_${t}}2I${ITKM_${t}}3" "itk::VectorImage<${ITKT_${t}}, 2>, itk::Image<${ITKT_${t}}, 3>")
itk_wrap_template("VI${ITKM_${t}}3I${ITKM_${t}}4" "itk::VectorImage<${ITKT_${t}}, 3>, itk::Image<${ITKT_${t}}, 4>")
Expand Down
17 changes: 11 additions & 6 deletions wrapping/itkInPlaceImageFilterRTK.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,28 @@ itk_wrap_class("itk::InPlaceImageFilter" POINTER)

# Wrap ITK unsigned short missing types
if (NOT ITK_WRAP_unsigned_short)
itk_wrap_template("IUS2IUS2" "itk::Image<${ITKT_US}, 2>, itk::Image<${ITKT_US}, 2>")
itk_wrap_template("IUS3IUS3" "itk::Image<${ITKT_US}, 3>, itk::Image<${ITKT_US}, 3>")
endif()

# Wrap ITK unsigned short combination (required by : rtkLookupTableImageFilter)
if (NOT ITK_WRAP_unsigned_short)
if (NOT ITK_WRAP_double)
itk_wrap_template("IUS3ID3" "itk::Image<${ITKT_US}, 3>, itk::Image<${ITKT_D}, 3>")
endif()
itk_wrap_template("IUS4IF4" "itk::Image<${ITKT_US}, 4>, itk::Image<${ITKT_F}, 4>")
itk_wrap_template("IUS3IF3" "itk::Image<${ITKT_US}, 3>, itk::Image<${ITKT_F}, 3>")
itk_wrap_template("IUS2IF2" "itk::Image<${ITKT_US}, 2>, itk::Image<${ITKT_F}, 2>")
foreach(t ${WRAP_ITK_REAL})
itk_wrap_template("IUS2I${ITKM_${t}}2" "itk::Image<${ITKT_US}, 2>, itk::Image<${ITKT_${t}}, 2>")
itk_wrap_template("IUS3I${ITKM_${t}}3" "itk::Image<${ITKT_US}, 3>, itk::Image<${ITKT_${t}}, 3>")
endforeach()
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (NOT ${_index} EQUAL -1)
itk_wrap_template("IUS1IF1" "itk::Image<${ITKT_US}, 1>, itk::Image<${ITKT_F}, 1>")
endif()
endif()

# Wrap ITK unsigned int missing types
foreach(t ${WRAP_ITK_REAL})
itk_wrap_template("IUI2I${ITKM_${t}}2" "itk::Image<${ITKT_UI}, 2>, itk::Image<${ITKT_${t}}, 2>")
itk_wrap_template("IUI3I${ITKM_${t}}3" "itk::Image<${ITKT_UI}, 3>, itk::Image<${ITKT_${t}}, 3>")
endforeach()

# Wrap ITK short combination (required by : rtkLookupTableImageFilter)
if (NOT ITK_WRAP_signed_short)
itk_wrap_template("ISS3IF3" "itk::Image<${ITKT_SS}, 3>, itk::Image<${ITKT_F}, 3>")
Expand Down
21 changes: 6 additions & 15 deletions wrapping/itkMatrixRTK.wrap
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
itk_wrap_class("itk::Matrix")
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
itk_wrap_class("itk::Matrix")
itk_wrap_template("${ITKM_D}11" "${ITKT_D}, 1, 1")
itk_end_wrap_class()
endif()

# Wrap ITK double missing types --
if (NOT ITK_WRAP_double)
itk_wrap_template("D11" "${ITKT_D}, 1, 1")
endif()

# Wrap ITK dimension 1 missing types
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
if (ITK_WRAP_double)
itk_wrap_template("D11" "${ITKT_D}, 1, 1")
endif()
endif()

itk_end_wrap_class()
17 changes: 6 additions & 11 deletions wrapping/itkPointRTK.wrap
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
itk_wrap_class("itk::Point")
if (NOT ITK_WRAP_double)
itk_wrap_template("D1" "${ITKT_D}, 1")
endif()
list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
itk_wrap_class("itk::Point")
itk_wrap_template("${ITKM_D}1" "${ITKT_D}, 1")
itk_end_wrap_class()
endif()

list(FIND ITK_WRAP_IMAGE_DIMS "1" _index)
if (${_index} EQUAL -1)
if (ITK_WRAP_double)
itk_wrap_template("D1" "double, 1")
endif()
endif()
itk_end_wrap_class()
9 changes: 6 additions & 3 deletions wrapping/rtkDaubechiesWaveletsDenoiseSequenceImageFilter.wrap
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
itk_wrap_class("rtk::DaubechiesWaveletsDenoiseSequenceImageFilter" POINTER)
itk_wrap_image_filter("${WRAP_ITK_REAL}" 1 4)
itk_end_wrap_class()
list(FIND ITK_WRAP_IMAGE_DIMS "4" _index)
if (NOT ${_index} EQUAL -1)
itk_wrap_class("rtk::DaubechiesWaveletsDenoiseSequenceImageFilter" POINTER)
itk_wrap_image_filter("${WRAP_ITK_REAL}" 1 4)
itk_end_wrap_class()
endif()
4 changes: 3 additions & 1 deletion wrapping/rtkElektaSynergyRawLookupTableImageFilter.wrap
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
itk_wrap_class("rtk::ElektaSynergyRawLookupTableImageFilter" POINTER)
itk_wrap_image_filter("${US}" 2 2+)
foreach(d 2 3)
itk_wrap_template("IUS${d}IUS${d}" "itk::Image<${ITKT_US}, ${d}>, itk::Image<${ITKT_US}, ${d}>")
endforeach()
itk_end_wrap_class()
Loading

0 comments on commit b36a044

Please sign in to comment.