HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 
49  SWIGOUT(%ignore HOM_BoundingRect(const UT_BoundingRectD &);)
51  : myBoundingRect(rect)
52  { HOM_CONSTRUCT_OBJECT(this) }
53 
54  SWIGOUT(%ignore HOM_BoundingRect(const UT_BoundingRectF &);)
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 
83  { return HOM_Vector2(myBoundingRect.xmin(), myBoundingRect.ymin()); }
85  { return HOM_Vector2(myBoundingRect.xmax(), myBoundingRect.ymax()); }
87  { return HOM_Vector2(myBoundingRect.sizeX(), myBoundingRect.sizeY()); }
89  { return HOM_Vector2(myBoundingRect.centerX(), myBoundingRect.centerY()); }
90  HOM_Vector2 getOffsetToAvoid(HOM_BoundingRect &bounds,
91  HOM_Vector2 *direction = NULL);
92 
93  void enlargeToContain(const std::vector<double> &point);
95  { myBoundingRect.enlargeBounds(rect.myBoundingRect); }
96  void intersect(const HOM_BoundingRect &rect)
97  { myBoundingRect.intersectBounds(rect.myBoundingRect); }
98 
99  bool intersects(const std::vector<double> &point0,
100  const std::vector<double> &point1,
101  const std::vector<double> &point2);
102  bool intersects(const std::vector<double> &point0,
103  const std::vector<double> &point1);
104  bool intersects(const HOM_BoundingRect &rect)
105  { return myBoundingRect.intersects(rect.myBoundingRect); }
106 
107  bool contains(const std::vector<double> &point);
108  bool contains(const HOM_BoundingRect &rect)
109  { return rect.myBoundingRect.isInside(myBoundingRect); }
110  HOM_Vector2 closestPoint(const std::vector<double> &point);
111 
112  SWIGOUT(%ignore operator=;)
113  HOM_BoundingRect &operator=(const HOM_BoundingRect& rect)
114  {
115  myBoundingRect = rect.myBoundingRect;
116  return *this;
117  }
118 
120  { return &myBoundingRect; }
121 
122  SWIGOUT(%ignore myBoundingRect;)
123  UT_BoundingRectD myBoundingRect;
124 };
125 
126 #endif
#define SYSmax(a, b)
Definition: SYS_Math.h:1365
HOM_BoundingRect(const HOM_BoundingRect &src)
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:973
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:813
UT_BoundingRectD myBoundingRect
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
std::string __repr__()
bool operator==(HOM_PtrOrNull< HOM_BoundingRect > rect)
GLint y
Definition: glcorearb.h:102
HOM_Vector2 size()
GA_API const UT_StringHolder scale
std::string __str__()
#define HOM_API
Definition: HOM_API.h:13
bool contains(const HOM_BoundingRect &rect)
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:972
int __hash__()
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)
bool operator!=(HOM_PtrOrNull< HOM_BoundingRect > rect)
void setTo(const std::vector< double > &sequence)
bool isAlmostEqual(HOM_Matrix4 &matrix4, double tolerance=0.00001)
bool intersects(const Box< Vec3< T > > &b, const Line3< T > &r, Vec3< T > &ip)
Definition: ImathBoxAlgo.h:728
GLint GLenum GLint x
Definition: glcorearb.h:408
int isInside(const UT_BoundingRectT< T > &brect) const
#define SYSmin(a, b)
Definition: SYS_Math.h:1366
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:596
void intersect(const HOM_BoundingRect &rect)
HOM_BoundingRect(const UT_BoundingRectD &rect)
GLenum src
Definition: glcorearb.h:1792