HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_Parametric.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  * NAME: GT_Parametric.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_Parametric__
12 #define __GT_Parametric__
13 
14 #include "GT_API.h"
15 #include <SYS/SYS_Types.h>
16 
17 class UT_JSONWriter;
18 
19 /// Class to keep track for a 2D parametric interval
21 {
22 public:
24  : myU0(u0), myU1(u1), myV0(v0), myV1(v1)
25  {
26  }
28  : myU0(src.myU0),
29  myU1(src.myU1),
30  myV0(src.myV0),
31  myV1(src.myV1)
32  {
33  }
35 
37  {
38  init(src.myU0, src.myU1, src.myV0, src.myV1);
39  return *this;
40  }
41 
42  /// Split this parametric rectangle in U. This will become the left, the
43  /// returned value will be the right.
45  {
46  fpreal u1 = myU1;
47  myU1 = (myU0 + myU1) * .5;
48  return GT_Parametric(myU1, u1, myV0, myV1);
49  }
50  /// Split this parametric rectangle in V. This will become the bottom, the
51  /// returned value will be the top.
53  {
54  fpreal v1 = myV1;
55  myV1 = (myV0 + myV1) * .5;
56  return GT_Parametric(myU0, myU1, myV1, v1);
57  }
58 
59  bool containsU(fpreal u) const
60  { return u >= myU0 && u < myU1; }
61  bool containsV(fpreal v) const
62  { return v >= myV0 && v < myV1; }
63 
65  { return getClosest(u, myU0, myU1); }
67  { return getClosest(v, myV0, myV1); }
68 
69  fpreal getU0() const { return myU0; }
70  fpreal getU1() const { return myU1; }
71  fpreal getV0() const { return myV0; }
72  fpreal getV1() const { return myV1; }
73 
74  fpreal getDU() const { return myU1 - myU0; }
75  fpreal getDV() const { return myV1 - myV0; }
76 
78  {
79  myU0 = u0;
80  myU1 = u1;
81  myV0 = v0;
82  myV1 = v1;
83  }
84 
85  void splitU(GT_Parametric &left, GT_Parametric &right) const;
86  void splitV(GT_Parametric &bottom, GT_Parametric &top) const;
87 
88  /// Save to JSON
89  bool save(UT_JSONWriter &w) const;
90 private:
91  static inline fpreal getClosest(fpreal v, fpreal min, fpreal max)
92  {
93  if (v < min)
94  return min;
95  if (v > max)
96  return max;
97  return v;
98  }
99 
100  fpreal myU0, myU1, myV0, myV1;
101 };
102 
103 #endif
104 
GT_Parametric splitV()
Definition: GT_Parametric.h:52
fpreal closestU(fpreal u) const
Definition: GT_Parametric.h:64
GT_Parametric splitU()
Definition: GT_Parametric.h:44
GT_Parametric & operator=(const GT_Parametric &src)
Definition: GT_Parametric.h:36
GLint left
Definition: glcorearb.h:2005
const GLdouble * v
Definition: glcorearb.h:837
GLdouble right
Definition: glad.h:2817
Class to keep track for a 2D parametric interval.
Definition: GT_Parametric.h:20
#define GT_API
Definition: GT_API.h:13
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
void init(fpreal u0, fpreal u1, fpreal v0, fpreal v1)
Definition: GT_Parametric.h:77
GLdouble u1
Definition: glad.h:2676
GT_Parametric(fpreal u0=0, fpreal u1=1, fpreal v0=0, fpreal v1=1)
Definition: GT_Parametric.h:23
fpreal getV0() const
Definition: GT_Parametric.h:71
fpreal closestV(fpreal v) const
Definition: GT_Parametric.h:66
fpreal getU1() const
Definition: GT_Parametric.h:70
bool containsU(fpreal u) const
Definition: GT_Parametric.h:59
fpreal getU0() const
Definition: GT_Parametric.h:69
bool containsV(fpreal v) const
Definition: GT_Parametric.h:61
GLfloat v0
Definition: glcorearb.h:816
GLint GLint bottom
Definition: glcorearb.h:2005
GT_Parametric(const GT_Parametric &src)
Definition: GT_Parametric.h:27
fpreal getDV() const
Definition: GT_Parametric.h:75
fpreal64 fpreal
Definition: SYS_Types.h:278
fpreal getV1() const
Definition: GT_Parametric.h:72
GLfloat GLfloat v1
Definition: glcorearb.h:817
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GLdouble GLdouble GLdouble top
Definition: glad.h:2817
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
fpreal getDU() const
Definition: GT_Parametric.h:74
GLenum src
Definition: glcorearb.h:1793