annotate Framework/Layers/DicomStructureSetRendererFactory.cpp @ 353:92a159481900 am-2

removed useless variable
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 29 Oct 2018 11:53:34 +0100
parents fccffbf99ba1
children 3d523c9a8f0d ba5ad93f935a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
134
4cff7b1ed31d upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 47
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
10 * the License, or (at your option) any later version.
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
15 * Affero General Public License for more details.
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
16 *
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "DicomStructureSetRendererFactory.h"
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 namespace OrthancStone
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 class DicomStructureSetRendererFactory::Renderer : public ILayerRenderer
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 private:
132
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
29 class Structure
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
30 {
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
31 private:
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
32 bool visible_;
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
33 uint8_t red_;
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
34 uint8_t green_;
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
35 uint8_t blue_;
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
36 std::string name_;
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
37 std::vector< std::vector<DicomStructureSet::PolygonPoint> > polygons_;
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
38
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
39 public:
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
40 Structure(DicomStructureSet& structureSet,
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
41 const CoordinateSystem3D& slice,
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
42 size_t index) :
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
43 name_(structureSet.GetStructureName(index))
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
44 {
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
45 structureSet.GetStructureColor(red_, green_, blue_, index);
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
46 visible_ = structureSet.ProjectStructure(polygons_, index, slice);
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
47 }
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
132
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
49 void Render(CairoContext& context)
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
50 {
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
51 if (visible_)
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
52 {
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
53 cairo_t* cr = context.GetObject();
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
54
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
55 context.SetSourceColor(red_, green_, blue_);
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
56
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
57 for (size_t i = 0; i < polygons_.size(); i++)
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
58 {
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
59 cairo_move_to(cr, polygons_[i][0].first, polygons_[i][0].second);
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
60
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
61 for (size_t j = 1; j < polygons_[i].size(); j++)
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
62 {
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
63 cairo_line_to(cr, polygons_[i][j].first, polygons_[i][j].second);
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
64 }
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
65
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
66 cairo_line_to(cr, polygons_[i][0].first, polygons_[i][0].second);
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
67 cairo_stroke(cr);
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
68 }
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
69 }
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
70 }
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
71 };
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
72
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
73 typedef std::list<Structure*> Structures;
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
74
122
e3433dabfb8d refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 121
diff changeset
75 CoordinateSystem3D slice_;
132
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
76 Structures structures_;
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
77
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 public:
122
e3433dabfb8d refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 121
diff changeset
79 Renderer(DicomStructureSet& structureSet,
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
80 const CoordinateSystem3D& slice) :
132
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
81 slice_(slice)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
132
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
83 for (size_t k = 0; k < structureSet.GetStructureCount(); k++)
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
84 {
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
85 structures_.push_back(new Structure(structureSet, slice, k));
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
86 }
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
87 }
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
88
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
89 virtual ~Renderer()
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
90 {
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
91 for (Structures::iterator it = structures_.begin();
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
92 it != structures_.end(); ++it)
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
93 {
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
94 delete *it;
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
95 }
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 virtual bool RenderLayer(CairoContext& context,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 const ViewportGeometry& view)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 {
132
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
101 cairo_set_line_width(context.GetObject(), 2.0f / view.GetZoom());
125
44fc253d4876 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 123
diff changeset
102
132
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
103 for (Structures::const_iterator it = structures_.begin();
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
104 it != structures_.end(); ++it)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
132
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
106 assert(*it != NULL);
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
107 (*it)->Render(context);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 return true;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
113 virtual const CoordinateSystem3D& GetLayerSlice()
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
114 {
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
115 return slice_;
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
116 }
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
117
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 virtual void SetLayerStyle(const RenderStyle& style)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 }
132
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
121
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 virtual bool IsFullQuality()
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 return true;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 };
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
129 void DicomStructureSetRendererFactory::ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
130
1982d6c1d2ff IVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
131 if (loader_.HasStructureSet())
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 {
130
1982d6c1d2ff IVolumeLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
133 NotifyLayerReady(new Renderer(loader_.GetStructureSet(), viewportSlice), viewportSlice, false);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }