# HG changeset patch # User am@osimis.io # Date 1550223563 -3600 # Node ID 29fc066b6f65e7be3980ded0170f98888b7fbf17 # Parent 159a465e27bdd51c927d41f46893faed5cd838f7 Export now accepts Json::Value diff -r 159a465e27bd -r 29fc066b6f65 Framework/Radiography/RadiographyScene.cpp --- a/Framework/Radiography/RadiographyScene.cpp Thu Feb 14 16:23:59 2019 +0100 +++ b/Framework/Radiography/RadiographyScene.cpp Fri Feb 15 10:39:23 2019 +0100 @@ -587,10 +587,8 @@ } - // Export using PAM is faster than using PNG, but requires Orthanc - // core >= 1.4.3 void RadiographyScene::ExportDicom(OrthancApiClient& orthanc, - const Orthanc::DicomMap& dicom, + const Json::Value& dicomTags, const std::string& parentOrthancId, double pixelSpacingX, double pixelSpacingY, @@ -621,31 +619,17 @@ Orthanc::Toolbox::EncodeBase64(base64, content); } - std::set tags; - dicom.GetTags(tags); - - createDicomRequestContent["Tags"] = Json::objectValue; - - for (std::set::const_iterator - tag = tags.begin(); tag != tags.end(); ++tag) - { - const Orthanc::DicomValue& value = dicom.GetValue(*tag); - if (!value.IsNull() && - !value.IsBinary()) - { - createDicomRequestContent["Tags"][tag->Format()] = value.GetContent(); - } - } + createDicomRequestContent["Tags"] = dicomTags; PhotometricDisplayMode photometricMode = GetPreferredPhotomotricDisplayMode(); if ((invert && photometricMode != PhotometricDisplayMode_Monochrome2) || (!invert && photometricMode == PhotometricDisplayMode_Monochrome1)) { - createDicomRequestContent["Tags"][Orthanc::DICOM_TAG_PHOTOMETRIC_INTERPRETATION.Format()] = "MONOCHROME1"; + createDicomRequestContent["Tags"]["PhotometricInterpretation"] = "MONOCHROME1"; } else { - createDicomRequestContent["Tags"][Orthanc::DICOM_TAG_PHOTOMETRIC_INTERPRETATION.Format()] = "MONOCHROME2"; + createDicomRequestContent["Tags"]["PhotometricInterpretation"] = "MONOCHROME2"; } // WARNING: The order of PixelSpacing is Y/X. We use "%0.8f" to @@ -655,15 +639,15 @@ char buf[32]; sprintf(buf, "%0.8f\\%0.8f", pixelSpacingY, pixelSpacingX); - createDicomRequestContent["Tags"][Orthanc::DICOM_TAG_PIXEL_SPACING.Format()] = buf; + createDicomRequestContent["Tags"]["PixelSpacing"] = buf; float center, width; if (GetWindowing(center, width)) { - createDicomRequestContent["Tags"][Orthanc::DICOM_TAG_WINDOW_CENTER.Format()] = + createDicomRequestContent["Tags"]["WindowCenter"] = boost::lexical_cast(boost::math::iround(center)); - createDicomRequestContent["Tags"][Orthanc::DICOM_TAG_WINDOW_WIDTH.Format()] = + createDicomRequestContent["Tags"]["WindowWidth"] = boost::lexical_cast(boost::math::iround(width)); } @@ -683,6 +667,38 @@ new Callable (*this, &RadiographyScene::OnDicomExported), NULL, NULL); + + } + + + // Export using PAM is faster than using PNG, but requires Orthanc + // core >= 1.4.3 + void RadiographyScene::ExportDicom(OrthancApiClient& orthanc, + const Orthanc::DicomMap& dicom, + const std::string& parentOrthancId, + double pixelSpacingX, + double pixelSpacingY, + bool invert, + ImageInterpolation interpolation, + bool usePam) + { + std::set tags; + dicom.GetTags(tags); + + Json::Value jsonTags = Json::objectValue; + + for (std::set::const_iterator + tag = tags.begin(); tag != tags.end(); ++tag) + { + const Orthanc::DicomValue& value = dicom.GetValue(*tag); + if (!value.IsNull() && + !value.IsBinary()) + { + jsonTags[tag->Format()] = value.GetContent(); + } + } + + ExportDicom(orthanc, jsonTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, interpolation, usePam); } void RadiographyScene::OnDicomExported(const OrthancApiClient::JsonResponseReadyMessage& message) diff -r 159a465e27bd -r 29fc066b6f65 Framework/Radiography/RadiographyScene.h --- a/Framework/Radiography/RadiographyScene.h Thu Feb 14 16:23:59 2019 +0100 +++ b/Framework/Radiography/RadiographyScene.h Fri Feb 15 10:39:23 2019 +0100 @@ -204,6 +204,15 @@ ImageInterpolation interpolation, bool usePam); + void ExportDicom(OrthancApiClient& orthanc, + const Json::Value& dicomTags, + const std::string& parentOrthancId, + double pixelSpacingX, + double pixelSpacingY, + bool invert, + ImageInterpolation interpolation, + bool usePam); + Orthanc::Image* ExportToImage(double pixelSpacingX, double pixelSpacingY, ImageInterpolation interpolation)