comparison OrthancServer/Search/HierarchicalMatcher.cpp @ 1797:23722a191e4e worklists

worklists are working
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 20 Nov 2015 11:37:58 +0100
parents 5e08a5fe6b27
children 769178f0ab2c
comparison
equal deleted inserted replaced
1796:5e08a5fe6b27 1797:23722a191e4e
233 233
234 DcmSequenceOfItems* sequence = NULL; 234 DcmSequenceOfItems* sequence = NULL;
235 if (!item.findAndGetSequence(tag, sequence).good() || 235 if (!item.findAndGetSequence(tag, sequence).good() ||
236 sequence == NULL) 236 sequence == NULL)
237 { 237 {
238 return false; 238 return true;
239 } 239 }
240 240
241 bool match = false; 241 bool match = false;
242 242
243 for (unsigned long i = 0; i < sequence->card(); i++) 243 for (unsigned long i = 0; i < sequence->card(); i++)
258 258
259 return true; 259 return true;
260 } 260 }
261 261
262 262
263 DcmDataset* HierarchicalMatcher::ExtractInternal(DcmItem& item, 263 DcmDataset* HierarchicalMatcher::ExtractInternal(DcmItem& source,
264 Encoding encoding) const 264 Encoding encoding) const
265 { 265 {
266 std::auto_ptr<DcmDataset> dataset(new DcmDataset); 266 std::auto_ptr<DcmDataset> target(new DcmDataset);
267 267
268 for (Constraints::const_iterator it = constraints_.begin(); 268 for (Constraints::const_iterator it = constraints_.begin();
269 it != constraints_.end(); ++it) 269 it != constraints_.end(); ++it)
270 { 270 {
271 DcmTagKey tag = ToDcmtkBridge::Convert(it->first); 271 DcmTagKey tag = ToDcmtkBridge::Convert(it->first);
272 272
273 DcmElement* element = NULL; 273 DcmElement* element = NULL;
274 if (item.findAndGetElement(tag, element).good() && 274 if (source.findAndGetElement(tag, element).good() &&
275 element != NULL) 275 element != NULL)
276 { 276 {
277 std::auto_ptr<DcmElement> cloned(FromDcmtkBridge::CreateElementForTag(it->first)); 277 std::auto_ptr<DcmElement> cloned(FromDcmtkBridge::CreateElementForTag(it->first));
278 cloned->copyFrom(*element); 278 cloned->copyFrom(*element);
279 dataset->insert(cloned.release()); 279 target->insert(cloned.release());
280 } 280 }
281 } 281 }
282 282
283 for (Sequences::const_iterator it = sequences_.begin(); 283 for (Sequences::const_iterator it = sequences_.begin();
284 it != sequences_.end(); ++it) 284 it != sequences_.end(); ++it)
285 { 285 {
286 DcmTagKey tag = ToDcmtkBridge::Convert(it->first); 286 DcmTagKey tag = ToDcmtkBridge::Convert(it->first);
287 287
288 DcmSequenceOfItems* sequence = NULL; 288 DcmSequenceOfItems* sequence = NULL;
289 if (item.findAndGetSequence(tag, sequence).good() && 289 if (source.findAndGetSequence(tag, sequence).good() &&
290 sequence != NULL) 290 sequence != NULL)
291 { 291 {
292 std::auto_ptr<DcmSequenceOfItems> cloned(new DcmSequenceOfItems(tag)); 292 std::auto_ptr<DcmSequenceOfItems> cloned(new DcmSequenceOfItems(tag));
293 293
294 for (unsigned long i = 0; i < sequence->card(); i++) 294 for (unsigned long i = 0; i < sequence->card(); i++)
295 { 295 {
296 if (it->second == NULL) 296 if (it->second == NULL)
297 { 297 {
298 cloned->append(new DcmItem(*sequence->getItem(i))); 298 cloned->append(new DcmItem(*sequence->getItem(i)));
299 } 299 }
300 else if (it->second->MatchInternal(*sequence->getItem(i), encoding)) 300 else if (it->second->MatchInternal(*sequence->getItem(i), encoding)) // TODO Might be optimized
301 { 301 {
302 cloned->append(it->second->ExtractInternal(*sequence->getItem(i), encoding)); 302 // It is necessary to encapsulate the child dataset into a
303 // "DcmItem" object before it can be included in a
304 // sequence. Otherwise, "dciodvfy" reports an error "Bad
305 // tag in sequence - Expecting Item or Sequence Delimiter."
306 std::auto_ptr<DcmDataset> child(it->second->ExtractInternal(*sequence->getItem(i), encoding));
307 cloned->append(new DcmItem(*child));
303 } 308 }
304 } 309 }
305 310
306 dataset->insert(cloned.release()); 311 target->insert(cloned.release());
307 } 312 }
308 } 313 }
309 314
310 return dataset.release(); 315 return target.release();
311 } 316 }
312 317
313 318
314 ParsedDicomFile* HierarchicalMatcher::Extract(ParsedDicomFile& dicom) const 319 ParsedDicomFile* HierarchicalMatcher::Extract(ParsedDicomFile& dicom) const
315 { 320 {