From 19e0d130162dafe2a08bd3aa0e60e1e975555778 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Sun, 28 Jul 2024 14:09:58 -0400 Subject: [PATCH] STYLE: Factor out itkOMEZarrNGFFCommon.h For re-use across ImageIO and TransformIO. OMEZarrNGFFAxis is renamed to OMEZarrAxis for brevity. Also, what was previously ambigiously ome-zarr-ngff is now OME-Zarr. --- CMakeLists.txt | 3 +- include/itkOMEZarrNGFFCommon.h | 46 ++++++++++++++++++++++++++++++ include/itkOMEZarrNGFFImageIO.h | 20 +++---------- src/itkOMEZarrNGFFImageIO.cxx | 2 +- wrapping/CMakeLists.txt | 3 ++ wrapping/itkOMEZarrNGFFCommon.wrap | 4 +++ 6 files changed, 59 insertions(+), 19 deletions(-) create mode 100644 include/itkOMEZarrNGFFCommon.h create mode 100644 wrapping/itkOMEZarrNGFFCommon.wrap diff --git a/CMakeLists.txt b/CMakeLists.txt index 56351dd..d48ab5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,11 +8,10 @@ set(CMAKE_CXX_STANDARD 17) set_property(GLOBAL PROPERTY USE_FOLDERS ON) project(IOOMEZarrNGFF CXX C ASM_NASM ASM) - set(IOOMEZarrNGFF_LIBRARIES IOOMEZarrNGFF) if(NOT ITK_SOURCE_DIR) - find_package(ITK 5.0 REQUIRED) + find_package(ITK 5.4 REQUIRED) list(APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) include(ITKModuleExternal) diff --git a/include/itkOMEZarrNGFFCommon.h b/include/itkOMEZarrNGFFCommon.h new file mode 100644 index 0000000..1054ecf --- /dev/null +++ b/include/itkOMEZarrNGFFCommon.h @@ -0,0 +1,46 @@ +/*========================================================================= + * + * Copyright NumFOCUS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ + +#ifndef itkOMEZarrNGFFCommon_h +#define itkOMEZarrNGFFCommon_h +#include "IOOMEZarrNGFFExport.h" + + +#include + +namespace itk +{ +/** \class OMEZarrNGFFAxis + * + * \brief Represent an OME-Zarr NGFF axis + * + * Open Microscopy Environment Zarr Next Generation File Format + * specification can be found at https://github.com/ome/ngff + * + * \ingroup IOOMEZarrNGFF + */ +struct IOOMEZarrNGFF_EXPORT OMEZarrAxis +{ + std::string name; + std::string type; + std::string unit; +}; + +} // end namespace itk + +#endif // itkOMEZarrNGFFCommon_h diff --git a/include/itkOMEZarrNGFFImageIO.h b/include/itkOMEZarrNGFFImageIO.h index e31d541..b8e5e71 100644 --- a/include/itkOMEZarrNGFFImageIO.h +++ b/include/itkOMEZarrNGFFImageIO.h @@ -24,25 +24,13 @@ #include #include #include + #include "itkImageIOBase.h" +#include "itkOMEZarrNGFFCommon.h" + namespace itk { -/** \class OMEZarrNGFFAxis - * - * \brief Represent an OME-Zarr NGFF axis - * - * Open Microscopy Environment Zarr Next Generation File Format - * specification can be found at https://github.com/ome/ngff - * - * \ingroup IOOMEZarrNGFF - */ -struct IOOMEZarrNGFF_EXPORT OMEZarrNGFFAxis -{ - std::string name; - std::string type; - std::string unit; -}; /** \class OMEZarrNGFFImageIO * @@ -73,7 +61,7 @@ class IOOMEZarrNGFF_EXPORT OMEZarrNGFFImageIO : public ImageIOBase static constexpr unsigned MaximumDimension = 5; // OME-NGFF specifies up to 5D data static constexpr int INVALID_INDEX = -1; // for specifying enumerated axis slice indices - using AxesCollectionType = std::vector; + using AxesCollectionType = std::vector; /** The different types of ImageIO's can support data of varying * dimensionality. For example, some file formats are strictly 2D diff --git a/src/itkOMEZarrNGFFImageIO.cxx b/src/itkOMEZarrNGFFImageIO.cxx index 8dc9167..c63f99f 100644 --- a/src/itkOMEZarrNGFFImageIO.cxx +++ b/src/itkOMEZarrNGFFImageIO.cxx @@ -554,7 +554,7 @@ OMEZarrNGFFImageIO::ReadImageInformation() auto targetIt = m_StoreAxes.rbegin(); for (const auto & axis : json.at("axes")) { - *targetIt = (OMEZarrNGFFAxis{ axis.at("name"), axis.at("type"), (axis.contains("unit") ? axis.at("unit") : "") }); + *targetIt = (OMEZarrAxis{ axis.at("name"), axis.at("type"), (axis.contains("unit") ? axis.at("unit") : "") }); ++targetIt; } itkAssertOrThrowMacro(targetIt == m_StoreAxes.rend(), diff --git a/wrapping/CMakeLists.txt b/wrapping/CMakeLists.txt index b3eaae0..750e02b 100644 --- a/wrapping/CMakeLists.txt +++ b/wrapping/CMakeLists.txt @@ -1,3 +1,6 @@ itk_wrap_module(IOOMEZarrNGFF) +set(WRAPPER_SUBMODULE_ORDER + itkOMEZarrNGFFCommon +) itk_auto_load_submodules() itk_end_wrap_module() diff --git a/wrapping/itkOMEZarrNGFFCommon.wrap b/wrapping/itkOMEZarrNGFFCommon.wrap new file mode 100644 index 0000000..fd35ac9 --- /dev/null +++ b/wrapping/itkOMEZarrNGFFCommon.wrap @@ -0,0 +1,4 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) +itk_wrap_include("itkOMEZarrNGFFCommon.h") +itk_wrap_simple_class("itk::OMEZarrAxis") +set(WRAPPER_AUTO_INCLUDE_HEADERS ON) \ No newline at end of file