# HG changeset patch # User Sebastien Jodogne # Date 1562928677 -7200 # Node ID d3aea0af03e1e80f59264f940ab0567ba2d0d836 # Parent 605247fc8758af7d9547a17b4c2273abd72e8495 attempt to fix issue 139 diff -r 605247fc8758 -r d3aea0af03e1 Applications/Dicomizer.cpp --- a/Applications/Dicomizer.cpp Fri Jul 12 12:00:31 2019 +0200 +++ b/Applications/Dicomizer.cpp Fri Jul 12 12:51:17 2019 +0200 @@ -390,6 +390,7 @@ { // Construct tag "Shared Functional Groups Sequence" (5200,9229) +#if 1 // In the 2 lines below, remember to switch X/Y when going from physical to pixel coordinates! float spacingX = volume.GetWidth() / static_cast(source.GetLevelHeight(0)); float spacingY = volume.GetHeight() / static_cast(source.GetLevelWidth(0)); @@ -420,6 +421,23 @@ { throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } +#else + std::auto_ptr item(new DcmItem); + + std::auto_ptr item3(new DcmItem); + OrthancWSI::DicomToolbox::SetStringTag(*item3, DCM_OpticalPathIdentifier, opticalPathId); + + std::auto_ptr sequence(new DcmSequenceOfItems(DCM_SharedFunctionalGroupsSequence)); + std::auto_ptr sequence3(new DcmSequenceOfItems(DCM_OpticalPathIdentificationSequence)); + + if (!sequence3->insert(item3.release(), false, false).good() || + !item->insert(sequence3.release(), false, false).good() || + !sequence->insert(item.release(), false, false).good() || + !dataset.insert(sequence.release(), true /* replace */, false).good()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } +#endif } } diff -r 605247fc8758 -r d3aea0af03e1 Framework/Outputs/DicomPyramidWriter.cpp --- a/Framework/Outputs/DicomPyramidWriter.cpp Fri Jul 12 12:00:31 2019 +0200 +++ b/Framework/Outputs/DicomPyramidWriter.cpp Fri Jul 12 12:51:17 2019 +0200 @@ -142,6 +142,44 @@ (dataset_, GetImageCompression(), GetPixelFormat(), level.width_, level.height_, GetTileWidth(), GetTileHeight(), photometric_); writers_[z] = writer; + +#if 0 + { + // Fix issue 139: The PixelSpacing information changes at each level + // https://bitbucket.org/sjodogne/orthanc/issues/139/orthancwsidicomizer-pixelspacing + + // In the 2 lines below, remember to switch X/Y when going from physical to pixel coordinates! + float spacingX = volume_.GetWidth() / static_cast(level.height_); + float spacingY = volume_.GetHeight() / static_cast(level.width_); + + std::string spacing = (boost::lexical_cast(spacingX) + '\\' + + boost::lexical_cast(spacingY)); + + std::auto_ptr item(new DcmItem); + + std::auto_ptr item2(new DcmItem); + OrthancWSI::DicomToolbox::SetStringTag(*item2, DCM_SliceThickness, + boost::lexical_cast(volume_.GetDepth())); + OrthancWSI::DicomToolbox::SetStringTag(*item2, DCM_PixelSpacing, spacing); + + std::auto_ptr sequence2(new DcmSequenceOfItems(DCM_PixelMeasuresSequence)); + if (!sequence2->insert(item2.release(), false, false).good()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } + + DcmSequenceOfItems* sequence = NULL; + if (!writer->GetSharedTags().findAndGetSequence(DCM_SharedFunctionalGroupsSequence, sequence).good() || + sequence == NULL || + sequence->card() != 1 || + sequence->getItem(0) == NULL || + !sequence->getItem(0)->insert(sequence2.release(), false, false).good()) + { + // This sequence should have been created by "SetupDimension()" in Dicomizer.cpp + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } + } +#endif } std::auto_ptr functionalGroup(CreateFunctionalGroup(writer->GetFramesCount() + 1, diff -r 605247fc8758 -r d3aea0af03e1 Framework/Outputs/MultiframeDicomWriter.h --- a/Framework/Outputs/MultiframeDicomWriter.h Fri Jul 12 12:00:31 2019 +0200 +++ b/Framework/Outputs/MultiframeDicomWriter.h Fri Jul 12 12:51:17 2019 +0200 @@ -91,5 +91,10 @@ { return height_; } + + DcmDataset& GetSharedTags() + { + return sharedTags_; + } }; }