158
|
1 /**
|
|
2 * Stone of Orthanc
|
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
|
|
4 * Department, University Hospital of Liege, Belgium
|
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
|
|
6 *
|
|
7 * This program is free software: you can redistribute it and/or
|
|
8 * modify it under the terms of the GNU Affero General Public License
|
|
9 * as published by the Free Software Foundation, either version 3 of
|
|
10 * the License, or (at your option) any later version.
|
|
11 *
|
|
12 * This program is distributed in the hope that it will be useful, but
|
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
15 * Affero General Public License for more details.
|
|
16 *
|
|
17 * You should have received a copy of the GNU Affero General Public License
|
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19 **/
|
|
20
|
|
21
|
|
22 #pragma once
|
|
23
|
|
24 // Patch for ublas in Boost 1.64.0
|
|
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
|
|
36 namespace OrthancStone
|
|
37 {
|
|
38 typedef boost::numeric::ublas::matrix<double> Matrix;
|
|
39 typedef boost::numeric::ublas::vector<double> Vector;
|
|
40
|
|
41 namespace LinearAlgebra
|
|
42 {
|
|
43 void Print(const Vector& v);
|
|
44
|
|
45 void Print(const Matrix& m);
|
|
46
|
|
47 bool ParseVector(Vector& target,
|
|
48 const std::string& s);
|
|
49
|
|
50 bool ParseVector(Vector& target,
|
|
51 const Orthanc::DicomMap& dataset,
|
|
52 const Orthanc::DicomTag& tag);
|
|
53
|
|
54 void AssignVector(Vector& v,
|
|
55 double v1,
|
|
56 double v2);
|
|
57
|
|
58 void AssignVector(Vector& v,
|
|
59 double v1,
|
|
60 double v2,
|
|
61 double v3);
|
|
62
|
|
63 inline bool IsNear(double x,
|
|
64 double y,
|
|
65 double threshold)
|
|
66 {
|
|
67 return fabs(x - y) < threshold;
|
|
68 }
|
|
69
|
|
70 bool IsNear(double x,
|
|
71 double y);
|
|
72
|
|
73 inline bool IsCloseToZero(double x)
|
|
74 {
|
|
75 return IsNear(x, 0.0);
|
|
76 }
|
|
77
|
|
78 void NormalizeVector(Vector& u);
|
|
79
|
|
80 void CrossProduct(Vector& result,
|
|
81 const Vector& u,
|
|
82 const Vector& v);
|
|
83
|
|
84 void FillMatrix(Matrix& target,
|
|
85 size_t rows,
|
|
86 size_t columns,
|
|
87 const double values[]);
|
|
88
|
|
89 void FillVector(Vector& target,
|
|
90 size_t size,
|
|
91 const double values[]);
|
|
92
|
|
93 void Convert(Matrix& target,
|
|
94 const Vector& source);
|
|
95 };
|
|
96 }
|