Mercurial > hg > orthanc-stone
comparison 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 |
comparison
equal
deleted
inserted
replaced
1592:0d4b11ba86df | 1593:b782f78aed42 |
---|---|
40 target[attr.name()] = attr.value(); | 40 target[attr.name()] = attr.value(); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 CollectionOfAnnotations::~CollectionOfAnnotations() | 45 void CollectionOfAnnotations::Clear() |
46 { | 46 { |
47 for (size_t i = 0; i < annotations_.size(); i++) | 47 for (size_t i = 0; i < annotations_.size(); i++) |
48 { | 48 { |
49 assert(annotations_[i] != NULL); | 49 assert(annotations_[i] != NULL); |
50 delete annotations_[i]; | 50 delete annotations_[i]; |
51 } | 51 } |
52 | |
53 annotations_.clear(); | |
54 index_.clear(); | |
52 } | 55 } |
53 | 56 |
54 | 57 |
55 const Annotation& CollectionOfAnnotations::GetAnnotation(size_t i) const | 58 const Annotation& CollectionOfAnnotations::GetAnnotation(size_t i) const |
56 { | 59 { |
72 { | 75 { |
73 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | 76 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
74 } | 77 } |
75 else | 78 else |
76 { | 79 { |
80 size_t pos = annotations_.size(); | |
77 annotations_.push_back(annotation); | 81 annotations_.push_back(annotation); |
82 | |
83 SopInstanceUidIndex::iterator found = index_.find(annotation->GetSopInstanceUid()); | |
84 if (found == index_.end()) | |
85 { | |
86 std::set<size_t> s; | |
87 s.insert(pos); | |
88 index_[annotation->GetSopInstanceUid()] = s; | |
89 } | |
90 else | |
91 { | |
92 found->second.insert(pos); | |
93 } | |
78 } | 94 } |
79 } | 95 } |
80 | 96 |
81 void CollectionOfAnnotations::ParseXml(const std::string& xml) | 97 |
98 void CollectionOfAnnotations::LookupSopInstanceUid(std::set<size_t>& target, | |
99 const std::string& sopInstanceUid) const | |
100 { | |
101 SopInstanceUidIndex::const_iterator found = index_.find(sopInstanceUid); | |
102 if (found == index_.end()) | |
103 { | |
104 target.clear(); | |
105 } | |
106 else | |
107 { | |
108 target = found->second; | |
109 } | |
110 } | |
111 | |
112 | |
113 void CollectionOfAnnotations::LoadXml(const char* xml, | |
114 size_t size) | |
82 { | 115 { |
83 pugi::xml_document doc; | 116 pugi::xml_document doc; |
84 pugi::xml_parse_result result = doc.load_buffer(xml.empty() ? NULL : xml.c_str(), xml.size()); | 117 pugi::xml_parse_result result = doc.load_buffer(xml, size); |
85 if (!result) | 118 if (!result) |
86 { | 119 { |
87 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | 120 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
88 } | 121 } |
89 | 122 |