ML Reference
mlSubImageBoxd.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_SUB_IMAGE_BOXD_H
14#define ML_SUB_IMAGE_BOXD_H
15
19
20#include "mlInitSystemML.h"
21#include "mlSubImageBox.h"
22#include "mlLinearAlgebra.h"
23
24ML_START_NAMESPACE
25
26//-------------------------------------------------------------------------
31//-------------------------------------------------------------------------
33{
34
35public:
36
41
44
45 //------------------------------------------------------
48 //------------------------------------------------------
50 inline SubImageBoxd()
51 {
52 v1=Vector6(0);
53 v2=Vector6(-1);
54 }
55
58 inline SubImageBoxd(const Vector6& vector1, const Vector6& vector2) : v1(vector1), v2(vector2)
59 {
60 }
61
63 inline SubImageBoxd(const Vector6& extent) : v1(0), v2(extent)
64 {
65 }
66
72
73
74
75 //------------------------------------------------------
78 //------------------------------------------------------
80 inline bool operator==(const SubImageBoxd& box) const
81 {
82 return (v1==box.v1) && (v2==box.v2);
83 }
84
86 inline bool operator!=(const SubImageBoxd& box) const
87 {
88 return !operator==(box);
89 }
90
93 inline bool isEmpty() const
94 {
95 return (v1[0]>v2[0]) || (v1[1]>v2[1]) || (v1[2]>v2[2]) || (v1[3]>v2[3]) || (v1[4]>v2[4]) || (v1[5]>v2[5]);
96 }
97
99 inline Vector6 getExtent() const
100 {
101 if (isEmpty())
102 {
103 return Vector6(0);
104 }
105 else
106 {
107 return v2-v1;
108 }
109 }
110
114
115 //------------------------------------------------------
118 //------------------------------------------------------
120 inline static SubImageBoxd intersect(const SubImageBoxd& box1, const SubImageBoxd& box2)
121 {
122 SubImageBoxd result;
123 // If for any component result holds (result.v1[0]>result.v2[0] ||
124 // result.v1[1]>result.v1[1] || result.v1[2]>result.v1[2] ... ), the
125 // intersection is interpreted as being empty. This holds especially if
126 // if loc1 or loc2 are already empty.
127 result.v1 = compMax(box1.v1, box2.v1);
128 result.v2 = compMin(box1.v2, box2.v2);
129 return result;
130 }
131
133 inline void makeEmpty()
134 {
135 v1 = Vector6(0);
136 v2 = Vector6(-1);
137 }
138
141 {
142 return SubImageBoxd::intersect(*this, box);
143 }
144
147 inline Vector6 clamp(const Vector6& position)
148 {
149 return compMax(compMin(position, v2), v1);
150 }
151
156
157
158}; // end of SubImageBoxd
159
160
161ML_END_NAMESPACE
162
163
164//-----------------------------------------------------------------------------------
165// Stream output for std::ostream
166//-----------------------------------------------------------------------------------
167namespace std {
168
170 inline ostream& operator<<(ostream& s, const ML_NAMESPACE::SubImageBoxd &box)
171 {
172 return s << "(" << box.v1 << ")(" << box.v2 << ")";
173 }
174
175}
176
177#endif // __mlSubImageBoxd_H
178
179
180
181
bool operator!=(const SubImageBoxd &box) const
Returns true if both boxes are identical.
MLEXPORT SubImageBoxd(const SubImageBox &box)
Vector6 v2
Corner v2 of the box region.
SubImageBoxd()
Constructor: constructs an empty region, i.e., v2 < v1.
bool operator==(const SubImageBoxd &box) const
Returns true if both boxes are identical.
void makeEmpty()
Makes box empty and restores constructor state.
SubImageBoxd(const Vector6 &vector1, const Vector6 &vector2)
Vector6 getExtent() const
Returns the distance vector between v1 and v2, i.e., it returns extents of the box.
MLEXPORT void correct()
Swaps all components where v1.* > v2.*.
static SubImageBoxd intersect(const SubImageBoxd &box1, const SubImageBoxd &box2)
Returns the intersection of box1 and box2.
static MLEXPORT SubImageBoxd calcAATransformedBox(const SubImageBox &box, const Matrix4 &matrix)
bool isEmpty() const
Vector6 clamp(const Vector6 &position)
SubImageBoxd intersect(const SubImageBoxd &box)
Memberfunction version to intersect this with a given box.
SubImageBoxd(const Vector6 &extent)
Constructor: creates a box with origin (0,0,0,0,0,0) and a given extent.
#define MLEXPORT
Code it as import symbol if compiled elsewhere.
FloatingPointVector< T, size, DataContainer > compMax(FloatingPointVector< T, size, DataContainer > buffer1, const FloatingPointVector< T, size, DataContainer > &buffer2)
Tmat4< MLdouble > Matrix4
The standard 4x4 matrix of type double.
Definition mlMatrix4.h:713
Tvec6< MLdouble > Vector6
A vector with six components of type double.
Definition mlVector6.h:194
TSubImageBox< MLint > SubImageBox
Defines the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type...
FloatingPointVector< T, size, DataContainer > compMin(FloatingPointVector< T, size, DataContainer > buffer1, const FloatingPointVector< T, size, DataContainer > &buffer2)
STL namespace.
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator '<<' for stream output of Field objects.