MeVisLab Toolbox Reference
mlDisc.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_DISC_H
14#define ML_DISC_H
15
16
18
19#include "MLToolsSystem.h"
20#include "mlModuleIncludes.h"
21#include "mlPlane.h"
22#include "mlTVirtualVolume.h"
23
25
27 class Line;
28
29 //----------------------------------------------------------------------------------
32 //----------------------------------------------------------------------------------
34 {
35 public:
38
40 Disc(const Vector3 &c, const Vector3 &n, double r);
41
43 inline void setValue(const Vector3 &c, const Vector3 &n, double r)
44 { _center = c; _radius = r; setNormal(n); }
45
47 inline void setCenter(const Vector3 &c) { _center = c; }
48
51 bool setNormal(const Vector3 &n);
52
54 inline void setRadius(double r) { _radius = r; }
55
57 inline const Vector3 &getCenter() const { return _center; }
58
60 inline const Vector3 &getNormal() const { return _normal; }
61
63 inline double getRadius() const { return _radius; }
64
66 inline bool project(const Vector3 &p, Vector3 &proj) const
67 { proj = getPlane().getClosestPoint(p); return (proj - _center).length() <= _radius; }
68
70 inline bool intersect(const Line &l, Vector3 &cut) const
71 { return getPlane().intersect(l, cut); }
72
74 inline Plane getPlane() const
75 { return Plane(_normal, _center); }
76
79 void getBoundingBox(const Matrix4 &transform, Vector3 &boxMin, Vector3 &boxMax) const;
80
85
89 void fill(const MedicalImageProperties &pImg, SubImage &destImg, double fillVal) const;
90
94 void fill(const MedicalImageProperties &pImg, VirtualVolume &destImg, double fillVal) const;
95
96 private:
97
99 Vector3 _center;
100
102 Vector3 _normal;
103
105 double _radius;
106 };
107
109
110#endif // __mlDisc_H
111
#define MLTOOLS_EXPORT
Resolves system dependencies for this project.
Class to handle the geometry primitive "Disc" consisting of a center, a normal and a radius.
Definition mlDisc.h:34
void setCenter(const Vector3 &c)
Set center.
Definition mlDisc.h:47
double getRadius() const
Get radius.
Definition mlDisc.h:63
SubImageBox getBoundingBox(const MedicalImageProperties &pImg) const
Compute bounding box of disc in voxel coordinates.
void setRadius(double r)
Set radius.
Definition mlDisc.h:54
void getBoundingBox(const Matrix4 &transform, Vector3 &boxMin, Vector3 &boxMax) const
Compute bounding box of disc in target coordinates; box is a homogeneous matrix specifying the transf...
void fill(const MedicalImageProperties &pImg, SubImage &destImg, double fillVal) const
Draw disc with value fillVal into subimage destImg.
const Vector3 & getCenter() const
Get center.
Definition mlDisc.h:57
bool intersect(const Line &l, Vector3 &cut) const
Intersects line l with disc plane, true if cut point exists, no radius check.
Definition mlDisc.h:70
bool setNormal(const Vector3 &n)
Set normal vector (performing normalization, (1,0,0) if zero).
void fill(const MedicalImageProperties &pImg, VirtualVolume &destImg, double fillVal) const
Draw disc with value fillVal into VirtualVolume destImg.
void setValue(const Vector3 &c, const Vector3 &n, double r)
Initialize disc parameters (used by constructor)
Definition mlDisc.h:43
Disc()
Constructor. Default state is center at (0,0,0), normal (1,0,0) and radius 0.
bool project(const Vector3 &p, Vector3 &proj) const
Project p to disc plane, return true if projected point lies on disc.
Definition mlDisc.h:66
Disc(const Vector3 &c, const Vector3 &n, double r)
Convenience constructor.
Plane getPlane() const
Get Plane object in which disc is located.
Definition mlDisc.h:74
const Vector3 & getNormal() const
Get normal.
Definition mlDisc.h:60
Class to define the geometry primitive "Line" consisting of a position and a direction.
Definition mlLine.h:28
This class encapsulates basic medical image properties:
Class defining a plane in 3D.
Definition mlPlane.h:30
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
Definition mlSubImage.h:75
This class manages a virtual volume organizing efficient voxel access to the output image of an input...
Target mlrange_cast(Source arg)
Generic version of checked ML casts.