11 #ifndef __UT_BoundingRect_H__
12 #define __UT_BoundingRect_H__
45 vals[0][0] = lowerbound.
vec[0];
46 vals[0][1] = upperbound.
vec[0];
47 vals[1][0] = lowerbound.
vec[1];
48 vals[1][1] = upperbound.
vec[1];
54 vals[0][0] =
T(src.
vals[0][0]);
55 vals[0][1] =
T(src.
vals[0][1]);
56 vals[1][0] =
T(src.
vals[1][0]);
57 vals[1][1] =
T(src.
vals[1][1]);
73 return (vals[0][0] == brect.
vals[0][0] &&
74 vals[0][1] == brect.
vals[0][1] &&
75 vals[1][0] == brect.
vals[1][0] &&
76 vals[1][1] == brect.
vals[1][1] );
80 return !(*
this == brect);
85 if (vals[0][0] > pt.
x() || vals[0][1] < pt.
x())
return 0;
86 if (vals[1][0] > pt.
y() || vals[1][1] < pt.
y())
return 0;
91 if (vals[0][0] > pt.
x() + tol ||
92 vals[0][1] < pt.
x() - tol)
94 if (vals[1][0] > pt.
y() + tol ||
95 vals[1][1] < pt.
y() - tol)
101 return (x >= vals[0][0] && x <= vals[0][1] &&
102 y >= vals[1][0] && y <= vals[1][1] );
108 if (closest_pt.x() < xmin())
109 closest_pt.
x() = xmin();
110 else if (closest_pt.x() > xmax())
111 closest_pt.x() = xmax();
113 if (closest_pt.y() < ymin())
114 closest_pt.y() = ymin();
115 else if (closest_pt.y() > ymax())
116 closest_pt.y() = ymax();
124 return (vals[0][0] >= brect.
vals[0][0] &&
125 vals[0][1] <= brect.
vals[0][1] &&
126 vals[1][0] >= brect.
vals[1][0] &&
127 vals[1][1] <= brect.
vals[1][1] );
139 if (vals[0][0] > rect.
vals[0][1] ||
140 vals[0][1] < rect.
vals[0][0])
142 if (vals[1][0] > rect.
vals[1][1] ||
143 vals[1][1] < rect.
vals[1][0])
149 if (vals[0][0] > rect.
vals[0][1] + tol ||
150 vals[0][1] < rect.
vals[0][0] - tol)
152 if (vals[1][0] > rect.
vals[1][1] + tol ||
153 vals[1][1] < rect.
vals[1][0] - tol)
162 intersectBounds(src);
167 vals[0][0] =
SYSmax(vals[0][0], src.
vals[0][0]);
168 vals[0][1] =
SYSmin(vals[0][1], src.
vals[0][1]);
169 vals[1][0] =
SYSmax(vals[1][0], src.
vals[1][0]);
170 vals[1][1] =
SYSmin(vals[1][1], src.
vals[1][1]);
174 vals[0][0] =
SYSmax(vals[0][0], min);
175 vals[0][1] =
SYSmin(vals[0][1], max);
179 vals[1][0] =
SYSmax(vals[1][0], min);
180 vals[1][1] =
SYSmin(vals[1][1], max);
186 return vals[0][0] <= vals[0][1] &&
187 vals[1][0] <= vals[1][1];
205 vals[0][0] = vals[0][1] = pt.
x();
206 vals[1][0] = vals[1][1] = pt.
y();
210 vals[0][0] = vals[0][1] =
x;
211 vals[1][0] = vals[1][1] =
y;
215 vals[0][0] = xmin; vals[0][1] = xmax;
216 vals[1][0] = ymin; vals[1][1] = ymax;
222 vals[0][0] = rect.
vals[0][0];
223 vals[0][1] = rect.
vals[0][1];
224 vals[1][0] = rect.
vals[1][0];
225 vals[1][1] = rect.
vals[1][1];
231 vals[0][0] = vals[1][0] =
233 vals[0][1] = vals[1][1] =
239 enlargeBounds(pt.
x(), pt.
y());
243 vals[0][0] =
SYSmin(vals[0][0], x);
244 vals[0][1] =
SYSmax(vals[0][1], x);
245 vals[1][0] =
SYSmin(vals[1][0], y);
246 vals[1][1] =
SYSmax(vals[1][1], y);
252 vals[0][0] =
SYSmin(vals[0][0], xmin);
253 vals[0][1] =
SYSmax(vals[0][1], xmax);
254 vals[1][0] =
SYSmin(vals[1][0], ymin);
255 vals[1][1] =
SYSmax(vals[1][1], ymax);
259 vals[0][0] =
SYSmin(vals[0][0], rect(0, 0));
260 vals[0][1] =
SYSmax(vals[0][1], rect(0, 1));
261 vals[1][0] =
SYSmin(vals[1][0], rect(1, 0));
262 vals[1][1] =
SYSmax(vals[1][1], rect(1, 1));
274 d =
min + sizeX()*percent;
275 vals[0][0] -= d; vals[0][1] += d;
276 d =
min + sizeY()*percent;
277 vals[1][0] -= d; vals[1][1] += d;
288 vals[0][0] *= xscale; vals[0][1] *= xscale;
289 vals[1][0] *= yscale; vals[1][1] *= yscale;
296 if (xmin() > box.
xmax())
298 else if (xmax() < box.
xmin())
301 if (ymin() > box.
ymax())
303 else if (ymax() < box.
ymin())
309 T sizeX()
const {
return vals[0][1] - vals[0][0]; }
310 T sizeY()
const {
return vals[1][1] - vals[1][0]; }
312 T centerX()
const {
return (vals[0][0] + vals[0][1]) * 0.5; }
313 T centerY()
const {
return (vals[1][0] + vals[1][1]) * 0.5; }
319 inline void project(
T &
x,
T &
y,
int *touchx=0,
int *touchy=0)
const;
321 T LX()
const {
return vals[0][0]; }
322 T LY()
const {
return vals[1][0]; }
323 T UX()
const {
return vals[0][1]; }
324 T UY()
const {
return vals[1][1]; }
326 T &
LX() {
return vals[0][0]; }
327 T &
LY() {
return vals[1][0]; }
328 T &
UX() {
return vals[0][1]; }
329 T &
UY() {
return vals[1][1]; }
346 T xmin()
const {
return vals[0][0]; }
347 T xmax()
const {
return vals[0][1]; }
348 T ymin()
const {
return vals[1][0]; }
349 T ymax()
const {
return vals[1][1]; }
351 T xsize()
const {
return vals[0][1] - vals[0][0]; }
352 T ysize()
const {
return vals[1][1] - vals[1][0]; }
377 void dump(
const char *msg=
"")
const;
378 void dump(std::ostream &os)
const;
383 const T *
data()
const {
return myFloats; }
389 const T *
begin()
const {
return &myFloats[0]; }
390 const T *
end()
const {
return &myFloats[4]; }
392 T *
end() {
return &myFloats[4]; }
406 void save(std::ostream &os)
const;
409 template <
typename T>
int intersects(const UT_BoundingRectT< T > &rect, T tol) const
vint4 max(const vint4 &a, const vint4 &b)
void stretch(T percent=0.001, T min=0.001)
UT_BoundingRectT(const UT_BoundingRectT< U > &src)
UT_BoundingRectT< fpreal > UT_BoundingRectR
UT_BoundingRectT< int64 > UT_BoundingRectI
void initBounds(T xmin, T xmax, T ymin, T ymax)
const T * getSerialized() const
bool intersectIfOverlapping(const UT_BoundingRectT< T > &src)
void scale(T xscale, T yscale)
JSON reader class which handles parsing of JSON or bJSON files.
uint8 cohenSutherland(const UT_BoundingRectT< T > &box) const
Class which writes ASCII or binary JSON streams.
void enlargeBounds(const UT_BoundingRectT< T > &rect)
unsigned long long uint64
void enlargeBounds(const UT_Vector2T< T > &pt)
bool save(UT_JSONWriter &w) const
int contains(const UT_Vector2T< T > &pt, T tol) const
GLfloat GLfloat GLfloat v2
UT_BoundingRectT< float > UT_BoundingRect
int contains(T x, T y) const
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
UT_BoundingRectT< fpreal32 > UT_BoundingRectF
void initMaxBounds()
Initialize the box to the largest size.
GLubyte GLubyte GLubyte GLubyte w
GLsizei GLsizei GLfloat distance
void enlargeBounds(const fpreal32 *v)
bool isValid() const
Check whether the bounding box contains at least one point.
void initBounds(const fpreal64 *v)
T & operator()(unsigned m, unsigned n)
int intersects(const UT_BoundingRectT< T > &rect) const
void enlargeBounds(const fpreal64 *v)
void enlargeBounds(T x, T y)
int operator==(const UT_BoundingRectT< T > &brect) const
friend std::ostream & operator<<(std::ostream &os, const UT_BoundingRectT< T > &brect)
void clampX(T min, T max)
void initBounds(const UT_Vector2T< T > &pt)
UT_BoundingRectT(T xmin, T ymin, T xmax, T ymax)
UT_BoundingRectT< int32 > UT_BoundingRecti
UT_API size_t format(char *buf, size_t bufsize, const UT_BoundingRectT< T > &v)
bool intersects(const Box< Vec3< T > > &b, const Line3< T > &r, Vec3< T > &ip)
void clampY(T min, T max)
bool operator!=(const UT_BoundingRectT< T > &brect) const
Class to store JSON objects as C++ objects.
T operator()(unsigned m, unsigned n) const
UT_Vector2T< T > closestPoint(const UT_Vector2T< T > &pt) const
friend std::size_t hash_value(const this_type &t)
Compute UT_BoundingRect hash.
uint64 hash() const
Compute UT_BoundingRect hash.
void expandBounds(T dx, T dy)
vint4 min(const vint4 &a, const vint4 &b)
int isInside(const UT_BoundingRectT< T > &brect) const
void enlargeBounds(T xmin, T xmax, T ymin, T ymax)
void initBounds(T x, T y)
int contains(const UT_Vector2T< T > &pt) const
GLenum GLuint GLsizei const GLchar * buf
UT_BoundingRectT< T > this_type
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER Vec project(const Vec &s, const Vec &t)
void intersectBounds(const UT_BoundingRectT< T > &src)
UT_BoundingRectT< fpreal64 > UT_BoundingRectD
void initBounds(const fpreal32 *v)
void initBounds(const UT_BoundingRectT< T > &rect)
UT_BoundingRectT(const UT_Vector2T< T > &lowerbound, const UT_Vector2T< T > &upperbound)