HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
COP2_CookAreaInfo.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: COP2_CookAreaInfo.h
7  *
8  * COMMENTS:
9  * This class describes an area of a plane to be cooked.
10  */
11 
12 #ifndef __COP2_CookAreaInfo_h__
13 #define __COP2_CookAreaInfo_h__
14 
15 #include "COP2_API.h"
16 #include <UT/UT_SmallObject.h>
17 #include <UT/UT_Assert.h>
18 #include <SYS/SYS_Math.h>
19 #include <UT/UT_ValArray.h>
20 #include <iosfwd>
21 
22 class COP2_Node;
23 class COP2_Context;
24 class TIL_Plane;
25 
27  : public UT_SmallObject<COP2_CookAreaInfo,
28  UT_SMALLOBJECT_CLEANPAGES_OFF, 250,
29  UT_SMALLOBJECT_THREADSAFE_ON>
30 {
31 public:
32  // In this constructor, the plane is marked as not needed.
34  const TIL_Plane &plane,
35  int array_index,
36  int bounds_xstart, int bounds_ystart,
37  int bounds_xend, int bounds_yend,
38  int frame_xres, int frame_yres,
39  float time);
40 
41  // In this constructor, the plane is marked as not needed. Also, the
42  // plane does not have to be in the node's sequence.
44  const TIL_Plane &ref_plane,
45  int array_index,
46  float time);
47 
48  // In this constructor, the is marked as needed.
50  const TIL_Plane &plane,
51  int array_index,
52  int bounds_xstart, int bounds_ystart,
53  int bounds_xend, int bounds_yend,
54  int frame_xres, int frame_yres,
55  float time,
56  int needed_xstart, int needed_ystart,
57  int needed_xend, int needed_yend);
58 
59  // Create an identicaly copy of this object.
60  COP2_CookAreaInfo *clone(int array_index) const;
61 
62  // True is returned if the area needed to be grown. Note that pixels_left,
63  // pixels_down, etc. may be negative in enlargeNeededArea().
64  bool enlargeNeededArea(int xstart, int ystart, int xend, int yend);
65  bool enlargeNeededArea(COP2_CookAreaInfo &area,
66  int pixels_left = 0,
67  int pixels_down = 0,
68  int pixels_right = 0,
69  int pixels_up = 0);
70  bool enlargeNeededAreaToBounds();
71 
72  // This method expands the needed area outward by the specified number
73  // of pixels. The needed area must already be defined before calling
74  // this method. This method does not shrink the needed area, so
75  // pixels_left, pixels_down, etc. must not be negative.
76  bool expandNeededArea(int pixels_left, int pixels_down,
77  int pixels_right, int pixels_up);
78 
79  // This convenience method gets the context data for the node, using
80  // the information stored in this object.
81  COP2_Context *getNodeContextData();
82 
83 
84  // Returns true if the node, plane, array index, time and frame res match.
85  // The cook area is NOT matched.
86  bool matchPlaneInfo(const COP2_CookAreaInfo &match,
87  bool node_too = true) const;
88 
89  // Accessor functions:
90  const COP2_Node &getNode() const { return myNode; }
91  COP2_Node &getNode() { return myNode; }
92 
93  const TIL_Plane &getPlane() const { return *myPlane; }
94 
95  int getArrayIndex() const { return myArrayIndex; }
96 
97  // The image bounds for the entire plane, in frame space:
98  int getBoundsXStart() const { return myBoundsXStart; }
99  int getBoundsYStart() const { return myBoundsYStart; }
100  int getBoundsXEnd() const { return myBoundsXEnd; }
101  int getBoundsYEnd() const { return myBoundsYEnd; }
102 
103  // The scaled resolution of the frame:
104  int getFrameXRes() const { return myFrameXRes; }
105  int getFrameYRes() const { return myFrameYRes; }
106 
107  // The time at which the plane is cooking:
108  void setTime(fpreal t) { myTime = t; }
109  fpreal getTime() const { return myTime; }
110 
111  // Is this plane needed by another one?
112  bool isNeeded() const { return myIsNeeded; }
113 
114  // The image bounds for the needed area of the plane, in frame space:
115  int getNeededXStart() const { return myNeededXStart; }
116  int getNeededYStart() const { return myNeededYStart; }
117  int getNeededXEnd() const { return myNeededXEnd; }
118  int getNeededYEnd() const { return myNeededYEnd; }
119 
120  void print(std::ostream &os) const;
121 
122 private:
123  void alignNeededAreaToTileBoundaries();
124 
125  // Data:
126 
127  COP2_Node &myNode;
128  const TIL_Plane *myPlane;
129 
130  int myArrayIndex;
131 
132  // The image bounds for the entire plane, in frame space:
133  int myBoundsXStart;
134  int myBoundsYStart;
135  int myBoundsXEnd;
136  int myBoundsYEnd;
137 
138  // The scaled resolution of the frame:
139  int myFrameXRes;
140  int myFrameYRes;
141 
142  // The time at which the plane is cooking:
143  fpreal myTime;
144 
145  // Is this plane needed by another node?
146  bool myIsNeeded;
147 
148  // The image bounds for the needed area of the plane, in frame space:
149  int myNeededXStart;
150  int myNeededYStart;
151  int myNeededXEnd;
152  int myNeededYEnd;
153 };
154 
155 inline std::ostream &
156 operator<<(std::ostream &os, const COP2_CookAreaInfo &area)
157 {
158  area.print(os);
159  return os;
160 }
161 
162 
163 // This class acts like a pointer array of COP2_CookAreaInfo's, but it ensures
164 // that duplicate COP2_CookAreaInfo's are unioned together.
165 
167 {
168 public:
169  explicit COP2_CookAreaList(unsigned int sz = 0) : myList(sz) { }
171 
172  // This append method MAY change your pointer if it's already found.
173  unsigned int append(COP2_CookAreaInfo *&area);
174  unsigned int entries() const { return myList.entries(); }
175  void remove(int index) { myList.removeIndex(index); }
176 
177  void resize(int entries) { myList.setCapacity(entries); }
178  void entries(int entries) { myList.entries(entries); }
179 
180 
181  COP2_CookAreaInfo *operator()(unsigned int i) const { return myList(i); }
182 
183 private:
185 };
186 
187 #endif
COP2_Node & getNode()
fpreal getTime() const
COP2_CookAreaInfo * operator()(unsigned int i) const
int getFrameXRes() const
std::ostream & operator<<(std::ostream &os, const COP2_CookAreaInfo &area)
GT_API const UT_StringHolder time
int getBoundsYEnd() const
COP2_CookAreaList(unsigned int sz=0)
unsigned int entries() const
int getNeededXStart() const
int getBoundsXStart() const
const COP2_Node & getNode() const
void print(std::ostream &os) const
int getNeededYEnd() const
void setTime(fpreal t)
void resize(int entries)
int getBoundsXEnd() const
bool isNeeded() const
int getNeededXEnd() const
int getFrameYRes() const
GLdouble t
Definition: glad.h:2397
const TIL_Plane & getPlane() const
#define COP2_API
Definition: COP2_API.h:10
void entries(int entries)
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint index
Definition: glcorearb.h:786
int getArrayIndex() const
int getBoundsYStart() const
FMT_INLINE void print(format_string< T...> fmt, T &&...args)
Definition: core.h:2976
int getNeededYStart() const
GA_API const UT_StringHolder area