Mercurial > hg > orthanc-stone
annotate Framework/Volumes/VolumeSceneLayerSource.cpp @ 1290:7def6ab2929f bugs/2020-02-invisible-slice
Removal of debugging logs
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 21 Feb 2020 15:20:29 +0100 |
parents | 2d8ab34c8c91 |
children | 8a0a62189f46 |
rev | line source |
---|---|
815 | 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:
956
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
815 | 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 "VolumeSceneLayerSource.h" | |
23 | |
24 #include <Core/OrthancException.h> | |
25 | |
26 namespace OrthancStone | |
27 { | |
28 static bool IsSameCuttingPlane(const CoordinateSystem3D& a, | |
29 const CoordinateSystem3D& b) | |
30 { | |
31 // TODO - What if the normal is reversed? | |
32 double distance; | |
33 return (CoordinateSystem3D::ComputeDistance(distance, a, b) && | |
34 LinearAlgebra::IsCloseToZero(distance)); | |
35 } | |
36 | |
37 | |
38 void VolumeSceneLayerSource::ClearLayer() | |
39 { | |
40 scene_.DeleteLayer(layerDepth_); | |
41 lastPlane_.reset(NULL); | |
42 } | |
43 | |
44 | |
45 VolumeSceneLayerSource::VolumeSceneLayerSource(Scene2D& scene, | |
46 int layerDepth, | |
47 const boost::shared_ptr<IVolumeSlicer>& slicer) : | |
48 scene_(scene), | |
49 layerDepth_(layerDepth), | |
50 slicer_(slicer) | |
51 { | |
52 if (slicer == NULL) | |
53 { | |
54 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
55 } | |
56 } | |
57 | |
934
094d10ed7ec2
VolumeSceneLayerSource dtor now clears the layer
Benjamin Golinvaux <bgo@osimis.io>
parents:
921
diff
changeset
|
58 VolumeSceneLayerSource::~VolumeSceneLayerSource() |
094d10ed7ec2
VolumeSceneLayerSource dtor now clears the layer
Benjamin Golinvaux <bgo@osimis.io>
parents:
921
diff
changeset
|
59 { |
094d10ed7ec2
VolumeSceneLayerSource dtor now clears the layer
Benjamin Golinvaux <bgo@osimis.io>
parents:
921
diff
changeset
|
60 ClearLayer(); |
094d10ed7ec2
VolumeSceneLayerSource dtor now clears the layer
Benjamin Golinvaux <bgo@osimis.io>
parents:
921
diff
changeset
|
61 } |
815 | 62 |
63 void VolumeSceneLayerSource::RemoveConfigurator() | |
64 { | |
65 configurator_.reset(); | |
66 lastPlane_.reset(); | |
67 } | |
68 | |
69 | |
70 void VolumeSceneLayerSource::SetConfigurator(ILayerStyleConfigurator* configurator) // Takes ownership | |
71 { | |
72 if (configurator == NULL) | |
73 { | |
74 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
75 } | |
76 | |
77 configurator_.reset(configurator); | |
78 | |
79 // Invalidate the layer | |
80 lastPlane_.reset(NULL); | |
81 } | |
82 | |
83 | |
84 ILayerStyleConfigurator& VolumeSceneLayerSource::GetConfigurator() const | |
85 { | |
86 if (configurator_.get() == NULL) | |
87 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
934
diff
changeset
|
88 LOG(ERROR) << "VolumeSceneLayerSource::GetConfigurator(): (configurator_.get() == NULL)"; |
815 | 89 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
90 } | |
91 | |
92 return *configurator_; | |
93 } | |
94 | |
95 | |
96 void VolumeSceneLayerSource::Update(const CoordinateSystem3D& plane) | |
97 { | |
98 assert(slicer_.get() != NULL); | |
99 std::auto_ptr<IVolumeSlicer::IExtractedSlice> slice(slicer_->ExtractSlice(plane)); | |
100 | |
101 if (slice.get() == NULL) | |
102 { | |
103 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
104 } | |
105 | |
106 if (!slice->IsValid()) | |
107 { | |
108 // The slicer cannot handle this cutting plane: Clear the layer | |
109 ClearLayer(); | |
110 } | |
111 else if (lastPlane_.get() != NULL && | |
112 IsSameCuttingPlane(*lastPlane_, plane) && | |
113 lastRevision_ == slice->GetRevision()) | |
114 { | |
115 // The content of the slice has not changed: Don't update the | |
116 // layer content, but possibly update its style | |
117 | |
118 if (configurator_.get() != NULL && | |
119 configurator_->GetRevision() != lastConfiguratorRevision_ && | |
120 scene_.HasLayer(layerDepth_)) | |
121 { | |
122 configurator_->ApplyStyle(scene_.GetLayer(layerDepth_)); | |
123 } | |
124 } | |
125 else | |
126 { | |
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:
815
diff
changeset
|
127 LOG(TRACE) << "VolumeSceneLayerSource::Update -- Content has changed: An update is needed"; |
815 | 128 // Content has changed: An update is needed |
129 lastPlane_.reset(new CoordinateSystem3D(plane)); | |
130 lastRevision_ = slice->GetRevision(); | |
131 | |
132 std::auto_ptr<ISceneLayer> layer(slice->CreateSceneLayer(configurator_.get(), plane)); | |
133 if (layer.get() == NULL) | |
134 { | |
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:
815
diff
changeset
|
135 LOG(TRACE) << "VolumeSceneLayerSource::Update -- (layer.get() == NULL)"; |
815 | 136 ClearLayer(); |
137 } | |
138 else | |
139 { | |
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:
815
diff
changeset
|
140 LOG(TRACE) << "VolumeSceneLayerSource::Update -- (layer.get() != NULL)"; |
815 | 141 if (configurator_.get() != NULL) |
142 { | |
143 lastConfiguratorRevision_ = configurator_->GetRevision(); | |
144 configurator_->ApplyStyle(*layer); | |
145 } | |
146 | |
147 scene_.SetLayer(layerDepth_, layer.release()); | |
148 } | |
149 } | |
150 } | |
151 } |