Mercurial > hg > orthanc-stone
changeset 1759:7428da2bb94d
merge
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 26 Apr 2021 20:43:00 +0200 |
parents | 4ee11b8773e2 (diff) b235999cad69 (current diff) |
children | e38b9875a969 |
files | Applications/Samples/build-wasm-samples.sh |
diffstat | 4 files changed, 28 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancStone/Sources/Loaders/DicomStructureSetLoader.cpp Mon Apr 26 15:51:09 2021 +0200 +++ b/OrthancStone/Sources/Loaders/DicomStructureSetLoader.cpp Mon Apr 26 20:43:00 2021 +0200 @@ -149,7 +149,7 @@ } const std::string msgStr = msg.str(); LOG(ERROR) << msgStr; - throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadJson); } const std::string instanceId = lookup[0]["ID"].asString();
--- a/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp Mon Apr 26 15:51:09 2021 +0200 +++ b/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp Mon Apr 26 20:43:00 2021 +0200 @@ -92,7 +92,7 @@ if (body.type() != Json::objectValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadJson, "JSON body should be an object value"); } std::unique_ptr<Orthanc::DicomMap> dicom(new Orthanc::DicomMap); @@ -269,7 +269,7 @@ template <typename T> void OrthancMultiframeVolumeLoader::CopyPixelDataAndComputeDistribution( - const std::string& pixelData, std::map<T,uint64_t>& distribution) + const std::string& pixelData, std::map<T, PixelCount>& distribution) { #if STONE_TIME_BLOCKING_OPS boost::posix_time::ptime timerStart = boost::posix_time::microsec_clock::universal_time(); @@ -294,6 +294,7 @@ } // first pass to initialize map +#if 0 { const uint8_t* source = reinterpret_cast<const uint8_t*>(pixelData.c_str()); @@ -311,6 +312,7 @@ } } } +#endif { const uint8_t* source = reinterpret_cast<const uint8_t*>(pixelData.c_str()); @@ -351,7 +353,7 @@ { CopyPixel(*targetAddrPix, source); - distribution[*targetAddrPix] += 1; + distribution[*targetAddrPix].count_ += 1; targetAddrPix++; source += bpp; @@ -372,7 +374,7 @@ template <typename T> void OrthancMultiframeVolumeLoader::ComputeMinMaxWithOutlierRejection( - const std::map<T, uint64_t>& distribution) + const std::map<T, PixelCount>& distribution) { if (distribution.size() == 0) { @@ -391,15 +393,14 @@ // compute number of values and check (assertion) that it is equal to // width * height * depth { - typename std::map<T, uint64_t>::const_iterator it = distribution.begin(); + typename std::map<T, PixelCount>::const_iterator it = distribution.begin(); uint64_t totalCount = 0; distributionRawMin_ = static_cast<float>(it->first); while (it != distribution.end()) { T pixelValue = it->first; - uint64_t count = it->second; - totalCount += count; + totalCount += it->second.count_; ++it; if (it == distribution.end()) distributionRawMax_ = static_cast<float>(pixelValue); @@ -436,14 +437,14 @@ // then start from start and remove pixel values up to // endRejectionCount voxels rejected { - typename std::map<T, uint64_t>::const_iterator it = distribution.begin(); + typename std::map<T, PixelCount>::const_iterator it = distribution.begin(); uint64_t currentCount = 0; while (it != distribution.end()) { T pixelValue = it->first; - uint64_t count = it->second; + uint64_t count = it->second.count_; // if this pixelValue crosses the rejection threshold, let's set it // and exit the loop @@ -468,14 +469,14 @@ // now start from END and remove pixel values up to // endRejectionCount voxels rejected { - typename std::map<T, uint64_t>::const_reverse_iterator it = distribution.rbegin(); + typename std::map<T, PixelCount>::const_reverse_iterator it = distribution.rbegin(); uint64_t currentCount = 0; while (it != distribution.rend()) { T pixelValue = it->first; - uint64_t count = it->second; + uint64_t count = it->second.count_; if ((currentCount <= endRejectionCount) && (currentCount + count > endRejectionCount)) @@ -506,7 +507,7 @@ void OrthancMultiframeVolumeLoader::CopyPixelDataAndComputeMinMax( const std::string& pixelData) { - std::map<T, uint64_t> distribution; + std::map<T, PixelCount> distribution; CopyPixelDataAndComputeDistribution(pixelData, distribution); ComputeMinMaxWithOutlierRejection(distribution); }
--- a/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.h Mon Apr 26 15:51:09 2021 +0200 +++ b/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.h Mon Apr 26 20:43:00 2021 +0200 @@ -41,6 +41,12 @@ class LoadTransferSyntax; class LoadUncompressedPixelData; + struct PixelCount + { + uint64_t count_; + PixelCount() { count_ = 0; } + }; + boost::shared_ptr<DicomVolumeImage> volume_; std::string instanceId_; std::string transferSyntaxUid_; @@ -81,11 +87,11 @@ /** Service method for CopyPixelDataAndComputeMinMax*/ template <typename T> void CopyPixelDataAndComputeDistribution(const std::string& pixelData, - std::map<T, uint64_t>& distribution); + std::map<T, PixelCount>& distribution); /** Service method for CopyPixelDataAndComputeMinMax*/ template <typename T> - void ComputeMinMaxWithOutlierRejection(const std::map<T, uint64_t>& distribution); + void ComputeMinMaxWithOutlierRejection(const std::map<T, PixelCount>& distribution); void SetUncompressedPixelData(const std::string& pixelData);
--- a/OrthancStone/Sources/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Mon Apr 26 15:51:09 2021 +0200 +++ b/OrthancStone/Sources/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Mon Apr 26 20:43:00 2021 +0200 @@ -350,7 +350,7 @@ if (body.type() != Json::objectValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadJson, "JSON body should be an object value"); } { @@ -574,11 +574,11 @@ OrthancSeriesVolumeProgressiveLoader::~OrthancSeriesVolumeProgressiveLoader() { LOG(TRACE) << "OrthancSeriesVolumeProgressiveLoader::~OrthancSeriesVolumeProgressiveLoader()"; - } - - void OrthancSeriesVolumeProgressiveLoader::SetStartCenter(bool startCenter) - { - startCenter_ = startCenter; + } + + void OrthancSeriesVolumeProgressiveLoader::SetStartCenter(bool startCenter) + { + startCenter_ = startCenter; } void OrthancSeriesVolumeProgressiveLoader::SetSimultaneousDownloads(unsigned int count)