Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Volumes/DicomVolumeImage.cpp @ 1619:4c9e68291467
Added code to remove the wheel callback in dtor, to prevent access to dead object
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 02 Nov 2020 17:55:35 +0100 |
parents | 8563ea5d8ae4 |
children | 59f95b9ea858 |
rev | line source |
---|---|
814 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1072
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
814 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
814 | 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 | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
814 | 20 **/ |
21 | |
22 | |
23 #include "DicomVolumeImage.h" | |
24 | |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
25 #include <OrthancException.h> |
814 | 26 |
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:
814
diff
changeset
|
27 |
814 | 28 namespace OrthancStone |
29 { | |
30 void DicomVolumeImage::CheckHasGeometry() const | |
31 { | |
32 if (!HasGeometry()) | |
33 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
34 LOG(ERROR) << "DicomVolumeImage::CheckHasGeometry(): (!HasGeometry())"; |
814 | 35 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
36 } | |
37 } | |
38 | |
39 | |
1072
391fb6d6905d
OrthancMultiframeVolumeLoader asks volume image to compute range +
Benjamin Golinvaux <bgo@osimis.io>
parents:
1048
diff
changeset
|
40 void DicomVolumeImage::Initialize( |
391fb6d6905d
OrthancMultiframeVolumeLoader asks volume image to compute range +
Benjamin Golinvaux <bgo@osimis.io>
parents:
1048
diff
changeset
|
41 const VolumeImageGeometry& geometry, |
391fb6d6905d
OrthancMultiframeVolumeLoader asks volume image to compute range +
Benjamin Golinvaux <bgo@osimis.io>
parents:
1048
diff
changeset
|
42 Orthanc::PixelFormat format, |
391fb6d6905d
OrthancMultiframeVolumeLoader asks volume image to compute range +
Benjamin Golinvaux <bgo@osimis.io>
parents:
1048
diff
changeset
|
43 bool computeRange) |
814 | 44 { |
45 geometry_.reset(new VolumeImageGeometry(geometry)); | |
46 image_.reset(new ImageBuffer3D(format, geometry_->GetWidth(), geometry_->GetHeight(), | |
1072
391fb6d6905d
OrthancMultiframeVolumeLoader asks volume image to compute range +
Benjamin Golinvaux <bgo@osimis.io>
parents:
1048
diff
changeset
|
47 geometry_->GetDepth(), computeRange)); |
814 | 48 |
49 revision_ ++; | |
50 } | |
51 | |
52 | |
53 void DicomVolumeImage::SetDicomParameters(const DicomInstanceParameters& parameters) | |
54 { | |
55 parameters_.reset(parameters.Clone()); | |
56 revision_ ++; | |
57 } | |
58 | |
59 | |
60 bool DicomVolumeImage::HasGeometry() const | |
61 { | |
62 return (geometry_.get() != NULL && | |
63 image_.get() != NULL); | |
64 } | |
65 | |
66 | |
67 ImageBuffer3D& DicomVolumeImage::GetPixelData() | |
68 { | |
69 CheckHasGeometry(); | |
70 return *image_; | |
71 } | |
72 | |
73 | |
74 const ImageBuffer3D& DicomVolumeImage::GetPixelData() const | |
75 { | |
76 CheckHasGeometry(); | |
77 return *image_; | |
78 } | |
79 | |
80 | |
81 const VolumeImageGeometry& DicomVolumeImage::GetGeometry() const | |
82 { | |
83 CheckHasGeometry(); | |
84 return *geometry_; | |
85 } | |
86 | |
87 | |
88 const DicomInstanceParameters& DicomVolumeImage::GetDicomParameters() const | |
89 { | |
90 if (HasDicomParameters()) | |
91 { | |
92 return *parameters_; | |
93 } | |
94 else | |
95 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
96 LOG(ERROR) << "DicomVolumeImage::GetDicomParameters(): (!HasDicomParameters())"; |
814 | 97 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
98 } | |
99 } | |
100 } |