Mercurial > hg > orthanc-stone
annotate UnitTestsSources/VolumeRenderingTests.cpp @ 1780:b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 May 2021 11:39:11 +0200 |
parents | 9ab251c03eda |
children | bf4b15b059ea |
rev | line source |
---|---|
1771
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
1772
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
22 #include "../OrthancStone/Sources/Scene2D/CairoCompositor.h" |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
23 #include "../OrthancStone/Sources/Scene2D/CopyStyleConfigurator.h" |
1775
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
24 #include "../OrthancStone/Sources/Scene2D/ColorTextureSceneLayer.h" |
1772
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
25 #include "../OrthancStone/Sources/Volumes/DicomVolumeImageMPRSlicer.h" |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
26 #include "../OrthancStone/Sources/Volumes/DicomVolumeImageReslicer.h" |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
27 |
1779
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
28 #include <Images/ImageProcessing.h> |
1772
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
29 #include <Images/ImageTraits.h> |
1778
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
30 #include <OrthancException.h> |
1772
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
31 |
1771
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 #include <gtest/gtest.h> |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
1778
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
34 |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
35 static float GetPixelValue(const Orthanc::ImageAccessor& image, |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
36 unsigned int x, |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
37 unsigned int y) |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
38 { |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
39 switch (image.GetFormat()) |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
40 { |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
41 case Orthanc::PixelFormat_Grayscale8: |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
42 return Orthanc::ImageTraits<Orthanc::PixelFormat_Grayscale8>::GetFloatPixel(image, x, y); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
43 |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
44 case Orthanc::PixelFormat_Float32: |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
45 return Orthanc::ImageTraits<Orthanc::PixelFormat_Float32>::GetFloatPixel(image, x, y); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
46 |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
47 case Orthanc::PixelFormat_RGB24: |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
48 { |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
49 Orthanc::PixelTraits<Orthanc::PixelFormat_RGB24>::PixelType pixel; |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
50 Orthanc::ImageTraits<Orthanc::PixelFormat_RGB24>::GetPixel(pixel, image, x, y); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
51 return pixel.red_; |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
52 } |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
53 |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
54 case Orthanc::PixelFormat_BGRA32: |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
55 { |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
56 Orthanc::PixelTraits<Orthanc::PixelFormat_BGRA32>::PixelType pixel; |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
57 Orthanc::ImageTraits<Orthanc::PixelFormat_BGRA32>::GetPixel(pixel, image, x, y); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
58 return pixel.red_; |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
59 } |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
60 |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
61 default: |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
62 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
63 } |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
64 } |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
65 |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
66 |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
67 static bool IsConstImage(float value, |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
68 const Orthanc::ImageAccessor& image) |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
69 { |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
70 for (unsigned int y = 0; y < image.GetHeight(); y++) |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
71 { |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
72 for (unsigned int x = 0; x < image.GetWidth(); x++) |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
73 { |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
74 if (!OrthancStone::LinearAlgebra::IsNear(value, GetPixelValue(image, x, y))) |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
75 { |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
76 return false; |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
77 } |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
78 } |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
79 } |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
80 |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
81 return true; |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
82 } |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
83 |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
84 |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
85 static bool IsConstRegion(float value, |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
86 const Orthanc::ImageAccessor& image, |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
87 unsigned int x, |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
88 unsigned int y, |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
89 unsigned int width, |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
90 unsigned int height) |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
91 { |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
92 Orthanc::ImageAccessor region; |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
93 image.GetRegion(region, x, y, width, height); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
94 return IsConstImage(value, region); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
95 } |
1779
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
96 |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
97 |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
98 static void Assign3x3Pattern(Orthanc::ImageAccessor& image) |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
99 { |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
100 if (image.GetFormat() == Orthanc::PixelFormat_Grayscale8 && |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
101 image.GetWidth() == 3 && |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
102 image.GetHeight() == 3) |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
103 { |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
104 unsigned int v = 0; |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
105 for (unsigned int y = 0; y < image.GetHeight(); y++) |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
106 { |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
107 uint8_t *p = reinterpret_cast<uint8_t*>(image.GetRow(y)); |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
108 for (unsigned int x = 0; x < image.GetWidth(); x++, p++) |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
109 { |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
110 *p = v; |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
111 v += 25; |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
112 } |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
113 } |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
114 } |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
115 else |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
116 { |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
117 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
118 } |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
119 } |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
120 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
121 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
122 static Orthanc::ImageAccessor* Render(const OrthancStone::Scene2D& scene, |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
123 unsigned int width, |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
124 unsigned int height) |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
125 { |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
126 OrthancStone::CairoCompositor compositor(width, height); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
127 compositor.Refresh(scene); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
128 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
129 Orthanc::ImageAccessor rendered; |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
130 compositor.GetCanvas().GetReadOnlyAccessor(rendered); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
131 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
132 return Orthanc::Image::Clone(rendered); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
133 } |
1778
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
134 |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
135 |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
136 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
137 // Render the scene using the identity viewpoint (default) |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
138 static Orthanc::ImageAccessor* Render(OrthancStone::ISceneLayer* layer, |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
139 unsigned int width, |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
140 unsigned int height) |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
141 { |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
142 OrthancStone::Scene2D scene; |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
143 scene.SetLayer(0, layer); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
144 return Render(scene, width, height); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
145 } |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
146 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
147 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
148 enum SlicerType |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
149 { |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
150 SlicerType_MPR = 0, |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
151 SlicerType_Reslicer = 1 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
152 }; |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
153 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
154 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
155 static OrthancStone::TextureBaseSceneLayer* SliceVolume(boost::shared_ptr<OrthancStone::DicomVolumeImage> volume, |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
156 const OrthancStone::CoordinateSystem3D& volumeCoordinates, |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
157 const OrthancStone::CoordinateSystem3D& cuttingPlane, |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
158 SlicerType type) |
1771
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 { |
1772
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
160 Orthanc::DicomMap dicom; |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
161 dicom.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, "study", false); |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
162 dicom.SetValue(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, "series", false); |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
163 dicom.SetValue(Orthanc::DICOM_TAG_SOP_INSTANCE_UID, "sop", false); |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
164 |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
165 volume->SetDicomParameters(OrthancStone::DicomInstanceParameters(dicom)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
166 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
167 std::unique_ptr<OrthancStone::IVolumeSlicer> slicer; |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
168 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
169 switch (type) |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
170 { |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
171 case SlicerType_MPR: |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
172 slicer.reset(new OrthancStone::DicomVolumeImageMPRSlicer(volume)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
173 break; |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
174 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
175 case SlicerType_Reslicer: |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
176 slicer.reset(new OrthancStone::DicomVolumeImageReslicer(volume)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
177 break; |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
178 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
179 default: |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
180 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
181 } |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
182 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
183 std::unique_ptr<OrthancStone::IVolumeSlicer::IExtractedSlice> slice(slicer->ExtractSlice(cuttingPlane)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
184 if (slice->IsValid()) |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
185 { |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
186 OrthancStone::CopyStyleConfigurator configurator; |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
187 return dynamic_cast<OrthancStone::TextureBaseSceneLayer*>(slice->CreateSceneLayer(&configurator, cuttingPlane)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
188 } |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
189 else |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
190 { |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
191 return NULL; |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
192 } |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
193 } |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
194 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
195 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
196 static OrthancStone::TextureBaseSceneLayer* Slice3x3x1Pattern(const OrthancStone::CoordinateSystem3D& volumeCoordinates, |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
197 const OrthancStone::CoordinateSystem3D& cuttingPlane, |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
198 SlicerType type) |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
199 { |
1772
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
200 OrthancStone::VolumeImageGeometry geometry; |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
201 geometry.SetSizeInVoxels(3, 3, 1); |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
202 geometry.SetAxialGeometry(volumeCoordinates); |
1775
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
203 |
1772
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
204 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume(new OrthancStone::DicomVolumeImage); |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
205 volume->Initialize(geometry, Orthanc::PixelFormat_Grayscale8, false); |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
206 |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
207 { |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
208 OrthancStone::ImageBuffer3D::SliceWriter writer(volume->GetPixelData(), OrthancStone::VolumeProjection_Axial, 0); |
1779
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
209 Assign3x3Pattern(writer.GetAccessor()); |
1772
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
210 } |
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
211 |
1775
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
212 OrthancStone::Vector v = volume->GetGeometry().GetVoxelDimensions(OrthancStone::VolumeProjection_Axial); |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
213 if (!OrthancStone::LinearAlgebra::IsNear(1, v[0]) || |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
214 !OrthancStone::LinearAlgebra::IsNear(1, v[1]) || |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
215 !OrthancStone::LinearAlgebra::IsNear(1, v[2])) |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
216 { |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
217 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
218 } |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
219 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
220 return SliceVolume(volume, volumeCoordinates, cuttingPlane, type); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
221 } |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
222 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
223 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
224 TEST(VolumeRendering, Axial) |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
225 { |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
226 OrthancStone::CoordinateSystem3D axial(OrthancStone::LinearAlgebra::CreateVector(-0.5, -0.5, 0), |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
227 OrthancStone::LinearAlgebra::CreateVector(1, 0, 0), |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
228 OrthancStone::LinearAlgebra::CreateVector(0, 1, 0)); |
1775
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
229 |
1774
95ece40bb298
DicomVolumeImageReslicer and DicomVolumeImageMPRSlicer behave identically on axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
230 for (unsigned int mode = 0; mode < 2; mode++) |
95ece40bb298
DicomVolumeImageReslicer and DicomVolumeImageMPRSlicer behave identically on axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
231 { |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
232 OrthancStone::CoordinateSystem3D cuttingPlane; |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
233 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
234 std::unique_ptr<OrthancStone::TextureBaseSceneLayer> layer(Slice3x3x1Pattern(axial, cuttingPlane, static_cast<SlicerType>(mode))); |
1772
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
235 |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
236 ASSERT_TRUE(layer.get() != NULL); |
1775
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
237 ASSERT_EQ(OrthancStone::ISceneLayer::Type_FloatTexture, layer->GetType()); |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
238 |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
239 OrthancStone::Extent2D box; |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
240 layer->GetBoundingBox(box); |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
241 ASSERT_FLOAT_EQ(-1.0f, box.GetX1()); |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
242 ASSERT_FLOAT_EQ(-1.0f, box.GetY1()); |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
243 ASSERT_FLOAT_EQ(2.0f, box.GetX2()); |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
244 ASSERT_FLOAT_EQ(2.0f, box.GetY2()); |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1774
diff
changeset
|
245 |
1774
95ece40bb298
DicomVolumeImageReslicer and DicomVolumeImageMPRSlicer behave identically on axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
246 { |
1778
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
247 const Orthanc::ImageAccessor& texture = dynamic_cast<OrthancStone::TextureBaseSceneLayer&>(*layer).GetTexture(); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
248 ASSERT_EQ(3u, texture.GetWidth()); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
249 ASSERT_EQ(3u, texture.GetHeight()); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
250 ASSERT_FLOAT_EQ(0, GetPixelValue(texture, 0, 0)); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
251 ASSERT_FLOAT_EQ(25, GetPixelValue(texture, 1, 0)); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
252 ASSERT_FLOAT_EQ(50, GetPixelValue(texture, 2, 0)); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
253 ASSERT_FLOAT_EQ(75, GetPixelValue(texture, 0, 1)); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
254 ASSERT_FLOAT_EQ(100, GetPixelValue(texture, 1, 1)); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
255 ASSERT_FLOAT_EQ(125, GetPixelValue(texture, 2, 1)); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
256 ASSERT_FLOAT_EQ(150, GetPixelValue(texture, 0, 2)); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
257 ASSERT_FLOAT_EQ(175, GetPixelValue(texture, 1, 2)); |
de5c965f0697
simplifying test VolumeRendering.Axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1775
diff
changeset
|
258 ASSERT_FLOAT_EQ(200, GetPixelValue(texture, 2, 2)); |
1774
95ece40bb298
DicomVolumeImageReslicer and DicomVolumeImageMPRSlicer behave identically on axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
259 } |
1772
6c246f862b00
unit test VolumeRendering.Basic
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1771
diff
changeset
|
260 |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
261 std::unique_ptr<Orthanc::ImageAccessor> rendered(Render(layer.release(), 5, 5)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
262 ASSERT_EQ(5u, rendered->GetWidth()); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
263 ASSERT_EQ(5u, rendered->GetHeight()); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
264 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 0, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
265 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 1, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
266 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 2, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
267 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 3, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
268 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 4, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
269 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 0, 1)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
270 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 1, 1)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
271 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 2, 1)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
272 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 3, 1)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
273 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 4, 1)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
274 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 0, 2)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
275 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 1, 2)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
276 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 2, 2)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
277 ASSERT_FLOAT_EQ(25, GetPixelValue(*rendered, 3, 2)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
278 ASSERT_FLOAT_EQ(50, GetPixelValue(*rendered, 4, 2)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
279 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 0, 3)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
280 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 1, 3)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
281 ASSERT_FLOAT_EQ(75, GetPixelValue(*rendered, 2, 3)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
282 ASSERT_FLOAT_EQ(100, GetPixelValue(*rendered, 3, 3)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
283 ASSERT_FLOAT_EQ(125, GetPixelValue(*rendered, 4, 3)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
284 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 0, 4)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
285 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 1, 4)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
286 ASSERT_FLOAT_EQ(150, GetPixelValue(*rendered, 2, 4)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
287 ASSERT_FLOAT_EQ(175, GetPixelValue(*rendered, 3, 4)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
288 ASSERT_FLOAT_EQ(200, GetPixelValue(*rendered, 4, 4)); |
1774
95ece40bb298
DicomVolumeImageReslicer and DicomVolumeImageMPRSlicer behave identically on axial
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1772
diff
changeset
|
289 } |
1771
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
290 } |
1779
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
291 |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
292 |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
293 TEST(VolumeRendering, TextureCorners) |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
294 { |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
295 // The origin of a 2D texture is the coordinate of the BORDER of the |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
296 // top-left pixel, *not* the center of the top-left pixel (as in |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
297 // DICOM 3D convention) |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
298 |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
299 Orthanc::Image pixel(Orthanc::PixelFormat_RGB24, 1, 1, false); |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
300 Orthanc::ImageProcessing::Set(pixel, 255, 0, 0, 255); |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
301 |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
302 { |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
303 std::unique_ptr<OrthancStone::ColorTextureSceneLayer> layer(new OrthancStone::ColorTextureSceneLayer(pixel)); |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
304 layer->SetOrigin(0, 0); |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
305 |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
306 std::unique_ptr<Orthanc::ImageAccessor> rendered(Render(layer.release(), 2, 2)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
307 ASSERT_EQ(2u, rendered->GetWidth()); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
308 ASSERT_EQ(2u, rendered->GetHeight()); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
309 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 0, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
310 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 1, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
311 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 0, 1)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
312 ASSERT_FLOAT_EQ(255, GetPixelValue(*rendered, 1, 1)); |
1779
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
313 } |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
314 |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
315 { |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
316 std::unique_ptr<OrthancStone::ColorTextureSceneLayer> layer(new OrthancStone::ColorTextureSceneLayer(pixel)); |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
317 layer->SetOrigin(-0.01, 0); |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
318 |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
319 std::unique_ptr<Orthanc::ImageAccessor> rendered(Render(layer.release(), 2, 2)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
320 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 0, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
321 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 1, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
322 ASSERT_FLOAT_EQ(255, GetPixelValue(*rendered, 0, 1)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
323 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 1, 1)); |
1779
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
324 } |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
325 |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
326 { |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
327 std::unique_ptr<OrthancStone::ColorTextureSceneLayer> layer(new OrthancStone::ColorTextureSceneLayer(pixel)); |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
328 layer->SetOrigin(-0.01, -0.01); |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
329 |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
330 std::unique_ptr<Orthanc::ImageAccessor> rendered(Render(layer.release(), 2, 2)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
331 ASSERT_FLOAT_EQ(255, GetPixelValue(*rendered, 0, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
332 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 1, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
333 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 0, 1)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
334 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 1, 1)); |
1779
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
335 } |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
336 |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
337 { |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
338 std::unique_ptr<OrthancStone::ColorTextureSceneLayer> layer(new OrthancStone::ColorTextureSceneLayer(pixel)); |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
339 layer->SetOrigin(0, -0.01); |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
340 |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
341 std::unique_ptr<Orthanc::ImageAccessor> rendered(Render(layer.release(), 2, 2)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
342 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 0, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
343 ASSERT_FLOAT_EQ(255, GetPixelValue(*rendered, 1, 0)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
344 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 0, 1)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
345 ASSERT_FLOAT_EQ(0, GetPixelValue(*rendered, 1, 1)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
346 } |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
347 } |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
348 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
349 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
350 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
351 TEST(VolumeRendering, FitTexture) |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
352 { |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
353 Orthanc::Image pixel(Orthanc::PixelFormat_RGB24, 1, 1, false); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
354 Orthanc::ImageProcessing::Set(pixel, 255, 0, 0, 255); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
355 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
356 { |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
357 std::unique_ptr<OrthancStone::ColorTextureSceneLayer> layer(new OrthancStone::ColorTextureSceneLayer(pixel)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
358 layer->SetOrigin(-42.0f, 35.0f); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
359 layer->SetPixelSpacing(2, 3); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
360 |
1779
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
361 OrthancStone::Scene2D scene; |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
362 scene.SetLayer(0, layer.release()); |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
363 scene.FitContent(30, 30); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
364 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
365 std::unique_ptr<Orthanc::ImageAccessor> rendered(Render(scene, 30, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
366 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 0, 5, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
367 ASSERT_TRUE(IsConstRegion(255.0f, *rendered, 5, 0, 20, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
368 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 25, 0, 5, 30)); |
1779
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
369 |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
370 rendered.reset(Render(scene, 40, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
371 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 0, 10, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
372 ASSERT_TRUE(IsConstRegion(255.0f, *rendered, 10, 0, 20, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
373 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 30, 0, 5, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
374 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
375 scene.FitContent(40, 30); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
376 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 0, 10, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
377 ASSERT_TRUE(IsConstRegion(255.0f, *rendered, 10, 0, 20, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
378 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 30, 0, 5, 30)); |
1779
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
379 |
1780
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
380 rendered.reset(Render(scene, 30, 36)); // The scene has not been fitted |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
381 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 0, 30, 3)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
382 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 0, 3, 36)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
383 ASSERT_TRUE(IsConstRegion(255.0f, *rendered, 5, 3, 20, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
384 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 25, 0, 5, 36)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
385 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 33, 30, 3)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
386 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
387 scene.FitContent(30, 36); // Refit |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
388 rendered.reset(Render(scene, 30, 36)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
389 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 0, 3, 36)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
390 ASSERT_TRUE(IsConstRegion(255.0f, *rendered, 3, 0, 24, 36)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
391 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 27, 0, 3, 36)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
392 } |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
393 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
394 { |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
395 std::unique_ptr<OrthancStone::ColorTextureSceneLayer> layer(new OrthancStone::ColorTextureSceneLayer(pixel)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
396 layer->SetOrigin(42.0f, -35.0f); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
397 layer->SetPixelSpacing(3, 2); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
398 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
399 OrthancStone::Scene2D scene; |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
400 scene.SetLayer(0, layer.release()); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
401 scene.FitContent(30, 30); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
402 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
403 std::unique_ptr<Orthanc::ImageAccessor> rendered(Render(scene, 30, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
404 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 0, 30, 5)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
405 ASSERT_TRUE(IsConstRegion(255.0f, *rendered, 0, 5, 30, 20)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
406 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 25, 30, 5)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
407 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
408 rendered.reset(Render(scene, 30, 40)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
409 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 0, 30, 10)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
410 ASSERT_TRUE(IsConstRegion(255.0f, *rendered, 0, 10, 30, 20)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
411 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 30, 30, 5)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
412 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
413 scene.FitContent(30, 40); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
414 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 0, 30, 10)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
415 ASSERT_TRUE(IsConstRegion(255.0f, *rendered, 0, 10, 30, 20)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
416 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 30, 30, 5)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
417 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
418 rendered.reset(Render(scene, 36, 30)); // The scene has not been fitted |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
419 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 0, 3, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
420 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 0, 36, 3)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
421 ASSERT_TRUE(IsConstRegion(255.0f, *rendered, 3, 5, 30, 20)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
422 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 25, 36, 5)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
423 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 33, 0, 3, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
424 |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
425 scene.FitContent(36, 30); // Refit |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
426 rendered.reset(Render(scene, 36, 30)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
427 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 0, 36, 3)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
428 ASSERT_TRUE(IsConstRegion(255.0f, *rendered, 0, 3, 36, 24)); |
b7c9fd1e9fb0
unit test VolumeRendering.FitTexture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1779
diff
changeset
|
429 ASSERT_TRUE(IsConstRegion(0.0f, *rendered, 0, 27, 36, 3)); |
1779
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
430 } |
9ab251c03eda
unit test VolumeRendering.TextureCorners
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1778
diff
changeset
|
431 } |