Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/TextureBaseSceneLayer.h @ 1871:7053b8a0aaec
upgrade to year 2022
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Jan 2022 11:18:48 +0100 |
parents | 3889ae96d2e9 |
children | 07964689cb0b |
rev | line source |
---|---|
590 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
590 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
590 | 10 * as published by the Free Software Foundation, either version 3 of |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
16 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
17 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
590 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #include "ISceneLayer.h" | |
27 #include "../Toolbox/AffineTransform2D.h" | |
1769 | 28 #include "../Toolbox/CoordinateSystem3D.h" |
590 | 29 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1298
diff
changeset
|
30 #include <Compatibility.h> |
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1298
diff
changeset
|
31 #include <Images/ImageAccessor.h> |
590 | 32 |
33 namespace OrthancStone | |
34 { | |
35 class TextureBaseSceneLayer : public ISceneLayer | |
36 { | |
37 private: | |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
38 std::unique_ptr<Orthanc::ImageAccessor> texture_; |
590 | 39 double originX_; |
40 double originY_; | |
41 double pixelSpacingX_; | |
42 double pixelSpacingY_; | |
43 double angle_; | |
44 bool isLinearInterpolation_; | |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
45 bool flipX_; |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
46 bool flipY_; |
590 | 47 uint64_t revision_; |
1768
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
48 std::unique_ptr<AffineTransform2D> transform_; // Manually-specified transformation |
590 | 49 |
1787
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1777
diff
changeset
|
50 void CheckNoManualTransform() const; |
6e8105942146
safeguard in TextureBaseSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1777
diff
changeset
|
51 |
590 | 52 protected: |
53 void SetTexture(Orthanc::ImageAccessor* texture); | |
54 | |
55 void IncrementRevision() | |
56 { | |
57 revision_++; | |
58 } | |
59 | |
60 void CopyParameters(const TextureBaseSceneLayer& other); | |
61 | |
62 public: | |
63 TextureBaseSceneLayer(); | |
64 | |
65 // Center of the top-left pixel | |
66 void SetOrigin(double x, | |
67 double y); | |
68 | |
69 void SetPixelSpacing(double sx, | |
70 double sy); | |
71 | |
72 // In radians | |
73 void SetAngle(double angle); | |
74 | |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
75 void SetFlipX(bool flip); |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
76 |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
77 void SetFlipY(bool flip); |
590 | 78 |
79 double GetOriginX() const | |
80 { | |
81 return originX_; | |
82 } | |
83 | |
84 double GetOriginY() const | |
85 { | |
86 return originY_; | |
87 } | |
88 | |
89 double GetPixelSpacingX() const | |
90 { | |
91 return pixelSpacingX_; | |
92 } | |
93 | |
94 double GetPixelSpacingY() const | |
95 { | |
96 return pixelSpacingY_; | |
97 } | |
98 | |
99 double GetAngle() const | |
100 { | |
101 return angle_; | |
102 } | |
103 | |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
104 bool IsFlipX() const |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
105 { |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
106 return flipX_; |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
107 } |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
108 |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
109 bool IsFlipY() const |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
110 { |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
111 return flipY_; |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
112 } |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
113 |
1775
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
114 bool IsLinearInterpolation() const |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
115 { |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
116 return isLinearInterpolation_; |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
117 } |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
118 |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
119 void SetLinearInterpolation(bool isLinearInterpolation); |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
120 |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
121 bool HasTexture() const |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
122 { |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
123 return (texture_.get() != NULL); |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
124 } |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
125 |
590 | 126 const Orthanc::ImageAccessor& GetTexture() const; |
127 | |
1768
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
128 void SetTransform(const AffineTransform2D& transform); |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
129 |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
130 void ClearTransform(); |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
131 |
1775
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
132 /** |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
133 * Initialize a transform that maps a texture slice in 3D, to a |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
134 * cutting plane (the cutting plane should be parallel to the 3D |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
135 * slice). The "pixelOffsetX/Y" must take pixel spacing into |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
136 * account. This method automatically converts from voxel centers |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
137 * (3D) to pixel corners (2D). |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
138 **/ |
1769 | 139 void SetCuttingPlaneTransform(const CoordinateSystem3D& cuttingPlane, |
140 const Vector& origin, // coordinates of the center of the voxel | |
141 const Vector& pixelOffsetX, // 3D offset from (0,0) voxel to (1,0) voxel | |
142 const Vector& pixelOffsetY); // 3D offset from (0,0) voxel to (0,1) voxel | |
143 | |
590 | 144 AffineTransform2D GetTransform() const; |
145 | |
1610
b7630b1a0253
ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
146 virtual void GetBoundingBox(Extent2D& target) const ORTHANC_OVERRIDE; |
590 | 147 |
1571 | 148 virtual uint64_t GetRevision() const ORTHANC_OVERRIDE |
590 | 149 { |
150 return revision_; | |
151 } | |
152 }; | |
153 } |