Mercurial > hg > orthanc-stone
comparison Framework/Toolbox/DicomStructureSet.cpp @ 34:a865c7992a87
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 19 Dec 2016 11:34:18 +0100 |
parents | 517c46f527cd |
children | 6465fbd23bce |
comparison
equal
deleted
inserted
replaced
33:12987d11be33 | 34:a865c7992a87 |
---|---|
93 std::string parentUid = reader.GetMandatoryStringValue(DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, contourIndex, | 93 std::string parentUid = reader.GetMandatoryStringValue(DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, contourIndex, |
94 DICOM_TAG_CONTOUR_SEQUENCE, sliceIndex, | 94 DICOM_TAG_CONTOUR_SEQUENCE, sliceIndex, |
95 DICOM_TAG_CONTOUR_IMAGE_SEQUENCE, 0, | 95 DICOM_TAG_CONTOUR_IMAGE_SEQUENCE, 0, |
96 DICOM_TAG_REFERENCED_SOP_INSTANCE_UID)); | 96 DICOM_TAG_REFERENCED_SOP_INSTANCE_UID)); |
97 | 97 |
98 std::string post; | 98 Json::Value parentLookup; |
99 orthanc.RestApiPost(post, "/tools/lookup", parentUid); | 99 MessagingToolbox::RestApiPost(parentLookup, orthanc, "/tools/lookup", parentUid); |
100 | 100 |
101 Json::Value tmp; | 101 if (parentLookup.type() != Json::arrayValue || |
102 MessagingToolbox::ParseJson(tmp, post); | 102 parentLookup.size() != 1 || |
103 | 103 !parentLookup[0].isMember("Type") || |
104 if (tmp.type() != Json::arrayValue || | 104 !parentLookup[0].isMember("Path") || |
105 tmp.size() != 1 || | 105 parentLookup[0]["Type"].type() != Json::stringValue || |
106 !tmp[0].isMember("Type") || | 106 parentLookup[0]["ID"].type() != Json::stringValue || |
107 !tmp[0].isMember("Path") || | 107 parentLookup[0]["Type"].asString() != "Instance") |
108 tmp[0]["Type"].type() != Json::stringValue || | |
109 tmp[0]["ID"].type() != Json::stringValue || | |
110 tmp[0]["Type"].asString() != "Instance") | |
111 { | 108 { |
112 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); | 109 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); |
113 } | 110 } |
114 | 111 |
115 Json::Value parentInstance; | 112 Json::Value parentInstance; |
116 MessagingToolbox::RestApiGet(parentInstance, orthanc, "/instances/" + tmp[0]["ID"].asString()); | 113 MessagingToolbox::RestApiGet(parentInstance, orthanc, "/instances/" + parentLookup[0]["ID"].asString()); |
117 | 114 |
118 if (parentInstance.type() != Json::objectValue || | 115 if (parentInstance.type() != Json::objectValue || |
119 !parentInstance.isMember("ParentSeries") || | 116 !parentInstance.isMember("ParentSeries") || |
120 parentInstance["ParentSeries"].type() != Json::stringValue) | 117 parentInstance["ParentSeries"].type() != Json::stringValue) |
121 { | 118 { |
133 { | 130 { |
134 LOG(ERROR) << "This RT-STRUCT refers to several different series"; | 131 LOG(ERROR) << "This RT-STRUCT refers to several different series"; |
135 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | 132 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
136 } | 133 } |
137 | 134 |
138 FullOrthancDataset parentTags(orthanc, "/instances/" + tmp[0]["ID"].asString() + "/tags"); | 135 FullOrthancDataset parentTags(orthanc, "/instances/" + parentLookup[0]["ID"].asString() + "/tags"); |
139 SliceGeometry slice(parentTags); | 136 SliceGeometry slice(parentTags); |
140 | 137 |
141 Vector v; | 138 Vector v; |
142 if (GeometryToolbox::ParseVector(v, parentTags, DICOM_TAG_SLICE_THICKNESS) && | 139 if (GeometryToolbox::ParseVector(v, parentTags, DICOM_TAG_SLICE_THICKNESS) && |
143 v.size() > 0) | 140 v.size() > 0) |