comparison Framework/Toolbox/GeometryToolbox.cpp @ 32:517c46f527cd

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 19 Dec 2016 11:00:23 +0100
parents ff1e935768e7
children 7207a407bcd8
comparison
equal deleted inserted replaced
31:9aace933cb64 32:517c46f527cd
30 **/ 30 **/
31 31
32 32
33 #include "GeometryToolbox.h" 33 #include "GeometryToolbox.h"
34 34
35 #include "../../Resources/Orthanc/Core/Logging.h"
35 #include "../../Resources/Orthanc/Core/OrthancException.h" 36 #include "../../Resources/Orthanc/Core/OrthancException.h"
36 #include "../../Resources/Orthanc/Core/Toolbox.h" 37 #include "../../Resources/Orthanc/Core/Toolbox.h"
37 38
38 #include <stdio.h> 39 #include <stdio.h>
39 #include <boost/lexical_cast.hpp> 40 #include <boost/lexical_cast.hpp>
72 return false; 73 return false;
73 } 74 }
74 } 75 }
75 76
76 return true; 77 return true;
78 }
79
80
81 bool ParseVector(Vector& target,
82 const OrthancPlugins::IDicomDataset& dataset,
83 const OrthancPlugins::DicomPath& tag)
84 {
85 std::string value;
86 return (dataset.GetStringValue(value, tag) &&
87 ParseVector(target, value));
77 } 88 }
78 89
79 90
80 void AssignVector(Vector& v, 91 void AssignVector(Vector& v,
81 double v1, 92 double v1,
345 y2 = b[1] / b[2]; 356 y2 = b[1] / b[2];
346 357
347 return true; 358 return true;
348 } 359 }
349 } 360 }
361
362
363 void GetPixelSpacing(double& spacingX,
364 double& spacingY,
365 const OrthancPlugins::IDicomDataset& dicom)
366 {
367 Vector v;
368
369 if (ParseVector(v, dicom, OrthancPlugins::DICOM_TAG_PIXEL_SPACING))
370 {
371 if (v.size() != 2 ||
372 v[0] <= 0 ||
373 v[1] <= 0)
374 {
375 LOG(ERROR) << "Bad value for PixelSpacing tag";
376 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
377 }
378 else
379 {
380 spacingX = v[0];
381 spacingY = v[1];
382 }
383 }
384 else
385 {
386 // The "PixelSpacing" is of type 1C: It could be absent, use
387 // default value in such a case
388 spacingX = 1;
389 spacingY = 1;
390 }
391 }
350 } 392 }
351 } 393 }