Mercurial > hg > orthanc-stone
comparison RenderingPlugin/Sources/Plugin.cpp @ 1945:98952be6fb97
rendering plugin: rendering of multiple structures
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 02 Jun 2022 12:23:45 +0200 |
parents | 3daecfa5791c |
children | 3c68cdfbdcab |
comparison
equal
deleted
inserted
replaced
1944:3daecfa5791c | 1945:98952be6fb97 |
---|---|
741 } | 741 } |
742 } | 742 } |
743 }; | 743 }; |
744 | 744 |
745 DataAugmentationParameters dataAugmentation; | 745 DataAugmentationParameters dataAugmentation; |
746 std::string structureName; | 746 std::vector<std::string> structureNames; |
747 std::string instanceId; | 747 std::string instanceId; |
748 bool compress = false; | 748 bool compress = false; |
749 | 749 |
750 for (uint32_t i = 0; i < request->getCount; i++) | 750 for (uint32_t i = 0; i < request->getCount; i++) |
751 { | 751 { |
754 | 754 |
755 if (!dataAugmentation.ParseParameter(key, value)) | 755 if (!dataAugmentation.ParseParameter(key, value)) |
756 { | 756 { |
757 if (key == "structure") | 757 if (key == "structure") |
758 { | 758 { |
759 structureName = value; | 759 Orthanc::Toolbox::TokenizeString(structureNames, value, ','); |
760 } | 760 } |
761 else if (key == "instance") | 761 else if (key == "instance") |
762 { | 762 { |
763 instanceId = value; | 763 instanceId = value; |
764 } | 764 } |
771 LOG(WARNING) << "Unsupported option: " << key; | 771 LOG(WARNING) << "Unsupported option: " << key; |
772 } | 772 } |
773 } | 773 } |
774 } | 774 } |
775 | 775 |
776 if (structureName.empty()) | 776 if (structureNames.empty()) |
777 { | 777 { |
778 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol, | 778 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol, |
779 "Missing option \"structure\" to provide the structure name"); | 779 "Missing option \"structure\" to provide the names of the structures of interest"); |
780 } | 780 } |
781 | 781 |
782 if (instanceId.empty()) | 782 if (instanceId.empty()) |
783 { | 783 { |
784 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol, | 784 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol, |
785 "Missing option \"instance\" to provide the Orthanc identifier of the instance of interest"); | 785 "Missing option \"instance\" to provide the Orthanc identifier of the instance of interest"); |
786 } | 786 } |
787 | 787 |
788 std::unique_ptr<OrthancStone::DicomInstanceParameters> parameters(GetInstanceParameters(instanceId)); | 788 std::unique_ptr<OrthancStone::DicomInstanceParameters> parameters(GetInstanceParameters(instanceId)); |
789 | 789 |
790 std::list< std::vector<OrthancStone::Vector> > polygons; | 790 typedef std::list< std::vector<OrthancStone::Vector> > Polygons; |
791 | |
792 Polygons polygons; | |
791 | 793 |
792 { | 794 { |
793 DicomStructureCache::Accessor accessor(DicomStructureCache::GetSingleton(), request->groups[0]); | 795 DicomStructureCache::Accessor accessor(DicomStructureCache::GetSingleton(), request->groups[0]); |
794 | 796 |
795 size_t structureIndex; | 797 for (size_t i = 0; i < structureNames.size(); i++) |
796 bool found = false; | 798 { |
797 for (size_t i = 0; i < accessor.GetRtStruct().GetStructuresCount(); i++) | 799 size_t structureIndex; |
798 { | 800 if (accessor.GetRtStruct().LookupStructureName(structureIndex, structureNames[i])) |
799 if (accessor.GetRtStruct().GetStructureName(i) == structureName) | 801 { |
800 { | 802 Polygons p; |
801 structureIndex = i; | 803 accessor.GetRtStruct().GetStructurePoints(p, structureIndex, parameters->GetSopInstanceUid()); |
802 found = true; | 804 polygons.splice(polygons.begin(), p); |
803 break; | 805 } |
804 } | 806 else |
805 } | 807 { |
806 | 808 LOG(WARNING) << "Missing structure name \"" << structureNames[i] |
807 if (!found) | 809 << "\" in RT-STRUCT: " << parameters->GetSopInstanceUid(); |
808 { | 810 } |
809 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem, | 811 } |
810 "Unknown structure name: " + structureName); | |
811 } | |
812 | |
813 accessor.GetRtStruct().GetStructurePoints(polygons, structureIndex, parameters->GetSopInstanceUid()); | |
814 } | 812 } |
815 | 813 |
816 // We use a "XOR" filler for the polygons in order to deal with holes in the RT-STRUCT | 814 // We use a "XOR" filler for the polygons in order to deal with holes in the RT-STRUCT |
817 XorFiller filler(parameters->GetWidth(), parameters->GetHeight()); | 815 XorFiller filler(parameters->GetWidth(), parameters->GetHeight()); |
818 OrthancStone::AffineTransform2D transform = dataAugmentation.ComputeTransform(parameters->GetWidth(), parameters->GetHeight()); | 816 OrthancStone::AffineTransform2D transform = dataAugmentation.ComputeTransform(parameters->GetWidth(), parameters->GetHeight()); |