annotate Framework/Loaders/OrthancMultiframeVolumeLoader.cpp @ 1145:4f99c7905f8d broker

mingw qt
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 12 Nov 2019 18:28:46 +0100
parents 8e3763d1736a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "OrthancMultiframeVolumeLoader.h"
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
816
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 815
diff changeset
24 #include <Core/Endianness.h>
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include <Core/Toolbox.h>
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 namespace OrthancStone
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 class OrthancMultiframeVolumeLoader::LoadRTDoseGeometry : public LoaderStateMachine::State
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 private:
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 std::auto_ptr<Orthanc::DicomMap> dicom_;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 public:
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 LoadRTDoseGeometry(OrthancMultiframeVolumeLoader& that,
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 Orthanc::DicomMap* dicom) :
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 State(that),
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 dicom_(dicom)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 if (dicom == NULL)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 // Complete the DICOM tags with just-received "Grid Frame Offset Vector"
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 std::string s = Orthanc::Toolbox::StripSpaces(message.GetAnswer());
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 dicom_->SetValue(Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR, s, false);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 GetLoader<OrthancMultiframeVolumeLoader>().SetGeometry(*dicom_);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 };
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 static std::string GetSopClassUid(const Orthanc::DicomMap& dicom)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 std::string s;
994
1f74bc3459ba fix build due to rename in Orthanc::DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 956
diff changeset
61 if (!dicom.LookupStringValue(s, Orthanc::DICOM_TAG_SOP_CLASS_UID, false))
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat,
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 "DICOM file without SOP class UID");
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 else
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 return s;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 class OrthancMultiframeVolumeLoader::LoadGeometry : public State
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 public:
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 LoadGeometry(OrthancMultiframeVolumeLoader& that) :
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 State(that)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 OrthancMultiframeVolumeLoader& loader = GetLoader<OrthancMultiframeVolumeLoader>();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 Json::Value body;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 message.ParseJsonBody(body);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 if (body.type() != Json::objectValue)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 std::auto_ptr<Orthanc::DicomMap> dicom(new Orthanc::DicomMap);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 dicom->FromDicomAsJson(body);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 if (StringToSopClassUid(GetSopClassUid(*dicom)) == SopClassUid_RTDose)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 // Download the "Grid Frame Offset Vector" DICOM tag, that is
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 // mandatory for RT-DOSE, but is too long to be returned by default
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 command->SetUri("/instances/" + loader.GetInstanceId() + "/content/" +
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR.Format());
1128
8e3763d1736a removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1117
diff changeset
104 command->AcquirePayload(new LoadRTDoseGeometry(loader, dicom.release()));
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 Schedule(command.release());
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 else
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 loader.SetGeometry(*dicom);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 };
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 class OrthancMultiframeVolumeLoader::LoadTransferSyntax : public State
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 public:
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 LoadTransferSyntax(OrthancMultiframeVolumeLoader& that) :
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 State(that)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 GetLoader<OrthancMultiframeVolumeLoader>().SetTransferSyntax(message.GetAnswer());
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 };
925
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
128
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 class OrthancMultiframeVolumeLoader::LoadUncompressedPixelData : public State
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 public:
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 LoadUncompressedPixelData(OrthancMultiframeVolumeLoader& that) :
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 State(that)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 GetLoader<OrthancMultiframeVolumeLoader>().SetUncompressedPixelData(message.GetAnswer());
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 };
925
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
142
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 const std::string& OrthancMultiframeVolumeLoader::GetInstanceId() const
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 if (IsActive())
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 return instanceId_;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 else
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 {
956
a7351ad54960 Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents: 949
diff changeset
151 LOG(ERROR) << "OrthancMultiframeVolumeLoader::GetInstanceId(): (!IsActive())";
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 void OrthancMultiframeVolumeLoader::ScheduleFrameDownloads()
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 if (transferSyntaxUid_.empty() ||
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 !volume_->HasGeometry())
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 return;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 /*
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 1.2.840.10008.1.2 Implicit VR Endian: Default Transfer Syntax for DICOM
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 1.2.840.10008.1.2.1 Explicit VR Little Endian
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 1.2.840.10008.1.2.2 Explicit VR Big Endian
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 See https://www.dicomlibrary.com/dicom/transfer-syntax/
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 */
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 if (transferSyntaxUid_ == "1.2.840.10008.1.2" ||
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 transferSyntaxUid_ == "1.2.840.10008.1.2.1" ||
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 transferSyntaxUid_ == "1.2.840.10008.1.2.2")
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 command->SetHttpHeader("Accept-Encoding", "gzip");
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 command->SetUri("/instances/" + instanceId_ + "/content/" +
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 Orthanc::DICOM_TAG_PIXEL_DATA.Format() + "/0");
1128
8e3763d1736a removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1117
diff changeset
178 command->AcquirePayload(new LoadUncompressedPixelData(*this));
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 Schedule(command.release());
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 else
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 throw Orthanc::OrthancException(
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 Orthanc::ErrorCode_NotImplemented,
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 "No support for multiframe instances with transfer syntax: " + transferSyntaxUid_);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 void OrthancMultiframeVolumeLoader::SetTransferSyntax(const std::string& transferSyntax)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 transferSyntaxUid_ = Orthanc::Toolbox::StripSpaces(transferSyntax);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 ScheduleFrameDownloads();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 void OrthancMultiframeVolumeLoader::SetGeometry(const Orthanc::DicomMap& dicom)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 DicomInstanceParameters parameters(dicom);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 volume_->SetDicomParameters(parameters);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 Orthanc::PixelFormat format;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 if (!parameters.GetImageInformation().ExtractPixelFormat(format, true))
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 double spacingZ;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 switch (parameters.GetSopClassUid())
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 case SopClassUid_RTDose:
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 spacingZ = parameters.GetThickness();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 break;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 default:
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 throw Orthanc::OrthancException(
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 Orthanc::ErrorCode_NotImplemented,
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 "No support for multiframe instances with SOP class UID: " + GetSopClassUid(dicom));
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 const unsigned int width = parameters.GetImageInformation().GetWidth();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 const unsigned int height = parameters.GetImageInformation().GetHeight();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 const unsigned int depth = parameters.GetImageInformation().GetNumberOfFrames();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 VolumeImageGeometry geometry;
949
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
225 geometry.SetSizeInVoxels(width, height, depth);
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 geometry.SetAxialGeometry(parameters.GetGeometry());
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 geometry.SetVoxelDimensions(parameters.GetPixelSpacingX(),
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 parameters.GetPixelSpacingY(), spacingZ);
1072
391fb6d6905d OrthancMultiframeVolumeLoader asks volume image to compute range +
Benjamin Golinvaux <bgo@osimis.io>
parents: 994
diff changeset
229 volume_->Initialize(geometry, format, true /* Do compute range */);
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 volume_->GetPixelData().Clear();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 ScheduleFrameDownloads();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235
949
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
236
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
237
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 BroadcastMessage(DicomVolumeImage::GeometryReadyMessage(*volume_));
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 ORTHANC_FORCE_INLINE
925
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
243 static void CopyPixel(uint32_t& target, const void* source)
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 // TODO - check alignement?
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 target = le32toh(*reinterpret_cast<const uint32_t*>(source));
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 }
925
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
248
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
249 ORTHANC_FORCE_INLINE
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
250 static void CopyPixel(uint16_t& target, const void* source)
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
251 {
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
252 // TODO - check alignement?
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
253 target = le16toh(*reinterpret_cast<const uint16_t*>(source));
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
254 }
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255
1114
33b0a762e98a Added support for signed 16-bit pixels/voxels in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1072
diff changeset
256 ORTHANC_FORCE_INLINE
33b0a762e98a Added support for signed 16-bit pixels/voxels in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1072
diff changeset
257 static void CopyPixel(int16_t& target, const void* source)
33b0a762e98a Added support for signed 16-bit pixels/voxels in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1072
diff changeset
258 {
33b0a762e98a Added support for signed 16-bit pixels/voxels in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1072
diff changeset
259 // byte swapping is the same for unsigned and signed integers
33b0a762e98a Added support for signed 16-bit pixels/voxels in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1072
diff changeset
260 // (the sign bit is always stored with the MSByte)
33b0a762e98a Added support for signed 16-bit pixels/voxels in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1072
diff changeset
261 uint16_t* targetUp = reinterpret_cast<uint16_t*>(&target);
33b0a762e98a Added support for signed 16-bit pixels/voxels in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1072
diff changeset
262 CopyPixel(*targetUp, source);
33b0a762e98a Added support for signed 16-bit pixels/voxels in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1072
diff changeset
263 }
33b0a762e98a Added support for signed 16-bit pixels/voxels in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1072
diff changeset
264
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 template <typename T>
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 void OrthancMultiframeVolumeLoader::CopyPixelData(const std::string& pixelData)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 ImageBuffer3D& target = volume_->GetPixelData();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 const unsigned int bpp = target.GetBytesPerPixel();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 const unsigned int width = target.GetWidth();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 const unsigned int height = target.GetHeight();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 const unsigned int depth = target.GetDepth();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 if (pixelData.size() != bpp * width * height * depth)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat,
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 "The pixel data has not the proper size");
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 if (pixelData.empty())
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 return;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 const uint8_t* source = reinterpret_cast<const uint8_t*>(pixelData.c_str());
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 for (unsigned int z = 0; z < depth; z++)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 ImageBuffer3D::SliceWriter writer(target, VolumeProjection_Axial, z);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 assert (writer.GetAccessor().GetWidth() == width &&
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 writer.GetAccessor().GetHeight() == height);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 for (unsigned int y = 0; y < height; y++)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 assert(sizeof(T) == Orthanc::GetBytesPerPixel(target.GetFormat()));
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 T* target = reinterpret_cast<T*>(writer.GetAccessor().GetRow(y));
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 for (unsigned int x = 0; x < width; x++)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 CopyPixel(*target, source);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 target ++;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 source += bpp;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 void OrthancMultiframeVolumeLoader::SetUncompressedPixelData(const std::string& pixelData)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 switch (volume_->GetPixelData().GetFormat())
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 case Orthanc::PixelFormat_Grayscale32:
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 CopyPixelData<uint32_t>(pixelData);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 break;
925
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
318 case Orthanc::PixelFormat_Grayscale16:
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
319 CopyPixelData<uint16_t>(pixelData);
4639d0bf6390 Added support for Grayscale16 in the multiframe loader (Victor)
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
320 break;
1114
33b0a762e98a Added support for signed 16-bit pixels/voxels in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1072
diff changeset
321 case Orthanc::PixelFormat_SignedGrayscale16:
33b0a762e98a Added support for signed 16-bit pixels/voxels in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1072
diff changeset
322 CopyPixelData<int16_t>(pixelData);
33b0a762e98a Added support for signed 16-bit pixels/voxels in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents: 1072
diff changeset
323 break;
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 default:
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 volume_->IncrementRevision();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329
937
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
330 pixelDataLoaded_ = true;
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 BroadcastMessage(DicomVolumeImage::ContentUpdatedMessage(*volume_));
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 }
949
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
333
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
334 bool OrthancMultiframeVolumeLoader::HasGeometry() const
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
335 {
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
336 return volume_->HasGeometry();
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
337 }
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338
949
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
339 const OrthancStone::VolumeImageGeometry& OrthancMultiframeVolumeLoader::GetImageGeometry() const
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
340 {
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
341 return volume_->GetGeometry();
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
342 }
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343
921
81d30cd93b65 Ability to ask the loader for the geometry in PULL mode (when subscribing to the messages is not possible) + small changes (removed const/ref qualifiers for boost::shared_ptr param, added traces, doc change)
Benjamin Golinvaux <bgo@osimis.io>
parents: 816
diff changeset
344 OrthancMultiframeVolumeLoader::OrthancMultiframeVolumeLoader(boost::shared_ptr<DicomVolumeImage> volume,
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 IOracle& oracle,
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 IObservable& oracleObservable) :
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 LoaderStateMachine(oracle, oracleObservable),
937
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
348 volume_(volume),
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
349 pixelDataLoaded_(false)
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 if (volume.get() == NULL)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356
935
401808e7ff2e Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents: 925
diff changeset
357 OrthancMultiframeVolumeLoader::~OrthancMultiframeVolumeLoader()
401808e7ff2e Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents: 925
diff changeset
358 {
401808e7ff2e Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents: 925
diff changeset
359 LOG(TRACE) << "OrthancMultiframeVolumeLoader::~OrthancMultiframeVolumeLoader()";
401808e7ff2e Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents: 925
diff changeset
360 }
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 void OrthancMultiframeVolumeLoader::LoadInstance(const std::string& instanceId)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 Start();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 instanceId_ = instanceId;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 command->SetHttpHeader("Accept-Encoding", "gzip");
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 command->SetUri("/instances/" + instanceId + "/tags");
1128
8e3763d1736a removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1117
diff changeset
372 command->AcquirePayload(new LoadGeometry(*this));
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 Schedule(command.release());
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 command->SetUri("/instances/" + instanceId + "/metadata/TransferSyntax");
1128
8e3763d1736a removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1117
diff changeset
379 command->AcquirePayload(new LoadTransferSyntax(*this));
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 Schedule(command.release());
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 }