My Project
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{
37public:
38 C3DDrawBox(const C3DBounds& size, const C3DFVector& origin, const C3DFVector& spacing);
39
40 void draw_point(const C3DFVector& p);
41
48 void draw_line(const C3DFVector& a, const C3DFVector& b);
49
59 void draw_triangle(const C3DFVector& a, const C3DFVector& b, const C3DFVector& c);
60
61private:
66 bool is_inside(const C3DFVector& p) const;
67
72 bool make_inside(C3DFVector& p, const C3DFVector& searchdir) const;
73
74 void draw_line_pivot_x(C3DFVector& x, C3DFVector& y, C3DFVector& v);
75 void draw_line_pivot_y(C3DFVector& x, C3DFVector& y, C3DFVector& v);
76 void draw_line_pivot_z(C3DFVector& x, C3DFVector& y, C3DFVector& v);
77
78 void draw_triangle_internal(const C3DFVector& a, const C3DFVector& b, const C3DFVector& c);
79 void draw_line_internal(const C3DFVector& x, const C3DFVector& y);
80
81 // check wether the bounding box enclosing the triangle overlaps with the drawing area
82 bool has_overlap(const C3DFVector& x, const C3DFVector& y, const C3DFVector& z);
83
84 virtual void do_draw_point(const C3DBounds& p) = 0;
85
86 C3DBounds m_size;
87 C3DFVector m_fsize;
88 C3DFVector m_origin;
89 C3DFVector m_stepping;
90
91};
92
93
98template <typename T>
100{
101
102public:
106 T3DImageDrawTarget(const C3DBounds& size, const C3DFVector& origin, const C3DFVector& spacing);
107
108
110 void set_color(T c);
111
112
114 const T3DImage<T>& get_image() const;
115private:
116 void do_draw_point(const C3DBounds& p);
117
118 T3DImage<T> m_target;
119 T m_color;
120};
121
131
133
134#endif
base class for a 3D volume raster graphics draw target
Definition imagedraw.hh:36
void draw_point(const C3DFVector &p)
void draw_line(const C3DFVector &a, const C3DFVector &b)
C3DDrawBox(const C3DBounds &size, const C3DFVector &origin, const C3DFVector &spacing)
void draw_triangle(const C3DFVector &a, const C3DFVector &b, const C3DFVector &c)
implements T3DImage as a target for drawing operations
Definition imagedraw.hh:100
const T3DImage< T > & get_image() const
T3DImageDrawTarget(const C3DBounds &size, const C3DFVector &origin, const C3DFVector &spacing)
Specific type of the 3D images that hold real pixel data.
Definition 3d/image.hh:150
#define EXPORT_3D
Definition defines3d.hh:45
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
T3DImageDrawTarget< unsigned char > C3DUBImageDrawTarget
Definition imagedraw.hh:123
T3DImageDrawTarget< double > C3DDImageDrawTarget
Definition imagedraw.hh:130
T3DImageDrawTarget< float > C3DFImageDrawTarget
Definition imagedraw.hh:129
T3DImageDrawTarget< unsigned short > C3DUSImageDrawTarget
Definition imagedraw.hh:125
T3DImageDrawTarget< signed char > C3DSBImageDrawTarget
Definition imagedraw.hh:124
T3DImageDrawTarget< signed short > C3DSSImageDrawTarget
Definition imagedraw.hh:126
T3DImageDrawTarget< signed int > C3DSIImageDrawTarget
Definition imagedraw.hh:128
T3DImageDrawTarget< bool > C3DBitImageDrawTarget
Definition imagedraw.hh:122
T3DImageDrawTarget< unsigned int > C3DUIImageDrawTarget
Definition imagedraw.hh:127