Mercurial > hg > orthanc-stone
diff OrthancStone/Sources/Toolbox/OsiriX/CollectionOfAnnotations.cpp @ 1593:b782f78aed42
rendering osirix annotations
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 23 Oct 2020 17:39:16 +0200 |
parents | bd180f97c734 |
children | 4fb8fdf03314 |
line wrap: on
line diff
--- a/OrthancStone/Sources/Toolbox/OsiriX/CollectionOfAnnotations.cpp Fri Oct 23 15:15:32 2020 +0200 +++ b/OrthancStone/Sources/Toolbox/OsiriX/CollectionOfAnnotations.cpp Fri Oct 23 17:39:16 2020 +0200 @@ -42,13 +42,16 @@ } - CollectionOfAnnotations::~CollectionOfAnnotations() + void CollectionOfAnnotations::Clear() { for (size_t i = 0; i < annotations_.size(); i++) { assert(annotations_[i] != NULL); delete annotations_[i]; } + + annotations_.clear(); + index_.clear(); } @@ -74,14 +77,44 @@ } else { + size_t pos = annotations_.size(); annotations_.push_back(annotation); + + SopInstanceUidIndex::iterator found = index_.find(annotation->GetSopInstanceUid()); + if (found == index_.end()) + { + std::set<size_t> s; + s.insert(pos); + index_[annotation->GetSopInstanceUid()] = s; + } + else + { + found->second.insert(pos); + } } } - void CollectionOfAnnotations::ParseXml(const std::string& xml) + + void CollectionOfAnnotations::LookupSopInstanceUid(std::set<size_t>& target, + const std::string& sopInstanceUid) const + { + SopInstanceUidIndex::const_iterator found = index_.find(sopInstanceUid); + if (found == index_.end()) + { + target.clear(); + } + else + { + target = found->second; + } + } + + + void CollectionOfAnnotations::LoadXml(const char* xml, + size_t size) { pugi::xml_document doc; - pugi::xml_parse_result result = doc.load_buffer(xml.empty() ? NULL : xml.c_str(), xml.size()); + pugi::xml_parse_result result = doc.load_buffer(xml, size); if (!result) { throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);