Mercurial > hg > orthanc-stone
comparison Framework/Toolbox/GeometryToolbox.h @ 158:a053ca7fa5c6 wasm
LinearAlgebra toolbox
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 14 Feb 2018 08:58:31 +0100 |
parents | 2309e8d86efe |
children | 8d50e6be565d |
comparison
equal
deleted
inserted
replaced
157:2309e8d86efe | 158:a053ca7fa5c6 |
---|---|
19 **/ | 19 **/ |
20 | 20 |
21 | 21 |
22 #pragma once | 22 #pragma once |
23 | 23 |
24 // Patch for ublas in Boost 1.64.0 | 24 #include "LinearAlgebra.h" |
25 // https://github.com/dealii/dealii/issues/4302 | |
26 #include <boost/version.hpp> | |
27 #if BOOST_VERSION >= 106300 // or 64, need to check | |
28 # include <boost/serialization/array_wrapper.hpp> | |
29 #endif | |
30 | |
31 #include <Core/DicomFormat/DicomMap.h> | |
32 | |
33 #include <boost/numeric/ublas/matrix.hpp> | |
34 #include <boost/numeric/ublas/vector.hpp> | |
35 #include <cassert> | |
36 | 25 |
37 namespace OrthancStone | 26 namespace OrthancStone |
38 { | 27 { |
39 typedef boost::numeric::ublas::matrix<double> Matrix; | |
40 typedef boost::numeric::ublas::vector<double> Vector; | |
41 | |
42 namespace GeometryToolbox | 28 namespace GeometryToolbox |
43 { | 29 { |
44 void Print(const Vector& v); | |
45 | |
46 void Print(const Matrix& m); | |
47 | |
48 bool ParseVector(Vector& target, | |
49 const std::string& s); | |
50 | |
51 bool ParseVector(Vector& target, | |
52 const Orthanc::DicomMap& dataset, | |
53 const Orthanc::DicomTag& tag); | |
54 | |
55 void AssignVector(Vector& v, | |
56 double v1, | |
57 double v2); | |
58 | |
59 void AssignVector(Vector& v, | |
60 double v1, | |
61 double v2, | |
62 double v3); | |
63 | |
64 inline bool IsNear(double x, | |
65 double y, | |
66 double threshold) | |
67 { | |
68 return fabs(x - y) < threshold; | |
69 } | |
70 | |
71 bool IsNear(double x, | |
72 double y); | |
73 | |
74 inline bool IsCloseToZero(double x) | |
75 { | |
76 return IsNear(x, 0.0); | |
77 } | |
78 | |
79 void NormalizeVector(Vector& u); | |
80 | |
81 void CrossProduct(Vector& result, | |
82 const Vector& u, | |
83 const Vector& v); | |
84 | |
85 void ProjectPointOntoPlane(Vector& result, | 30 void ProjectPointOntoPlane(Vector& result, |
86 const Vector& point, | 31 const Vector& point, |
87 const Vector& planeNormal, | 32 const Vector& planeNormal, |
88 const Vector& planeOrigin); | 33 const Vector& planeOrigin); |
89 | 34 |
139 bool IntersectPlaneAndLine(Vector& p, | 84 bool IntersectPlaneAndLine(Vector& p, |
140 const Vector& normal, | 85 const Vector& normal, |
141 double d, | 86 double d, |
142 const Vector& origin, | 87 const Vector& origin, |
143 const Vector& direction); | 88 const Vector& direction); |
144 | |
145 void FillMatrix(Matrix& target, | |
146 size_t rows, | |
147 size_t columns, | |
148 const double values[]); | |
149 | |
150 void FillVector(Vector& target, | |
151 size_t size, | |
152 const double values[]); | |
153 | |
154 void Convert(Matrix& target, | |
155 const Vector& source); | |
156 | 89 |
157 inline float ComputeBilinearInterpolationInternal(float x, | 90 inline float ComputeBilinearInterpolationInternal(float x, |
158 float y, | 91 float y, |
159 float f00, // source(x, y) | 92 float f00, // source(x, y) |
160 float f01, // source(x + 1, y) | 93 float f01, // source(x + 1, y) |