Mercurial > hg > orthanc-stone
comparison Framework/Toolbox/DicomStructureSet.cpp @ 786:5aa728500586
optimizing constructor of DicomStructureSet
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 28 May 2019 07:48:57 +0200 |
parents | 8e31b174ab26 |
children | 9f68155c75b0 |
comparison
equal
deleted
inserted
replaced
784:9f3b2027a4a9 | 786:5aa728500586 |
---|---|
420 << "\" containing " << countSlices << " slices (color: " | 420 << "\" containing " << countSlices << " slices (color: " |
421 << static_cast<int>(structures_[i].red_) << "," | 421 << static_cast<int>(structures_[i].red_) << "," |
422 << static_cast<int>(structures_[i].green_) << "," | 422 << static_cast<int>(structures_[i].green_) << "," |
423 << static_cast<int>(structures_[i].blue_) << ")"; | 423 << static_cast<int>(structures_[i].blue_) << ")"; |
424 | 424 |
425 | |
426 // These temporary variables avoid allocating many vectors in the loop below | |
427 OrthancPlugins::DicomPath countPointsPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, | |
428 DICOM_TAG_CONTOUR_SEQUENCE, 0, | |
429 DICOM_TAG_NUMBER_OF_CONTOUR_POINTS); | |
430 | |
431 OrthancPlugins::DicomPath geometricTypePath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, | |
432 DICOM_TAG_CONTOUR_SEQUENCE, 0, | |
433 DICOM_TAG_CONTOUR_GEOMETRIC_TYPE); | |
434 | |
435 OrthancPlugins::DicomPath imageSequencePath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, | |
436 DICOM_TAG_CONTOUR_SEQUENCE, 0, | |
437 DICOM_TAG_CONTOUR_IMAGE_SEQUENCE); | |
438 | |
439 OrthancPlugins::DicomPath referencedInstancePath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, | |
440 DICOM_TAG_CONTOUR_SEQUENCE, 0, | |
441 DICOM_TAG_CONTOUR_IMAGE_SEQUENCE, 0, | |
442 DICOM_TAG_REFERENCED_SOP_INSTANCE_UID); | |
443 | |
444 OrthancPlugins::DicomPath contourDataPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, | |
445 DICOM_TAG_CONTOUR_SEQUENCE, 0, | |
446 DICOM_TAG_CONTOUR_DATA); | |
447 | |
425 for (size_t j = 0; j < countSlices; j++) | 448 for (size_t j = 0; j < countSlices; j++) |
426 { | 449 { |
427 unsigned int countPoints; | 450 unsigned int countPoints; |
428 | 451 |
429 if (!reader.GetUnsignedIntegerValue | 452 countPointsPath.SetPrefixIndex(1, j); |
430 (countPoints, OrthancPlugins::DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, | 453 if (!reader.GetUnsignedIntegerValue(countPoints, countPointsPath)) |
431 DICOM_TAG_CONTOUR_SEQUENCE, j, | |
432 DICOM_TAG_NUMBER_OF_CONTOUR_POINTS))) | |
433 { | 454 { |
434 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | 455 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
435 } | 456 } |
436 | 457 |
437 //LOG(INFO) << "Parsing slice containing " << countPoints << " vertices"; | 458 //LOG(INFO) << "Parsing slice containing " << countPoints << " vertices"; |
438 | 459 |
439 std::string type = reader.GetMandatoryStringValue | 460 geometricTypePath.SetPrefixIndex(1, j); |
440 (OrthancPlugins::DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, | 461 std::string type = reader.GetMandatoryStringValue(geometricTypePath); |
441 DICOM_TAG_CONTOUR_SEQUENCE, j, | |
442 DICOM_TAG_CONTOUR_GEOMETRIC_TYPE)); | |
443 if (type != "CLOSED_PLANAR") | 462 if (type != "CLOSED_PLANAR") |
444 { | 463 { |
445 LOG(WARNING) << "Ignoring contour with geometry type: " << type; | 464 LOG(WARNING) << "Ignoring contour with geometry type: " << type; |
446 continue; | 465 continue; |
447 } | 466 } |
448 | 467 |
449 size_t size; | 468 size_t size; |
450 if (!tags.GetSequenceSize(size, OrthancPlugins::DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, | 469 |
451 DICOM_TAG_CONTOUR_SEQUENCE, j, | 470 imageSequencePath.SetPrefixIndex(1, j); |
452 DICOM_TAG_CONTOUR_IMAGE_SEQUENCE)) || | 471 if (!tags.GetSequenceSize(size, imageSequencePath) || |
453 size != 1) | 472 size != 1) |
454 { | 473 { |
455 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | 474 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
456 } | 475 } |
457 | 476 |
458 std::string sopInstanceUid = reader.GetMandatoryStringValue | 477 referencedInstancePath.SetPrefixIndex(1, j); |
459 (OrthancPlugins::DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, | 478 std::string sopInstanceUid = reader.GetMandatoryStringValue(referencedInstancePath); |
460 DICOM_TAG_CONTOUR_SEQUENCE, j, | 479 |
461 DICOM_TAG_CONTOUR_IMAGE_SEQUENCE, 0, | 480 contourDataPath.SetPrefixIndex(1, j); |
462 DICOM_TAG_REFERENCED_SOP_INSTANCE_UID)); | 481 std::string slicesData = reader.GetMandatoryStringValue(contourDataPath); |
463 | |
464 std::string slicesData = reader.GetMandatoryStringValue | |
465 (OrthancPlugins::DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, | |
466 DICOM_TAG_CONTOUR_SEQUENCE, j, | |
467 DICOM_TAG_CONTOUR_DATA)); | |
468 | 482 |
469 Vector points; | 483 Vector points; |
470 if (!LinearAlgebra::ParseVector(points, slicesData) || | 484 if (!LinearAlgebra::ParseVector(points, slicesData) || |
471 points.size() != 3 * countPoints) | 485 points.size() != 3 * countPoints) |
472 { | 486 { |