Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Toolbox/CoordinateSystem3D.h @ 1512:244ad1e4e76a
reorganization of folders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 16:21:02 +0200 |
parents | Framework/Toolbox/CoordinateSystem3D.h@d8af188ab545 |
children | 85e117739eca |
comparison
equal
deleted
inserted
replaced
1511:9dfeee74c1e6 | 1512:244ad1e4e76a |
---|---|
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-2020 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 #include "../Scene2D/ScenePoint2D.h" | |
25 #include "LinearAlgebra.h" | |
26 #include "OrthancDatasets/IDicomDataset.h" | |
27 | |
28 #include <iosfwd> | |
29 | |
30 namespace OrthancStone | |
31 { | |
32 // Geometry of a 3D plane | |
33 class CoordinateSystem3D | |
34 { | |
35 private: | |
36 Vector origin_; | |
37 Vector normal_; | |
38 Vector axisX_; | |
39 Vector axisY_; | |
40 double d_; | |
41 | |
42 void CheckAndComputeNormal(); | |
43 | |
44 void Setup(const std::string& imagePositionPatient, | |
45 const std::string& imageOrientationPatient); | |
46 | |
47 void SetupCanonical(); | |
48 | |
49 double GetOffset() const; | |
50 | |
51 public: | |
52 CoordinateSystem3D() | |
53 { | |
54 SetupCanonical(); | |
55 } | |
56 | |
57 friend std::ostream& operator<< (std::ostream& s, const CoordinateSystem3D& that); | |
58 | |
59 CoordinateSystem3D(const Vector& origin, | |
60 const Vector& axisX, | |
61 const Vector& axisY); | |
62 | |
63 CoordinateSystem3D(const IDicomDataset& dicom); | |
64 | |
65 CoordinateSystem3D(const std::string& imagePositionPatient, | |
66 const std::string& imageOrientationPatient) | |
67 { | |
68 Setup(imagePositionPatient, imageOrientationPatient); | |
69 } | |
70 | |
71 CoordinateSystem3D(const Orthanc::DicomMap& dicom); | |
72 | |
73 const Vector& GetNormal() const | |
74 { | |
75 return normal_; | |
76 } | |
77 | |
78 const Vector& GetOrigin() const // This is the "Image Position Patient" tag | |
79 { | |
80 return origin_; | |
81 } | |
82 | |
83 const Vector& GetAxisX() const | |
84 { | |
85 return axisX_; | |
86 } | |
87 | |
88 const Vector& GetAxisY() const | |
89 { | |
90 return axisY_; | |
91 } | |
92 | |
93 void SetOrigin(const Vector& origin); | |
94 | |
95 Vector MapSliceToWorldCoordinates(double x, | |
96 double y) const; | |
97 | |
98 Vector MapSliceToWorldCoordinates(const ScenePoint2D& p) const | |
99 { | |
100 return MapSliceToWorldCoordinates(p.GetX(), p.GetY()); | |
101 } | |
102 | |
103 double ProjectAlongNormal(const Vector& point) const; | |
104 | |
105 void ProjectPoint(double& offsetX, | |
106 double& offsetY, | |
107 const Vector& point) const; | |
108 | |
109 ScenePoint2D ProjectPoint(const Vector& point) const | |
110 { | |
111 double x, y; | |
112 ProjectPoint(x, y, point); | |
113 return ScenePoint2D(x, y); | |
114 } | |
115 | |
116 /* | |
117 Alternated faster implementation (untested yet) | |
118 */ | |
119 void ProjectPoint2(double& offsetX, | |
120 double& offsetY, | |
121 const Vector& point) const; | |
122 | |
123 bool IntersectSegment(Vector& p, | |
124 const Vector& edgeFrom, | |
125 const Vector& edgeTo) const; | |
126 | |
127 bool IntersectLine(Vector& p, | |
128 const Vector& origin, | |
129 const Vector& direction) const; | |
130 | |
131 // Returns "false" is the two planes are not parallel | |
132 static bool ComputeDistance(double& distance, | |
133 const CoordinateSystem3D& a, | |
134 const CoordinateSystem3D& b); | |
135 | |
136 // Normalize a cutting plane so that the origin (0,0,0) of the 3D | |
137 // world is mapped to the origin of its (x,y) coordinate system | |
138 static CoordinateSystem3D NormalizeCuttingPlane(const CoordinateSystem3D& plane); | |
139 }; | |
140 } |