HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_BoundingRect.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  */
8 
9 #ifndef __HOM_BoundingRect_h__
10 #define __HOM_BoundingRect_h__
11 
12 #include "HOM_API.h"
13 #include "HOM_Defines.h"
14 #include "HOM_Errors.h"
15 #include "HOM_Module.h"
16 #include "HOM_Vector2.h"
17 #include "HOM_PtrOrNull.h"
18 #include <UT/UT_BoundingRect.h>
19 #include <vector>
20 
21 class HOM_Matrix4;
22 
23 SWIGOUT(%rename(BoundingRect) HOM_BoundingRect;)
24 
26 {
27 public:
29  { HOM_CONSTRUCT_OBJECT(this); myBoundingRect.initBounds(); }
30 
31  HOM_BoundingRect(double x1, double y1, double x2, double y2)
32  : myBoundingRect(SYSmin(x1, x2),
33  SYSmin(y1, y2),
34  SYSmax(x1, x2),
35  SYSmax(y1, y2))
36  { HOM_CONSTRUCT_OBJECT(this) }
37 
38  HOM_BoundingRect(const HOM_Vector2 &pos1, const HOM_Vector2 &pos2)
39  : myBoundingRect(SYSmin(pos1.myVector2.x(), pos2.myVector2.x()),
40  SYSmin(pos1.myVector2.y(), pos2.myVector2.y()),
41  SYSmax(pos1.myVector2.x(), pos2.myVector2.x()),
42  SYSmax(pos1.myVector2.y(), pos2.myVector2.y()))
43  { HOM_CONSTRUCT_OBJECT(this) }
44 
46  : myBoundingRect(src.myBoundingRect)
47  { HOM_CONSTRUCT_OBJECT(this) }
48 
51  : myBoundingRect(rect)
52  { HOM_CONSTRUCT_OBJECT(this) }
53 
56  : myBoundingRect(rect.xmin(), rect.ymin(), rect.xmax(), rect.ymax())
57  { HOM_CONSTRUCT_OBJECT(this) }
58 
60  { HOM_DESTRUCT_OBJECT(this) }
61 
63  { return rect.myPointer && myBoundingRect==rect.myPointer->myBoundingRect; }
64 
66  { return !operator==(rect); }
67 
68  bool isAlmostEqual(HOM_BoundingRect &rect, double tolerance=0.00001);
69 
70  int __hash__();
73 
74  bool isValid()
75  { return myBoundingRect.isValid(); }
76 
77  void setTo(const std::vector<double> &tuple);
78  void translate(const std::vector<double> &tuple);
79  void scale(const std::vector<double> &tuple);
80  void expand(const std::vector<double> &tuple);
81 
82  SWIGOUT(%warnfilter(321) min;)
84  { return HOM_Vector2(myBoundingRect.xmin(), myBoundingRect.ymin()); }
85  SWIGOUT(%warnfilter(321) max;)
87  { return HOM_Vector2(myBoundingRect.xmax(), myBoundingRect.ymax()); }
89  { return HOM_Vector2(myBoundingRect.sizeX(), myBoundingRect.sizeY()); }
91  { return HOM_Vector2(myBoundingRect.centerX(), myBoundingRect.centerY()); }
92  HOM_Vector2 getOffsetToAvoid(HOM_BoundingRect &bounds,
93  HOM_Vector2 *direction = NULL);
94 
95  void enlargeToContain(const std::vector<double> &point);
97  { myBoundingRect.enlargeBounds(rect.myBoundingRect); }
98  void intersect(const HOM_BoundingRect &rect)
99  { myBoundingRect.intersectBounds(rect.myBoundingRect); }
100 
101  bool intersects(const std::vector<double> &point0,
102  const std::vector<double> &point1,
103  const std::vector<double> &point2);
104  bool intersects(const std::vector<double> &point0,
105  const std::vector<double> &point1);
106  bool intersects(const HOM_BoundingRect &rect)
107  { return myBoundingRect.intersects(rect.myBoundingRect); }
108 
109  bool contains(const std::vector<double> &point);
110  bool contains(const HOM_BoundingRect &rect)
111  { return rect.myBoundingRect.isInside(myBoundingRect); }
112  HOM_Vector2 closestPoint(const std::vector<double> &point);
113 
114  SWIGOUT(%ignore operator=;)
115  HOM_BoundingRect &operator=(const HOM_BoundingRect& rect)
116  {
117  myBoundingRect = rect.myBoundingRect;
118  return *this;
119  }
120 
122  { return &myBoundingRect; }
123 
124  SWIGOUT(%ignore myBoundingRect;)
125  UT_BoundingRectD myBoundingRect;
126 };
127 
128 #endif
#define SYSmax(a, b)
Definition: SYS_Math.h:1538
HOM_BoundingRect(const HOM_BoundingRect &src)
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1291
HOM_BoundingRect(const HOM_Vector2 &pos1, const HOM_Vector2 &pos2)
bool intersects(const HOM_BoundingRect &rect)
IMF_EXPORT IMATH_NAMESPACE::V3f direction(const IMATH_NAMESPACE::Box2i &dataWindow, const IMATH_NAMESPACE::V2f &pixelPosition)
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
UT_BoundingRectD myBoundingRect
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
bool operator==(HOM_PtrOrNull< HOM_BoundingRect > rect)
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:352
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GLint y
Definition: glcorearb.h:103
GLdouble GLdouble x2
Definition: glad.h:2349
HOM_Vector2 size()
GA_API const UT_StringHolder scale
std::string __str__()
#define HOM_API
Definition: HOM_API.h:13
void ignore(T const &) VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6508
bool contains(const HOM_BoundingRect &rect)
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1290
int __hash__()
GLdouble y1
Definition: glad.h:2349
HOM_Vector2 center()
void enlargeToContain(const HOM_BoundingRect &rect)
HOM_BoundingRect(const UT_BoundingRectF &rect)
HOM_Vector2 max()
HOM_Vector2 min()
HOM_BoundingRect(double x1, double y1, double x2, double y2)
GLint GLenum GLint x
Definition: glcorearb.h:409
bool operator!=(HOM_PtrOrNull< HOM_BoundingRect > rect)
void setTo(const std::vector< double > &sequence)
bool isAlmostEqual(HOM_Matrix4 &matrix4, double tolerance=0.00001)
OIIO_UTIL_API bool rename(string_view from, string_view to, std::string &err)
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool intersects(const Box< Vec3< T >> &b, const Line3< T > &r, Vec3< T > &ip) IMATH_NOEXCEPT
Definition: ImathBoxAlgo.h:642
PUGI__FN char_t * translate(char_t *buffer, const char_t *from, const char_t *to, size_t to_length)
Definition: pugixml.cpp:8352
GLdouble GLdouble GLdouble y2
Definition: glad.h:2349
int isInside(const UT_BoundingRectT< T > &brect) const
#define SYSmin(a, b)
Definition: SYS_Math.h:1539
bool OIIO_UTIL_API contains(string_view a, string_view b)
Does 'a' contain the string 'b' within it?
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
void intersect(const HOM_BoundingRect &rect)
HOM_BoundingRect(const UT_BoundingRectD &rect)
GLenum src
Definition: glcorearb.h:1793