comparison Framework/Deprecated/Layers/DicomStructureSetSlicer.cpp @ 1165:4d97f532f1e0 broker

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 19 Nov 2019 21:40:25 +0100
parents f72d1ab42932
children 0ca50d275b9a
comparison
equal deleted inserted replaced
1164:6c159b8362ff 1165:4d97f532f1e0
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/ 19 **/
20 20
21 #include "DicomStructureSetSlicer.h" 21 #include "DicomStructureSetSlicer.h"
22 22
23 #include "../../Toolbox/DicomStructureSet.h"
24
23 namespace Deprecated 25 namespace Deprecated
24 { 26 {
25 class DicomStructureSetSlicer::Renderer : public ILayerRenderer 27 class DicomStructureSetSlicer::Renderer : public ILayerRenderer
26 { 28 {
27 private: 29 private:
28 class Structure 30 class Structure
29 { 31 {
30 private: 32 private:
31 bool visible_; 33 bool visible_;
32 uint8_t red_; 34 uint8_t red_;
33 uint8_t green_; 35 uint8_t green_;
34 uint8_t blue_; 36 uint8_t blue_;
35 std::string name_; 37 std::string name_;
38
39 #if USE_BOOST_UNION_FOR_POLYGONS == 1
40 std::vector< std::vector<OrthancStone::Point2D> > polygons_;
41 #else
36 std::vector< std::pair<OrthancStone::Point2D, OrthancStone::Point2D> > segments_; 42 std::vector< std::pair<OrthancStone::Point2D, OrthancStone::Point2D> > segments_;
37 43 #endif
44
38 public: 45 public:
39 Structure(OrthancStone::DicomStructureSet& structureSet, 46 Structure(OrthancStone::DicomStructureSet& structureSet,
40 const OrthancStone::CoordinateSystem3D& plane, 47 const OrthancStone::CoordinateSystem3D& plane,
41 size_t index) : 48 size_t index) :
42 name_(structureSet.GetStructureName(index)) 49 name_(structureSet.GetStructureName(index))
43 { 50 {
44 structureSet.GetStructureColor(red_, green_, blue_, index); 51 structureSet.GetStructureColor(red_, green_, blue_, index);
52
53 #if USE_BOOST_UNION_FOR_POLYGONS == 1
54 visible_ = structureSet.ProjectStructure(polygons_, index, plane);
55 #else
45 visible_ = structureSet.ProjectStructure(segments_, index, plane); 56 visible_ = structureSet.ProjectStructure(segments_, index, plane);
57 #endif
46 } 58 }
47 59
48 void Render(OrthancStone::CairoContext& context) 60 void Render(OrthancStone::CairoContext& context)
49 { 61 {
50 if (visible_) 62 if (visible_)
51 { 63 {
52 cairo_t* cr = context.GetObject(); 64 cairo_t* cr = context.GetObject();
53 65
54 context.SetSourceColor(red_, green_, blue_); 66 context.SetSourceColor(red_, green_, blue_);
55 67
68 #if USE_BOOST_UNION_FOR_POLYGONS == 1
69 for (size_t i = 0; i < polygons_.size(); i++)
70 {
71 cairo_move_to(cr, polygons_[i][0].x, polygons_[i][0].y);
72 for (size_t j = 0; j < polygons_[i].size(); j++)
73 {
74 cairo_line_to(cr, polygons_[i][j].x, polygons_[i][j].y);
75 }
76 cairo_line_to(cr, polygons_[i][0].x, polygons_[i][0].y);
77 cairo_stroke(cr);
78 }
79 #else
56 for (size_t i = 0; i < segments_.size(); i++) 80 for (size_t i = 0; i < segments_.size(); i++)
57 { 81 {
58 cairo_move_to(cr, segments_[i].first.x, segments_[i].first.y); 82 cairo_move_to(cr, segments_[i].first.x, segments_[i].first.y);
59 cairo_move_to(cr, segments_[i].second.x, segments_[i].second.y); 83 cairo_line_to(cr, segments_[i].second.x, segments_[i].second.y);
60 cairo_stroke(cr); 84 cairo_stroke(cr);
61 } 85 }
86 #endif
62 } 87 }
63 } 88 }
64 }; 89 };
65 90
66 typedef std::list<Structure*> Structures; 91 typedef std::list<Structure*> Structures;