annotate OrthancStone/Sources/Volumes/VolumeSceneLayerSource.cpp @ 1558:314b6dc507d9

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 Aug 2020 11:38:56 +0200
parents 244ad1e4e76a
children 85e117739eca
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
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
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 "VolumeSceneLayerSource.h"
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
1324
4d8d642f7036 Added a NullLayer scene layer type that allows
Benjamin Golinvaux <bgo@osimis.io>
parents: 1322
diff changeset
24 #include "../Scene2D/NullLayer.h"
1433
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
25 #include "../Viewport/IViewport.h"
1324
4d8d642f7036 Added a NullLayer scene layer type that allows
Benjamin Golinvaux <bgo@osimis.io>
parents: 1322
diff changeset
26 #include "../StoneException.h"
1558
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
27 #include "../Scene2DViewport/ViewportController.h"
1324
4d8d642f7036 Added a NullLayer scene layer type that allows
Benjamin Golinvaux <bgo@osimis.io>
parents: 1322
diff changeset
28
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
29 #include <OrthancException.h>
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OrthancStone
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 static bool IsSameCuttingPlane(const CoordinateSystem3D& a,
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 const CoordinateSystem3D& b)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 // TODO - What if the normal is reversed?
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 double distance;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 return (CoordinateSystem3D::ComputeDistance(distance, a, b) &&
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 LinearAlgebra::IsCloseToZero(distance));
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 void VolumeSceneLayerSource::ClearLayer()
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
1433
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
45 {
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
46 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock());
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
47 ViewportController& controller = lock->GetController();
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
48 Scene2D& scene = controller.GetScene();
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
49 scene.DeleteLayer(layerDepth_);
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
50 }
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 lastPlane_.reset(NULL);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
1322
0da659f8579c Object reference 1st commit + indent change
Benjamin Golinvaux <bgo@osimis.io>
parents: 1298
diff changeset
54 VolumeSceneLayerSource::VolumeSceneLayerSource(
1433
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
55 boost::shared_ptr<OrthancStone::IViewport> viewport,
1322
0da659f8579c Object reference 1st commit + indent change
Benjamin Golinvaux <bgo@osimis.io>
parents: 1298
diff changeset
56 int layerDepth,
0da659f8579c Object reference 1st commit + indent change
Benjamin Golinvaux <bgo@osimis.io>
parents: 1298
diff changeset
57 const boost::shared_ptr<IVolumeSlicer>& slicer)
1433
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
58 : viewport_(viewport)
1322
0da659f8579c Object reference 1st commit + indent change
Benjamin Golinvaux <bgo@osimis.io>
parents: 1298
diff changeset
59 , layerDepth_(layerDepth)
0da659f8579c Object reference 1st commit + indent change
Benjamin Golinvaux <bgo@osimis.io>
parents: 1298
diff changeset
60 , slicer_(slicer)
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 if (slicer == NULL)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
1324
4d8d642f7036 Added a NullLayer scene layer type that allows
Benjamin Golinvaux <bgo@osimis.io>
parents: 1322
diff changeset
66
1433
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
67 {
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
68 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock());
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
69 ViewportController& controller = lock->GetController();
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
70 Scene2D& scene = controller.GetScene();
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
71 ORTHANC_ASSERT(!scene.HasLayer(layerDepth_));
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
72
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
73 // we need to book the scene layer depth by adding a dummy layer
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
74 std::unique_ptr<NullLayer> nullLayer(new NullLayer);
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
75 scene.SetLayer(layerDepth_,nullLayer.release());
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
76 }
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
934
094d10ed7ec2 VolumeSceneLayerSource dtor now clears the layer
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
79 VolumeSceneLayerSource::~VolumeSceneLayerSource()
094d10ed7ec2 VolumeSceneLayerSource dtor now clears the layer
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
80 {
094d10ed7ec2 VolumeSceneLayerSource dtor now clears the layer
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
81 ClearLayer();
094d10ed7ec2 VolumeSceneLayerSource dtor now clears the layer
Benjamin Golinvaux <bgo@osimis.io>
parents: 921
diff changeset
82 }
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 void VolumeSceneLayerSource::RemoveConfigurator()
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 configurator_.reset();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 lastPlane_.reset();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 void VolumeSceneLayerSource::SetConfigurator(ILayerStyleConfigurator* configurator) // Takes ownership
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 if (configurator == NULL)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 configurator_.reset(configurator);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 // Invalidate the layer
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 lastPlane_.reset(NULL);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 ILayerStyleConfigurator& VolumeSceneLayerSource::GetConfigurator() const
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 if (configurator_.get() == NULL)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
956
a7351ad54960 Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents: 934
diff changeset
109 LOG(ERROR) << "VolumeSceneLayerSource::GetConfigurator(): (configurator_.get() == NULL)";
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
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 return *configurator_;
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
1345
0d6a01ffa1dd Clean version of the hack commited in
Benjamin Golinvaux <bgo@osimis.io>
parents: 1344
diff changeset
117 void VolumeSceneLayerSource::Update(const CoordinateSystem3D& plane)
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 {
1433
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
119 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock());
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
120 ViewportController& controller = lock->GetController();
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
121 Scene2D& scene = controller.GetScene();
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
122
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 assert(slicer_.get() != NULL);
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
124 std::unique_ptr<IVolumeSlicer::IExtractedSlice> slice(slicer_->ExtractSlice(plane));
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 if (slice.get() == NULL)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 if (!slice->IsValid())
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 // The slicer cannot handle this cutting plane: Clear the layer
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 ClearLayer();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 }
1345
0d6a01ffa1dd Clean version of the hack commited in
Benjamin Golinvaux <bgo@osimis.io>
parents: 1344
diff changeset
136 else if (lastPlane_.get() != NULL &&
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 IsSameCuttingPlane(*lastPlane_, plane) &&
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 lastRevision_ == slice->GetRevision())
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 // The content of the slice has not changed: Don't update the
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 // layer content, but possibly update its style
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 if (configurator_.get() != NULL &&
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 configurator_->GetRevision() != lastConfiguratorRevision_ &&
1433
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
145 scene.HasLayer(layerDepth_))
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 {
1433
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
147 configurator_->ApplyStyle(scene.GetLayer(layerDepth_));
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 else
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 {
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
152 LOG(TRACE) << "VolumeSceneLayerSource::Update -- Content has changed: An update is needed";
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 // Content has changed: An update is needed
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 lastPlane_.reset(new CoordinateSystem3D(plane));
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 lastRevision_ = slice->GetRevision();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
157 std::unique_ptr<ISceneLayer> layer(slice->CreateSceneLayer(configurator_.get(), plane));
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 if (layer.get() == NULL)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 {
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
160 LOG(TRACE) << "VolumeSceneLayerSource::Update -- (layer.get() == NULL)";
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 ClearLayer();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 else
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 {
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
165 LOG(TRACE) << "VolumeSceneLayerSource::Update -- (layer.get() != NULL)";
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 if (configurator_.get() != NULL)
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 {
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 lastConfiguratorRevision_ = configurator_->GetRevision();
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 configurator_->ApplyStyle(*layer);
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171
1433
8635b333fa5b [BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1345
diff changeset
172 scene.SetLayer(layerDepth_, layer.release());
815
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 }
df442f1ba0c6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 }