diff --git a/CMakeLists.txt b/CMakeLists.txt index 417e902..12ccd17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules" ${CMAKE_MODULE_PATH}) project ("warpaffine" - VERSION 0.4.0 + VERSION 0.5.0 DESCRIPTION "experimental Deskew operation") option(WARPAFFINE_BUILD_CLANGTIDY "Build with Clang-Tidy" OFF) diff --git a/documentation/version-history.md b/documentation/version-history.md index 4482dc3..71b121b 100644 --- a/documentation/version-history.md +++ b/documentation/version-history.md @@ -6,4 +6,5 @@ version history {#version_history} 0.3.0 | N/A | initial release 0.3.1 | [3](https://github.com/ZEISS/warpaffine/pull/3) | bugfix for a crash for "CZIs containing a single brick but have an S-index" 0.3.2 | [5](https://github.com/ZEISS/warpaffine/pull/5) | bugfix for a deadlock in rare case - 0.4.0 | [6](https://github.com/ZEISS/warpaffine/pull/6) | set re-tiling id of sub-blocks to allow for more sensible stitching of resulting CZI \ No newline at end of file + 0.4.0 | [6](https://github.com/ZEISS/warpaffine/pull/6) | set re-tiling id of sub-blocks to allow for more sensible stitching of resulting CZI + 0.5.0 | [7](https://github.com/ZEISS/warpaffine/pull/7) | copy attachments from source document \ No newline at end of file diff --git a/libwarpaffine/main.cpp b/libwarpaffine/main.cpp index cffc437..05c57fb 100644 --- a/libwarpaffine/main.cpp +++ b/libwarpaffine/main.cpp @@ -481,6 +481,7 @@ int libmain(int argc, char** _argv) } auto reader_and_stream = CreateCziReader(app_context); + if (!get<0>(reader_and_stream) || !get<1>(reader_and_stream)) { return EXIT_FAILURE; @@ -494,6 +495,7 @@ int libmain(int argc, char** _argv) } auto writer = CreateCziWriter(app_context); + auto brick_source = CreateCziBrickSource(app_context, get<0>(reader_and_stream), get<1>(reader_and_stream)); auto warp_affine_engine = CreateWarpAffineEngine(app_context); @@ -533,6 +535,13 @@ int libmain(int argc, char** _argv) doWarp.DoOperation(); WaitUntilDone(app_context, doWarp); + get<0>(reader_and_stream)->EnumerateAttachments( + [&writer, &reader_and_stream](int index, const libCZI::AttachmentInfo& info) -> bool + { + writer->AddAttachment(get<0>(reader_and_stream)->ReadAttachment(index)); + return true; + }); + switch (const auto type_of_operation = app_context.GetCommandLineOptions().GetTypeOfOperation()) { case OperationType::Deskew: diff --git a/libwarpaffine/sliceswriter/ISlicesWriter.h b/libwarpaffine/sliceswriter/ISlicesWriter.h index f98c2ad..b7c3140 100644 --- a/libwarpaffine/sliceswriter/ISlicesWriter.h +++ b/libwarpaffine/sliceswriter/ISlicesWriter.h @@ -63,6 +63,10 @@ class ICziSlicesWriter /// Adds a slice (or subblock). /// \param add_slice_info Information describing the add slice. virtual void AddSlice(const AddSliceInfo& add_slice_info) = 0; + + /// Adds an attachment, i.e. a copy from a source document. + /// \param attachment The attachment to be added. + virtual void AddAttachment(const std::shared_ptr& attachment) = 0; /// Closes the output CZI-files. The specified metadata object (of the source document) is used /// to update the metadata of the output CZI-file. diff --git a/libwarpaffine/sliceswriter/NullSlicesWriter.cpp b/libwarpaffine/sliceswriter/NullSlicesWriter.cpp index fb122ac..f3793f8 100644 --- a/libwarpaffine/sliceswriter/NullSlicesWriter.cpp +++ b/libwarpaffine/sliceswriter/NullSlicesWriter.cpp @@ -17,6 +17,10 @@ void NullSlicesWriter::AddSlice(const AddSliceInfo& add_slice_info) { } +void NullSlicesWriter::AddAttachment(const std::shared_ptr& attachment) +{ +} + void NullSlicesWriter::Close(const std::shared_ptr&, const libCZI::ScalingInfo*, const std::function&) { } diff --git a/libwarpaffine/sliceswriter/NullSlicesWriter.h b/libwarpaffine/sliceswriter/NullSlicesWriter.h index 0dd137f..cd48273 100644 --- a/libwarpaffine/sliceswriter/NullSlicesWriter.h +++ b/libwarpaffine/sliceswriter/NullSlicesWriter.h @@ -14,6 +14,7 @@ class NullSlicesWriter : public ICziSlicesWriter public: std::uint32_t GetNumberOfPendingSliceWriteOperations() override; void AddSlice(const AddSliceInfo& add_slice_info) override; + void AddAttachment(const std::shared_ptr& attachment) override; void Close(const std::shared_ptr& source_metadata, const libCZI::ScalingInfo* new_scaling_info, const std::function& tweak_metadata_hook) override; diff --git a/libwarpaffine/sliceswriter/SlicesWriterTbb.cpp b/libwarpaffine/sliceswriter/SlicesWriterTbb.cpp index 9754ec9..471bf26 100644 --- a/libwarpaffine/sliceswriter/SlicesWriterTbb.cpp +++ b/libwarpaffine/sliceswriter/SlicesWriterTbb.cpp @@ -40,6 +40,20 @@ void CziSlicesWriterTbb::AddSlice(const AddSliceInfo& add_slice_info) ++this->number_of_slicewrite_operations_in_flight_; } +void CziSlicesWriterTbb::AddAttachment(const std::shared_ptr& attachment) +{ + AddAttachmentInfo add_attachment_info; + const auto& attachment_info = attachment->GetAttachmentInfo(); + add_attachment_info.contentGuid = attachment_info.contentGuid; + add_attachment_info.SetContentFileType(attachment_info.contentFileType); + add_attachment_info.SetName(attachment_info.name.c_str()); + size_t size_of_data; + auto raw_data = attachment->GetRawData(&size_of_data); + add_attachment_info.ptrData = raw_data.get(); + add_attachment_info.dataSize = static_cast(size_of_data); + this->writer_->SyncAddAttachment(add_attachment_info); +} + void CziSlicesWriterTbb::WriteWorker() { try diff --git a/libwarpaffine/sliceswriter/SlicesWriterTbb.h b/libwarpaffine/sliceswriter/SlicesWriterTbb.h index 09bef4e..7c11f7f 100644 --- a/libwarpaffine/sliceswriter/SlicesWriterTbb.h +++ b/libwarpaffine/sliceswriter/SlicesWriterTbb.h @@ -41,7 +41,7 @@ class CziSlicesWriterTbb : public ICziSlicesWriter std::uint32_t GetNumberOfPendingSliceWriteOperations() override; void AddSlice(const AddSliceInfo& add_slice_info) override; - + void AddAttachment(const std::shared_ptr& attachment) override; void Close(const std::shared_ptr& source_metadata, const libCZI::ScalingInfo* new_scaling_info, const std::function& tweak_metadata_hook) override;