# HG changeset patch # User Benjamin Golinvaux # Date 1619462580 -7200 # Node ID 7428da2bb94dc8dc98137c623e824d4eaa1dfe8a # Parent 4ee11b8773e21a3531130a5feef609bbbffd8866# Parent b235999cad695cf389327ab942708ef38861bf71 merge diff -r b235999cad69 -r 7428da2bb94d OrthancStone/Sources/Loaders/DicomStructureSetLoader.cpp --- 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(); diff -r b235999cad69 -r 7428da2bb94d OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp --- 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 dicom(new Orthanc::DicomMap); @@ -269,7 +269,7 @@ template void OrthancMultiframeVolumeLoader::CopyPixelDataAndComputeDistribution( - const std::string& pixelData, std::map& distribution) + const std::string& pixelData, std::map& 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(pixelData.c_str()); @@ -311,6 +312,7 @@ } } } +#endif { const uint8_t* source = reinterpret_cast(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 void OrthancMultiframeVolumeLoader::ComputeMinMaxWithOutlierRejection( - const std::map& distribution) + const std::map& 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::const_iterator it = distribution.begin(); + typename std::map::const_iterator it = distribution.begin(); uint64_t totalCount = 0; distributionRawMin_ = static_cast(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(pixelValue); @@ -436,14 +437,14 @@ // then start from start and remove pixel values up to // endRejectionCount voxels rejected { - typename std::map::const_iterator it = distribution.begin(); + typename std::map::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::const_reverse_iterator it = distribution.rbegin(); + typename std::map::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 distribution; + std::map distribution; CopyPixelDataAndComputeDistribution(pixelData, distribution); ComputeMinMaxWithOutlierRejection(distribution); } diff -r b235999cad69 -r 7428da2bb94d OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.h --- 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 volume_; std::string instanceId_; std::string transferSyntaxUid_; @@ -81,11 +87,11 @@ /** Service method for CopyPixelDataAndComputeMinMax*/ template void CopyPixelDataAndComputeDistribution(const std::string& pixelData, - std::map& distribution); + std::map& distribution); /** Service method for CopyPixelDataAndComputeMinMax*/ template - void ComputeMinMaxWithOutlierRejection(const std::map& distribution); + void ComputeMinMaxWithOutlierRejection(const std::map& distribution); void SetUncompressedPixelData(const std::string& pixelData); diff -r b235999cad69 -r 7428da2bb94d OrthancStone/Sources/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp --- 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)