imagedraw.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef mia_3d_imagedraw_hh
#define mia_3d_imagedraw_hh
#include <mia/3d/image.hh>
NS_MIA_BEGIN
class EXPORT_3D C3DDrawBox
{
public:
C3DDrawBox(const C3DBounds& size, const C3DFVector& origin, const C3DFVector& spacing);
void draw_point(const C3DFVector& p);
void draw_line(const C3DFVector& a, const C3DFVector& b);
void draw_triangle(const C3DFVector& a, const C3DFVector& b, const C3DFVector& c);
private:
bool is_inside(const C3DFVector& p) const;
bool make_inside(C3DFVector& p, const C3DFVector& searchdir) const;
void draw_line_pivot_x(C3DFVector& x, C3DFVector& y, C3DFVector& v);
void draw_line_pivot_y(C3DFVector& x, C3DFVector& y, C3DFVector& v);
void draw_line_pivot_z(C3DFVector& x, C3DFVector& y, C3DFVector& v);
void draw_triangle_internal(const C3DFVector& a, const C3DFVector& b, const C3DFVector& c);
void draw_line_internal(const C3DFVector& x, const C3DFVector& y);
// check wether the bounding box enclosing the triangle overlaps with the drawing area
bool has_overlap(const C3DFVector& x, const C3DFVector& y, const C3DFVector& z);
virtual void do_draw_point(const C3DBounds& p) = 0;
C3DBounds m_size;
C3DFVector m_fsize;
C3DFVector m_origin;
C3DFVector m_stepping;
};
template <typename T>
class T3DImageDrawTarget : public C3DDrawBox
{
public:
T3DImageDrawTarget(const C3DBounds& size, const C3DFVector& origin, const C3DFVector& spacing);
void set_color(T c);
const T3DImage<T>& get_image() const;
private:
void do_draw_point(const C3DBounds& p);
T3DImage<T> m_target;
T m_color;
};
typedef T3DImageDrawTarget<bool> C3DBitImageDrawTarget;
typedef T3DImageDrawTarget<unsigned char> C3DUBImageDrawTarget;
typedef T3DImageDrawTarget<signed char> C3DSBImageDrawTarget;
typedef T3DImageDrawTarget<unsigned short> C3DUSImageDrawTarget;
typedef T3DImageDrawTarget<signed short> C3DSSImageDrawTarget;
typedef T3DImageDrawTarget<unsigned int> C3DUIImageDrawTarget;
typedef T3DImageDrawTarget<signed int> C3DSIImageDrawTarget;
typedef T3DImageDrawTarget<float> C3DFImageDrawTarget;
typedef T3DImageDrawTarget<double> C3DDImageDrawTarget;
NS_MIA_END
#endif
image.hh
C3DBounds
T3DVector< unsigned int > C3DBounds
A unsinged int 3D Vector (used for 3D field sizes).
Definition 3d/vector.hh:415
C3DFVector
T3DVector< float > C3DFVector
A float 3D Vector.
Definition 3d/vector.hh:409
C3DDrawBox::draw_point
void draw_point(const C3DFVector &p)
C3DDrawBox::draw_line
void draw_line(const C3DFVector &a, const C3DFVector &b)
C3DDrawBox::C3DDrawBox
C3DDrawBox(const C3DBounds &size, const C3DFVector &origin, const C3DFVector &spacing)
C3DDrawBox::draw_triangle
void draw_triangle(const C3DFVector &a, const C3DFVector &b, const C3DFVector &c)
T3DImageDrawTarget
implements T3DImage as a target for drawing operations
Definition imagedraw.hh:100
T3DImageDrawTarget::get_image
const T3DImage< T > & get_image() const
T3DImageDrawTarget::T3DImageDrawTarget
T3DImageDrawTarget(const C3DBounds &size, const C3DFVector &origin, const C3DFVector &spacing)
T3DImageDrawTarget::set_color
void set_color(T c)
T3DImage
Specific type of the 3D images that hold real pixel data.
Definition 3d/image.hh:150
EXPORT_3D
#define EXPORT_3D
Definition defines3d.hh:45
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
C3DUBImageDrawTarget
T3DImageDrawTarget< unsigned char > C3DUBImageDrawTarget
Definition imagedraw.hh:123
C3DDImageDrawTarget
T3DImageDrawTarget< double > C3DDImageDrawTarget
Definition imagedraw.hh:130
C3DFImageDrawTarget
T3DImageDrawTarget< float > C3DFImageDrawTarget
Definition imagedraw.hh:129
C3DUSImageDrawTarget
T3DImageDrawTarget< unsigned short > C3DUSImageDrawTarget
Definition imagedraw.hh:125
C3DSBImageDrawTarget
T3DImageDrawTarget< signed char > C3DSBImageDrawTarget
Definition imagedraw.hh:124
C3DSSImageDrawTarget
T3DImageDrawTarget< signed short > C3DSSImageDrawTarget
Definition imagedraw.hh:126
C3DSIImageDrawTarget
T3DImageDrawTarget< signed int > C3DSIImageDrawTarget
Definition imagedraw.hh:128
C3DBitImageDrawTarget
T3DImageDrawTarget< bool > C3DBitImageDrawTarget
Definition imagedraw.hh:122
C3DUIImageDrawTarget
T3DImageDrawTarget< unsigned int > C3DUIImageDrawTarget
Definition imagedraw.hh:127