comparison Framework/Toolbox/DicomStructureSet.cpp @ 158:a053ca7fa5c6 wasm

LinearAlgebra toolbox
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 14 Feb 2018 08:58:31 +0100
parents a30ff4866a1e
children 0a73d76333db
comparison
equal deleted inserted replaced
157:2309e8d86efe 158:a053ca7fa5c6
122 const OrthancPlugins::IDicomDataset& dataset, 122 const OrthancPlugins::IDicomDataset& dataset,
123 const OrthancPlugins::DicomPath& tag) 123 const OrthancPlugins::DicomPath& tag)
124 { 124 {
125 std::string value; 125 std::string value;
126 return (dataset.GetStringValue(value, tag) && 126 return (dataset.GetStringValue(value, tag) &&
127 GeometryToolbox::ParseVector(target, value)); 127 LinearAlgebra::ParseVector(target, value));
128 } 128 }
129 129
130 130
131 void DicomStructureSet::Polygon::CheckPoint(const Vector& v) 131 void DicomStructureSet::Polygon::CheckPoint(const Vector& v)
132 { 132 {
133 if (hasSlice_) 133 if (hasSlice_)
134 { 134 {
135 if (!GeometryToolbox::IsNear(GeometryToolbox::ProjectAlongNormal(v, geometry_.GetNormal()), 135 if (!LinearAlgebra::IsNear(GeometryToolbox::ProjectAlongNormal(v, geometry_.GetNormal()),
136 projectionAlongNormal_, 136 projectionAlongNormal_,
137 sliceThickness_ / 2.0 /* in mm */)) 137 sliceThickness_ / 2.0 /* in mm */))
138 { 138 {
139 LOG(ERROR) << "This RT-STRUCT contains a point that is off the slice of its instance"; 139 LOG(ERROR) << "This RT-STRUCT contains a point that is off the slice of its instance";
140 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); 140 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
141 } 141 }
142 } 142 }
201 return false; 201 return false;
202 } 202 }
203 203
204 double d = GeometryToolbox::ProjectAlongNormal(slice.GetOrigin(), geometry_.GetNormal()); 204 double d = GeometryToolbox::ProjectAlongNormal(slice.GetOrigin(), geometry_.GetNormal());
205 205
206 return (GeometryToolbox::IsNear(d, projectionAlongNormal_, 206 return (LinearAlgebra::IsNear(d, projectionAlongNormal_,
207 sliceThickness_ / 2.0)); 207 sliceThickness_ / 2.0));
208 } 208 }
209 209
210 210
211 bool DicomStructureSet::Polygon::Project(double& x1, 211 bool DicomStructureSet::Polygon::Project(double& x1,
212 double& y1, 212 double& y1,
466 (DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, 466 (DicomPath(DICOM_TAG_ROI_CONTOUR_SEQUENCE, i,
467 DICOM_TAG_CONTOUR_SEQUENCE, j, 467 DICOM_TAG_CONTOUR_SEQUENCE, j,
468 DICOM_TAG_CONTOUR_DATA)); 468 DICOM_TAG_CONTOUR_DATA));
469 469
470 Vector points; 470 Vector points;
471 if (!GeometryToolbox::ParseVector(points, slicesData) || 471 if (!LinearAlgebra::ParseVector(points, slicesData) ||
472 points.size() != 3 * countPoints) 472 points.size() != 3 * countPoints)
473 { 473 {
474 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); 474 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
475 } 475 }
476 476
495 Vector DicomStructureSet::GetStructureCenter(size_t index) const 495 Vector DicomStructureSet::GetStructureCenter(size_t index) const
496 { 496 {
497 const Structure& structure = GetStructure(index); 497 const Structure& structure = GetStructure(index);
498 498
499 Vector center; 499 Vector center;
500 GeometryToolbox::AssignVector(center, 0, 0, 0); 500 LinearAlgebra::AssignVector(center, 0, 0, 0);
501 if (structure.polygons_.empty()) 501 if (structure.polygons_.empty())
502 { 502 {
503 return center; 503 return center;
504 } 504 }
505 505
612 double thickness = 1; // 1 mm by default 612 double thickness = 1; // 1 mm by default
613 613
614 std::string s; 614 std::string s;
615 Vector v; 615 Vector v;
616 if (dataset.CopyToString(s, Orthanc::DICOM_TAG_SLICE_THICKNESS, false) && 616 if (dataset.CopyToString(s, Orthanc::DICOM_TAG_SLICE_THICKNESS, false) &&
617 GeometryToolbox::ParseVector(v, s) && 617 LinearAlgebra::ParseVector(v, s) &&
618 v.size() > 0) 618 v.size() > 0)
619 { 619 {
620 thickness = v[0]; 620 thickness = v[0];
621 } 621 }
622 622
655 Vector DicomStructureSet::GetNormal() const 655 Vector DicomStructureSet::GetNormal() const
656 { 656 {
657 if (referencedSlices_.empty()) 657 if (referencedSlices_.empty())
658 { 658 {
659 Vector v; 659 Vector v;
660 GeometryToolbox::AssignVector(v, 0, 0, 1); 660 LinearAlgebra::AssignVector(v, 0, 0, 1);
661 return v; 661 return v;
662 } 662 }
663 else 663 else
664 { 664 {
665 return referencedSlices_.begin()->second.geometry_.GetNormal(); 665 return referencedSlices_.begin()->second.geometry_.GetNormal();