annotate Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.cpp @ 1287:8e82fdc6200e bugs/2020-02-invisible-slice

Heavy (temporary) logging in the path that leads from multiframe volume to slice (rendered texture)
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 14 Feb 2020 15:00:54 +0100
parents 29cdd73d9477
children 343aa1dfaa90
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1287
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
24 #include "../../Toolbox/ImageToolbox.h"
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
25
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
26
1048
f6be9412e42a cleaning up IObservable.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 947
diff changeset
27 #include <Core/OrthancException.h>
f6be9412e42a cleaning up IObservable.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 947
diff changeset
28
1278
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
29
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
30 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
31
841
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32 namespace OrthancStone
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33 {
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 namespace Internals
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 {
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 void OpenGLLookupTableTextureRenderer::LoadTexture(
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 const LookupTableTextureSceneLayer& layer)
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
39 if (!context_.IsContextLost())
841
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
41 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
42 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
43 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
44
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
45 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
46 (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
47 (texture_->GetHeight() != height))
841
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 {
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
50 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
51 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
52 width,
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
53 height,
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
54 false));
841
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 }
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
57 {
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 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
60 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
61
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
62 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
63 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
64 slope = 0;
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
65 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
66 else
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 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
69 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
70
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
71 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
72 texture_->GetWriteableAccessor(target);
841
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
74 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
75 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
76 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
77 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
78 }
841
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
80 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
81 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
82 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
83
1278
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 std::map<uint8_t, int> debugHistogram;
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
86 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
87 {
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
88 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
89 {
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
90 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
91 debugHistogram[k] = 0;
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
92 }
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
93 }
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
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 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
96 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
97 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
98 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
99
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
100 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
101 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
102 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
103 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
104 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
105 v = 0;
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 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
108 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
109 v = 255;
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
110 }
841
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
111
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
112 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
113
1287
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
114 if (OrthancStone_Internals_dump_LoadTexture_histogram == 1)
1278
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
115 debugHistogram[vv] += 1;
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
116
1287
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
117
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
118 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
119 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
120 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
121 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
122
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
123 p++;
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
124 q += 4;
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
125 }
841
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
126 }
1278
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
127
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
128 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
129 {
1287
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
130 LOG(ERROR) << "+----------------------------------------+";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
131 LOG(ERROR) << "| This is not an error! |";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
132 LOG(ERROR) << "+----------------------------------------+";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
133 LOG(ERROR) << "Work on the \"invisible slice\" bug";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
134 LOG(ERROR) << "--> in OpenGLLookupTableTextureRenderer::LoadTexture():";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
135 LOG(ERROR) << "layer.GetMinValue() = " << layer.GetMinValue() << " | layer.GetMaxValue() = " << layer.GetMaxValue();
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
136 LOG(ERROR) << "a = " << a << " | slope = " << slope;
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
137
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
138 LOG(ERROR) << "SOURCE gets scaled and offset, this yields --> TEMP that gets through the lut to yield RESULT";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
139 LOG(ERROR) << "The SOURCE (layer.GetTexture()) will be dumped below (format is Float32)";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
140 LOG(ERROR) << "";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
141 HistogramData hd;
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
142 double minValue = 0;
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
143 double maxValue = 0;
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
144 ComputeMinMax(source, minValue, maxValue);
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
145 double binSize = (maxValue - minValue) * 0.01; // split in 100 bins
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
146 ComputeHistogram(source, hd, binSize);
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
147 std::string s;
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
148 DumpHistogramResult(s, hd);
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
149 LOG(ERROR) << s;
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
150 LOG(ERROR) << "";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
151
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
152
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
153 LOG(ERROR) << "TEMP will be dumped below (format is uint8_t)";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
154 LOG(ERROR) << "";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
155
1278
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
156 {
1287
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
157 uint8_t vv = 0;
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
158 do
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
159 {
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
160 LOG(ERROR) << " TEMP. Pixel " << (int)vv << " is present "
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
161 << debugHistogram[vv] << " times";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
162 } while (vv++ != 255);
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
163 }
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
164
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
165 LOG(ERROR) << "\nThe LUT will be dumped below";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
166 LOG(ERROR) << "----------------------------";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
167 LOG(ERROR) << "";
1278
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
168
1287
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
169 {
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
170 uint8_t vv = 0;
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
171 // proper way to loop on all unsigned values is a do while loop
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
172 do
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
173 {
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
174 LOG(ERROR) << " LUT[" << (int)vv << "] ="
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
175 << " R:" << (int)lut[4 * vv + 0]
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
176 << " G:" << (int)lut[4 * vv + 1]
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
177 << " B:" << (int)lut[4 * vv + 2]
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
178 << " A:" << (int)lut[4 * vv + 3];
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
179 } while (vv++ != 255);
1278
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
180 }
1287
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
181 LOG(ERROR) << "+----------------------------------------+";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
182 LOG(ERROR) << "| end of debug dump |";
8e82fdc6200e Heavy (temporary) logging in the path that leads
Benjamin Golinvaux <bgo@osimis.io>
parents: 1278
diff changeset
183 LOG(ERROR) << "+----------------------------------------+";
1278
29cdd73d9477 DO NOT MERGE! Added global bool that enables
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
184 }
841
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
185 }
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
186
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
187 context_.MakeCurrent();
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
188 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
189 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
190 layerTransform_ = layer.GetTransform();
841
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
191 }
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
192 }
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
193
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
194 OpenGLLookupTableTextureRenderer::OpenGLLookupTableTextureRenderer(
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
195 OpenGL::IOpenGLContext& context,
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
196 OpenGLColorTextureProgram& program,
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
197 const LookupTableTextureSceneLayer& layer)
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
198 : context_(context)
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
199 , program_(program)
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
200 {
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
201 LoadTexture(layer);
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
202 }
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
203
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
204
888
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 841
diff changeset
205 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
206 unsigned int canvasWidth,
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 841
diff changeset
207 unsigned int canvasHeight)
841
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
208 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 888
diff changeset
209 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
210 {
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
211 program_.Apply(
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
212 *glTexture_,
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
213 AffineTransform2D::Combine(transform, layerTransform_),
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
214 true);
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
215 }
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
216 }
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
217
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
218
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
219 void OpenGLLookupTableTextureRenderer::Update(const ISceneLayer& layer)
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
220 {
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
221 // 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
222 LoadTexture(dynamic_cast<const LookupTableTextureSceneLayer&>(layer));
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
223 }
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
224 }
266e2b0b9abc better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
225 }