imagedraw.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef mia_3d_imagedraw_hh
22 #define mia_3d_imagedraw_hh
23 
24 
25 #include <mia/3d/image.hh>
26 
28 
36 public:
37  C3DDrawBox(const C3DBounds& size, const C3DFVector& origin, const C3DFVector& spacing);
38 
39  void draw_point(const C3DFVector& p);
40 
47  void draw_line(const C3DFVector& a, const C3DFVector& b);
48 
58  void draw_triangle(const C3DFVector& a, const C3DFVector& b, const C3DFVector& c);
59 
60 private:
65  bool is_inside(const C3DFVector& p) const;
66 
71  bool make_inside(C3DFVector& p, const C3DFVector& searchdir) const;
72 
73  void draw_line_pivot_x(C3DFVector& x, C3DFVector& y, C3DFVector& v);
74  void draw_line_pivot_y(C3DFVector& x, C3DFVector& y, C3DFVector& v);
75  void draw_line_pivot_z(C3DFVector& x, C3DFVector& y, C3DFVector& v);
76 
77  void draw_triangle_internal(const C3DFVector& a, const C3DFVector& b, const C3DFVector& c);
78  void draw_line_internal(const C3DFVector& x, const C3DFVector& y);
79 
80  // check wether the bounding box enclosing the triangle overlaps with the drawing area
81  bool has_overlap(const C3DFVector& x, const C3DFVector& y, const C3DFVector& z);
82 
83  virtual void do_draw_point(const C3DBounds& p) = 0;
84 
85  C3DBounds m_size;
86  C3DFVector m_fsize;
87  C3DFVector m_origin;
88  C3DFVector m_stepping;
89 
90 };
91 
92 
97 template <typename T>
99 
100 public:
104  T3DImageDrawTarget(const C3DBounds& size, const C3DFVector& origin, const C3DFVector& spacing);
105 
106 
108  void set_color(T c);
109 
110 
112  const T3DImage<T>& get_image() const;
113 private:
114  void do_draw_point(const C3DBounds& p);
115 
116  T3DImage<T> m_target;
117  T m_color;
118 };
119 
129 
131 
132 #endif
T3DImageDrawTarget< unsigned char > C3DUBImageDrawTarget
Definition: imagedraw.hh:121
Specific type of the 3D images that hold real pixel data.
Definition: 3d/image.hh:148
T3DImageDrawTarget< unsigned short > C3DUSImageDrawTarget
Definition: imagedraw.hh:123
base class for a 3D volume raster graphics draw target
Definition: imagedraw.hh:35
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
#define EXPORT_3D
Definition: defines3d.hh:44
T3DImageDrawTarget< double > C3DDImageDrawTarget
Definition: imagedraw.hh:128
implements T3DImage as a target for drawing operations
Definition: imagedraw.hh:98
T3DImageDrawTarget< bool > C3DBitImageDrawTarget
Definition: imagedraw.hh:120
T3DImageDrawTarget< unsigned int > C3DUIImageDrawTarget
Definition: imagedraw.hh:125
T3DImageDrawTarget< signed int > C3DSIImageDrawTarget
Definition: imagedraw.hh:126
T3DImageDrawTarget< float > C3DFImageDrawTarget
Definition: imagedraw.hh:127
T3DImageDrawTarget< signed char > C3DSBImageDrawTarget
Definition: imagedraw.hh:122
T3DImageDrawTarget< signed short > C3DSSImageDrawTarget
Definition: imagedraw.hh:124
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36