Mercurial > hg > orthanc-stone
diff Framework/Loaders/DicomStructureSetLoader.cpp @ 981:c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 06 Sep 2019 09:38:18 +0200 |
parents | 262a0244e9b2 |
children | 50e5acf5553b |
line wrap: on
line diff
--- a/Framework/Loaders/DicomStructureSetLoader.cpp Mon Sep 02 17:44:20 2019 +0200 +++ b/Framework/Loaders/DicomStructureSetLoader.cpp Fri Sep 06 09:38:18 2019 +0200 @@ -64,10 +64,6 @@ virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) { -#if 0 - if (logbgo115) - LOG(TRACE) << "DicomStructureSetLoader::AddReferencedInstance::Handle() (SUCCESS)"; -#endif Json::Value tags; message.ParseJsonBody(tags); @@ -76,17 +72,6 @@ DicomStructureSetLoader& loader = GetLoader<DicomStructureSetLoader>(); -#if 0 - { - std::stringstream ss; - //DumpDicomMap(ss, dicom); - std::string dicomMapStr = ss.str(); - if (logbgo115) - LOG(TRACE) << " DicomStructureSetLoader::AddReferencedInstance::Handle() about to call AddReferencedSlice on dicom = " << dicomMapStr; - } -#endif - - loader.content_->AddReferencedSlice(dicom); loader.countProcessedInstances_ ++; @@ -150,24 +135,12 @@ const std::string instanceId = lookup[0]["ID"].asString(); { -#if 0 - if(logbgo115) - LOG(TRACE) << "DicomStructureSetLoader::LookupInstance::Handle() (SUCCESS)"; -#endif std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); command->SetHttpHeader("Accept-Encoding", "gzip"); std::string uri = "/instances/" + instanceId + "/tags"; command->SetUri(uri); command->SetPayload(new AddReferencedInstance(loader, instanceId)); -#if 0 - if (logbgo115) - LOG(TRACE) << " DicomStructureSetLoader::LookupInstance::Handle() about to schedule request with AddReferencedInstance subsequent command on uri \"" << uri << "\""; -#endif Schedule(command.release()); -#if 0 - if (logbgo115) - LOG(TRACE) << " DicomStructureSetLoader::LookupInstance::Handle() request+command scheduled"; -#endif } } }; @@ -195,27 +168,30 @@ loader.content_.reset(new DicomStructureSet(dicom)); } + // Some (admittedly invalid) Dicom files have empty values in the + // 0008,1155 tag. We try our best to cope with this. std::set<std::string> instances; + std::set<std::string> nonEmptyInstances; loader.content_->GetReferencedInstances(instances); + for (std::set<std::string>::const_iterator + it = instances.begin(); it != instances.end(); ++it) + { + std::string instance = Orthanc::Toolbox::StripSpaces(*it); + if(instance != "") + nonEmptyInstances.insert(instance); + } - loader.countReferencedInstances_ = static_cast<unsigned int>(instances.size()); + loader.countReferencedInstances_ = + static_cast<unsigned int>(nonEmptyInstances.size()); for (std::set<std::string>::const_iterator - it = instances.begin(); it != instances.end(); ++it) + it = nonEmptyInstances.begin(); it != nonEmptyInstances.end(); ++it) { std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); command->SetUri("/tools/lookup"); command->SetMethod(Orthanc::HttpMethod_Post); command->SetBody(*it); - - // The following headers have been commented out because - // they were causing issues in the reverse proxy in a dev scenario. - // They should NOT be required for POST requests - //command->SetHttpHeader("pragma", "no-cache"); - //command->SetHttpHeader("cache-control", "no-cache"); - command->SetPayload(new LookupInstance(loader, *it)); - //LOG(TRACE) << "About to schedule a /tools/lookup POST request. URI = " << command->GetUri() << " Body size = " << (*it).size() << " Body = " << (*it) << "\n"; Schedule(command.release()); } } @@ -267,7 +243,7 @@ { const Color& color = content_.GetStructureColor(i); - std::vector< std::vector<DicomStructureSet::PolygonPoint> > polygons; + std::vector< std::vector<DicomStructureSet::PolygonPoint2D> > polygons; if (content_.ProjectStructure(polygons, i, cuttingPlane)) { @@ -319,17 +295,10 @@ command->SetHttpHeader("Accept-Encoding", "gzip"); std::string uri = "/instances/" + instanceId + "/tags?ignore-length=3006-0050"; -#if 0 - if (logbgo115) - LOG(TRACE) << "DicomStructureSetLoader::LoadInstance() instanceId = " << instanceId << " | uri = \"" << uri << "\""; -#endif + command->SetUri(uri); command->SetPayload(new LoadStructure(*this)); Schedule(command.release()); -#if 0 - if (logbgo115) - LOG(TRACE) << "DicomStructureSetLoader::LoadInstance() command (with LoadStructure) scheduled."; -#endif } }