Mercurial > hg > orthanc-stone
annotate Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.cpp @ 1278:29cdd73d9477 bugs/2020-02-invisible-slice
DO NOT MERGE! Added global bool that enables
dumping the loaded texture histogram.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 04 Feb 2020 12:32:15 +0100 |
parents | 2d8ab34c8c91 |
children | 8e82fdc6200e |
rev | line source |
---|---|
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1048
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 #include "OpenGLLookupTableTextureRenderer.h" |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 |
1048
f6be9412e42a
cleaning up IObservable.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
947
diff
changeset
|
24 #include <Core/OrthancException.h> |
f6be9412e42a
cleaning up IObservable.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
947
diff
changeset
|
25 |
1278
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
26 |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
27 int OrthancStone_Internals_dump_LoadTexture_histogram = 0; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
28 |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 namespace OrthancStone |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 { |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 namespace Internals |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 { |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 void OpenGLLookupTableTextureRenderer::LoadTexture( |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 const LookupTableTextureSceneLayer& layer) |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
36 if (!context_.IsContextLost()) |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
38 const Orthanc::ImageAccessor& source = layer.GetTexture(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
39 const unsigned int width = source.GetWidth(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
40 const unsigned int height = source.GetHeight(); |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
42 if ((texture_.get() == NULL) || |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
43 (texture_->GetWidth() != width) || |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
44 (texture_->GetHeight() != height)) |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 { |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
47 texture_.reset(new Orthanc::Image( |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
48 Orthanc::PixelFormat_RGBA32, |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
49 width, |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
50 height, |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
51 false)); |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 } |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
54 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
55 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
56 const float a = layer.GetMinValue(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
57 float slope = 0; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
58 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
59 if (layer.GetMinValue() >= layer.GetMaxValue()) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
60 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
61 slope = 0; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
62 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
63 else |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
64 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
65 slope = 256.0f / (layer.GetMaxValue() - layer.GetMinValue()); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
66 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
67 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
68 Orthanc::ImageAccessor target; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
69 texture_->GetWriteableAccessor(target); |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
71 const std::vector<uint8_t>& lut = layer.GetLookupTable(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
72 if (lut.size() != 4 * 256) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
73 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
74 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
75 } |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
77 assert(source.GetFormat() == Orthanc::PixelFormat_Float32 && |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
78 target.GetFormat() == Orthanc::PixelFormat_RGBA32 && |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
79 sizeof(float) == 4); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
80 |
1278
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
81 |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
82 std::map<uint8_t, int> debugHistogram; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
83 if (OrthancStone_Internals_dump_LoadTexture_histogram == 1) |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
84 { |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
85 for (int i = 0; i <= 255; ++i) |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
86 { |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
87 uint8_t k = static_cast<uint8_t>(i); |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
88 debugHistogram[k] = 0; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
89 } |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
90 } |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
91 |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
92 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
93 for (unsigned int y = 0; y < height; y++) |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
95 const float* p = reinterpret_cast<const float*>(source.GetConstRow(y)); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
96 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
97 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
98 for (unsigned int x = 0; x < width; x++) |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
100 float v = (*p - a) * slope; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
101 if (v <= 0) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
102 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
103 v = 0; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
104 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
105 else if (v >= 255) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
106 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
107 v = 255; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
108 } |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
109 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
110 uint8_t vv = static_cast<uint8_t>(v); |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 |
1278
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
112 if(OrthancStone_Internals_dump_LoadTexture_histogram == 1) |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
113 debugHistogram[vv] += 1; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
114 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
115 q[0] = lut[4 * vv + 0]; // R |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
116 q[1] = lut[4 * vv + 1]; // G |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
117 q[2] = lut[4 * vv + 2]; // B |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
118 q[3] = lut[4 * vv + 3]; // A |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
119 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
120 p++; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
121 q += 4; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
122 } |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 } |
1278
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
124 |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
125 if (OrthancStone_Internals_dump_LoadTexture_histogram == 1) |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
126 { |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
127 uint8_t vv; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
128 LOG(INFO) << "Dumping texture loaded with OpenGLLookupTableTextureRenderer::LoadTexture"; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
129 for (int i = 0; i <= 255; ++i) |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
130 { |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
131 vv = static_cast<uint8_t>(i); |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
132 int ivv = vv; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
133 int count = debugHistogram[vv]; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
134 int lutr = lut[4 * vv + 0]; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
135 int lutg = lut[4 * vv + 1]; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
136 int lutb = lut[4 * vv + 2]; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
137 int luta = lut[4 * vv + 3]; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
138 |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
139 LOG(ERROR) << "This is no error! Y= " << ivv << " count= " << count |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
140 << " lut R= " << lutr << " lut G= " << lutg << " lut B= " << lutb << " lut A= " << luta; |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
141 } |
29cdd73d9477
DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
142 } |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 } |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
144 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
145 context_.MakeCurrent(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
146 glTexture_.reset(new OpenGL::OpenGLTexture(context_)); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
147 glTexture_->Load(*texture_, layer.IsLinearInterpolation()); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
148 layerTransform_ = layer.GetTransform(); |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 } |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
150 } |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
151 |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
152 OpenGLLookupTableTextureRenderer::OpenGLLookupTableTextureRenderer( |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
153 OpenGL::IOpenGLContext& context, |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
154 OpenGLColorTextureProgram& program, |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
155 const LookupTableTextureSceneLayer& layer) |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
156 : context_(context) |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
157 , program_(program) |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
158 { |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
159 LoadTexture(layer); |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
160 } |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
161 |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 |
888
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
841
diff
changeset
|
163 void OpenGLLookupTableTextureRenderer::Render(const AffineTransform2D& transform, |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
841
diff
changeset
|
164 unsigned int canvasWidth, |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
841
diff
changeset
|
165 unsigned int canvasHeight) |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
166 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
888
diff
changeset
|
167 if (!context_.IsContextLost() && glTexture_.get() != NULL) |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
168 { |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
169 program_.Apply( |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
170 *glTexture_, |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
171 AffineTransform2D::Combine(transform, layerTransform_), |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
172 true); |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
173 } |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
174 } |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
175 |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
176 |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
177 void OpenGLLookupTableTextureRenderer::Update(const ISceneLayer& layer) |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
178 { |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
179 // Should never happen (no revisions in color textures) |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
180 LoadTexture(dynamic_cast<const LookupTableTextureSceneLayer&>(layer)); |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 } |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
182 } |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
183 } |