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 public:
23  : myU0(u0), myU1(u1), myV0(v0), myV1(v1)
24  {
25  }
27  : myU0(src.myU0),
28  myU1(src.myU1),
29  myV0(src.myV0),
30  myV1(src.myV1)
31  {
32  }
34 
36  {
37  init(src.myU0, src.myU1, src.myV0, src.myV1);
38  return *this;
39  }
40 
41  /// Split this parametric rectangle in U. This will become the left, the
42  /// returned value will be the right.
44  {
45  fpreal u1 = myU1;
46  myU1 = (myU0 + myU1) * .5;
47  return GT_Parametric(myU1, u1, myV0, myV1);
48  }
49  /// Split this parametric rectangle in V. This will become the bottom, the
50  /// returned value will be the top.
52  {
53  fpreal v1 = myV1;
54  myV1 = (myV0 + myV1) * .5;
55  return GT_Parametric(myU0, myU1, myV1, v1);
56  }
57 
58  bool containsU(fpreal u) const
59  { return u >= myU0 && u < myU1; }
60  bool containsV(fpreal v) const
61  { return v >= myV0 && v < myV1; }
62 
64  { return getClosest(u, myU0, myU1); }
66  { return getClosest(v, myV0, myV1); }
67 
68  fpreal getU0() const { return myU0; }
69  fpreal getU1() const { return myU1; }
70  fpreal getV0() const { return myV0; }
71  fpreal getV1() const { return myV1; }
72 
73  fpreal getDU() const { return myU1 - myU0; }
74  fpreal getDV() const { return myV1 - myV0; }
75 
77  {
78  myU0 = u0;
79  myU1 = u1;
80  myV0 = v0;
81  myV1 = v1;
82  }
83 
84  void splitU(GT_Parametric &left, GT_Parametric &right) const;
85  void splitV(GT_Parametric &bottom, GT_Parametric &top) const;
86 
87  /// Save to JSON
88  bool save(UT_JSONWriter &w) const;
89 private:
90  static inline fpreal getClosest(fpreal v, fpreal min, fpreal max)
91  {
92  if (v < min)
93  return min;
94  if (v > max)
95  return max;
96  return v;
97  }
98 
99  fpreal myU0, myU1, myV0, myV1;
100 };
101 
102 #endif
103 
GT_Parametric splitV()
Definition: GT_Parametric.h:51
fpreal closestU(fpreal u) const
Definition: GT_Parametric.h:63
GT_Parametric splitU()
Definition: GT_Parametric.h:43
GT_Parametric & operator=(const GT_Parametric &src)
Definition: GT_Parametric.h:35
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:76
GLdouble u1
Definition: glad.h:2676
GT_Parametric(fpreal u0=0, fpreal u1=1, fpreal v0=0, fpreal v1=1)
Definition: GT_Parametric.h:22
fpreal getV0() const
Definition: GT_Parametric.h:70
fpreal closestV(fpreal v) const
Definition: GT_Parametric.h:65
fpreal getU1() const
Definition: GT_Parametric.h:69
bool containsU(fpreal u) const
Definition: GT_Parametric.h:58
fpreal getU0() const
Definition: GT_Parametric.h:68
bool containsV(fpreal v) const
Definition: GT_Parametric.h:60
GLfloat v0
Definition: glcorearb.h:816
GLint GLint bottom
Definition: glcorearb.h:2005
GT_Parametric(const GT_Parametric &src)
Definition: GT_Parametric.h:26
fpreal getDV() const
Definition: GT_Parametric.h:74
fpreal64 fpreal
Definition: SYS_Types.h:277
fpreal getV1() const
Definition: GT_Parametric.h:71
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:73
GLenum src
Definition: glcorearb.h:1793