# itkimage component just needs to use the component_extension macro
camitk_extension(COMPONENT_EXTENSION 
                 NEEDS_ITK
                 CEP_NAME CEP_IMAGING
                 CXX_FLAGS "-w"
                 DEFINES _SCL_SECURE_NO_WARNINGS # to remove Windows MSVC warnings
                 DESCRIPTION "This component allows CamiTK to handle basic ITK format images."
                 ENABLE_AUTO_TEST
)

# --------------------------------
# --- Specific test management ---
# --------------------------------

camitk_disable_tests(TESTS component-itkimage-level3-9 
                           component-itkimage-level3-10
                     REASON "Test failure due to ITK error during save.
  ITK 5.3.0 generates an error when trying to save the files biorad.pic and 
  cthead1.lsm
  For now disable these tests until this can be dealt with (if possible)
  in the save() method."
)

camitk_disable_tests(TESTS component-itkimage-level3-3 
                     REASON "Test failure due to change of parameter during save.
  ITK 5.3.0 modifies the stimFileName parameter of the header BigEndian.spr
  The test always fails because of the change in stimFileName."
)


# TODO confirm diagnostic: check why BigEndianCompressed.img.gz, LittleEndianCompressed.img.gz and minimal.nii.gz does not work on Windows (maybe because of double suffix .im.gz?)
camitk_tests_requirement(TESTS component-itkimage-level3-6 
                               component-itkimage-level3-16 
                               component-itkimage-level3-28
                         REQUIRES "NOT WIN32"
                         REASON "WIN32 failure (probably) due to double suffix .im.gz or .nii.gz
  For input file: BigEndianCompressed.img.gz, LittleEndianCompressed.img.gz 
  and minimal.nii.gz"
)


camitk_tests_requirement(TESTS component-itkimage-level3-19 
                               component-itkimage-level3-20
                         REQUIRES "NOT WIN32"
                         REASON "Test failure on Windows.
  ITK 5.3.0 does not save the exact same data on Windows for images 
  LittleEndianZ.hdr and LittleEndianZ.img.gz.
  For now disable these tests on Windows until this can be dealt with 
  (if possible)."
)

camitk_tests_requirement(TESTS component-itkimage-level3-1
                               component-itkimage-level3-4
                               component-itkimage-level3-7
                               component-itkimage-level3-11
                               component-itkimage-level3-13
                               component-itkimage-level3-15
                               component-itkimage-level3-17
                               component-itkimage-level3-19
                               component-itkimage-level3-21
                               component-itkimage-level3-28
                         REQUIRES "${ITK_VERSION} VERSION_EQUAL 5.3.0"
                         REASON "Requires ITK version 5.3.0
   The default test files are written using the currently supported version
   of ITK (ITK 5.3.0).
   This test might therefore fail when comparing the input to the output 
   if another version of ITK is used."
)

# Additional test for SDK actions: this will add auto test for the given actions using the itkimage component
camitk_additional_action_test(ACTION_EXTENSIONS crop-image imagelut imageresampling multipicking pixelcolorchanger reconstruction reorientimage showin3d volumerendering
                              TEST_FILES BigEndian.hdr BigEndian.img BigEndianCompressed1.hdr BigEndianCompressed1.img biorad.pic cthead1.lsm LittleEndian1.hdr LittleEndian1.img LittleEndianCompressed1.hdr LittleEndianCompressed1.img LittleEndianZ1.hdr mini-complex-slow1.nrrd mini-ten-nomask-slow1.nrrd mini-vector-slow1.nrrd ramp1.gipl
)
