MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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
27class Line;
28
29//----------------------------------------------------------------------------------
32//----------------------------------------------------------------------------------
34{
35public:
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 {
45 _center = c;
46 _radius = r;
47 setNormal(n);
48 }
49
51 inline void setCenter(const Vector3& c)
52 {
53 _center = c;
54 }
55
58 bool setNormal(const Vector3& n);
59
61 inline void setRadius(double r)
62 {
63 _radius = r;
64 }
65
67 inline const Vector3& getCenter() const
68 {
69 return _center;
70 }
71
73 inline const Vector3& getNormal() const
74 {
75 return _normal;
76 }
77
79 inline double getRadius() const
80 {
81 return _radius;
82 }
83
85 inline bool project(const Vector3& p, Vector3& proj) const
86 {
87 proj = getPlane().getClosestPoint(p);
88 return (proj - _center).length() <= _radius;
89 }
90
92 inline bool intersect(const Line& l, Vector3& cut) const
93 {
94 return getPlane().intersect(l, cut);
95 }
96
98 inline Plane getPlane() const
99 {
100 return Plane(_normal, _center);
101 }
102
105 void getBoundingBox(const Matrix4& transform, Vector3& boxMin, Vector3& boxMax) const;
106
111
115 void fill(const MedicalImageProperties& pImg, SubImage& destImg, double fillVal) const;
116
120 void fill(const MedicalImageProperties& pImg, VirtualVolume& destImg, double fillVal) const;
121
122private:
124 Vector3 _center;
125
127 Vector3 _normal;
128
130 double _radius;
131};
132
134
135#endif // __mlDisc_H
#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:51
double getRadius() const
Get radius.
Definition mlDisc.h:79
SubImageBox getBoundingBox(const MedicalImageProperties &pImg) const
Compute bounding box of disc in voxel coordinates.
void setRadius(double r)
Set radius.
Definition mlDisc.h:61
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:67
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:92
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:85
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:98
const Vector3 & getNormal() const
Get normal.
Definition mlDisc.h:73
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 that 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.