comparison OrthancStone/Sources/Deprecated/Layers/SingleFrameRendererFactory.cpp @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Framework/Deprecated/Layers/SingleFrameRendererFactory.cpp@30deba7bc8e2
children
comparison
equal deleted inserted replaced
1511:9dfeee74c1e6 1512:244ad1e4e76a
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #include "SingleFrameRendererFactory.h"
23
24 #include "FrameRenderer.h"
25 #include "../Toolbox/MessagingToolbox.h"
26 #include "../Toolbox/DicomFrameConverter.h"
27
28 #include <OrthancException.h>
29 #include <FullOrthancDataset.h>
30 #include <DicomDatasetReader.h>
31
32 namespace Deprecated
33 {
34 SingleFrameRendererFactory::SingleFrameRendererFactory(OrthancPlugins::IOrthancConnection& orthanc,
35 const std::string& instanceId,
36 unsigned int frame) :
37 orthanc_(orthanc),
38 instance_(instanceId),
39 frame_(frame)
40 {
41 dicom_.reset(new OrthancPlugins::FullOrthancDataset(orthanc, "/instances/" + instanceId + "/tags"));
42
43 DicomFrameConverter converter;
44 converter.ReadParameters(*dicom_);
45 format_ = converter.GetExpectedPixelFormat();
46 }
47
48
49 bool SingleFrameRendererFactory::GetExtent(double& x1,
50 double& y1,
51 double& x2,
52 double& y2,
53 const SliceGeometry& viewportSlice)
54 {
55 // Assume that PixelSpacingX == PixelSpacingY == 1
56
57 OrthancPlugins::DicomDatasetReader reader(*dicom_);
58
59 unsigned int width, height;
60
61 if (!reader.GetUnsignedIntegerValue(width, OrthancPlugins::DICOM_TAG_COLUMNS) ||
62 !reader.GetUnsignedIntegerValue(height, OrthancPlugins::DICOM_TAG_ROWS))
63 {
64 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
65 }
66
67 x1 = 0;
68 y1 = 0;
69 x2 = static_cast<double>(width);
70 y2 = static_cast<double>(height);
71
72 return true;
73 }
74
75
76 ILayerRenderer* SingleFrameRendererFactory::CreateLayerRenderer(const SliceGeometry& viewportSlice)
77 {
78 SliceGeometry frameSlice(*dicom_);
79 return FrameRenderer::CreateRenderer(MessagingToolbox::DecodeFrame(orthanc_, instance_, frame_, format_),
80 frameSlice, *dicom_, 1, 1, true);
81 }
82
83
84 ISliceableVolume& SingleFrameRendererFactory::GetSourceVolume() const
85 {
86 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
87 }
88 }