HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMX_Layer.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  */
7 
8 #pragma once
9 
10 #include "IMX_API.h"
11 
12 #include "IMX_Buffer.h"
13 
14 #include <UT/UT_Array.h>
15 #include <UT/UT_CameraParms.h>
16 #include <UT/UT_Matrix4.h>
17 #include <UT/UT_Rect.h>
18 #include <UT/UT_SharedPtr.h>
19 #include <UT/UT_Vector3.h>
20 #include <UT/UT_Vector4.h>
21 #include <UT/UT_Options.h>
22 
23 /// This is the object read/written by IMX_Node. It is (usually) one AOV (a
24 /// Vec4f per pixel) of an image.
25 
26 class IMX_Layer;
29 
31 {
32 public:
33 
34  static constexpr UT_StringLit theCameraMetadataKey = "camera_metadata";
35 
36  IMX_Layer() { setDefault(); }
37 
38  /// "copy constructor" that does not copy the buffer pixels
39  IMX_Layer(const IMX_Layer &a, bool) { copyMetadata(a); }
40 
41  /// Initialize the IMX_Buffer
43  : IMX_Buffer(width, height, storage, channels)
44  {
45  setDefault(); // Initialize metadata
46  }
47 
48  /// Construct a layer from a PXL_Raster
49  IMX_Layer(const PXL_Raster &rp)
50  : IMX_Buffer(rp) // Create the underlying buffer
51  {
52  setDefault(); // Initialize metadata
53  setDataWindow(bufferWidth(), bufferHeight());
54  setBufferToPixels();
55  }
56 
57  /// Returns true for successful save.
58  bool save(std::ostream &os) const;
59  bool saveJSON(UT_JSONWriter &w) const;
60 
61  /// Returns a newly created Layer loaded from the stream, or null
62  /// if load failure.
63  static IMX_LayerPtr load(UT_IStream &is);
64  static IMX_LayerPtr loadJSON(UT_JSONParser &p);
65 
66  /// Write our fields into the provided options:
67  /// THis does not include the stat block, nor properties.
68  void copyMetadataToOptions(UT_Options &opt) const;
69  /// Load ourselves from the options, ignoring fields we don't know
70  void updateMetadataFromOptions(const UT_Options &opt);
71 
72  ////////////////////////////////////////////////////////////////
73  // Accessors for image data
74 
75  /// The dataWindow surrounds all the pixels
76  const UT_DimRect& dataWindow() const { return d->myDataWindow; }
77  int x() const { return d->myDataWindow.x(); }
78  int y() const { return d->myDataWindow.y(); }
79  UT_Vector2I xy() const { return UT_Vector2I(d->myDataWindow.data()); }
80  int width() const { return d->myDataWindow.width(); }
81  int height() const { return d->myDataWindow.height(); }
82  UT_Vector2I wh() const { return UT_Vector2I(d->myDataWindow.width(), d->myDataWindow.height()); }
83  int r() const { return d->myDataWindow.x2(); }
84  int t() const { return d->myDataWindow.y2(); }
85  UT_Vector2I rt() const { return UT_Vector2I(d->myDataWindow.x2(), d->myDataWindow.y2()); }
86 
87  /// Distortion in image->pixel space transform
88  fpreal64 pixelAspectRatio() const { return d->myPixelAspectRatio; }
89 
90  /// World space voxel size, where xy is the pixel size and z is max(x,y).
91  UT_Vector3D voxelSize() const;
92 
93  /// Aperture in pixels
94  const UT_Vector2D &displayWindowSize() const { return d->myDisplayWindowSize; }
95  UT_Vector2D displayWindowXY() const { return d->myImageToPixelTranslate - d->myDisplayWindowSize / 2; }
96  UT_Vector2D displayWindowRT() const { return d->myImageToPixelTranslate + d->myDisplayWindowSize / 2; }
97 
98  /// width / height of the aperture / displayWindow
100  { return d->myPixelAspectRatio * d->myDisplayWindowSize[0] / d->myDisplayWindowSize[1]; }
101 
102  /// Camera
106  fpreal64 apertureMax() const { return d->myApertureMax; }
107  fpreal64 focalLength() const { return d->myFocalLength; }
108  fpreal64 fStop() const { return d->myFStop; }
109  fpreal64 lensDiameter() const { return focalLength() * d->myFStop; }
110  const UT_Vector2D &clippingRange() const { return d->myClippingRange; }
111  fpreal64 focusDistance() const { return d->myFocusDistance; }
112  const UT_Vector3D &cameraPosition() const { return d->myCamera; }
113  fpreal64 cameraZ() const { return d->myCamera[2]; }
114  fpreal64 imagingDist() const { return cameraZ(); }
115  fpreal64 guideScale() const { return d->myGuideScale; }
116  const UT_Vector2D &shutter() const { return d->myShutter; }
117 
118  void getCameraParms(UT_CameraParms &cam_parms, UT_Matrix4D &xform) const;
119  void setCameraParms(const UT_CameraParms &cam_parms, const UT_Matrix4D &xform);
120 
121  /// Transform from camera space to image space.
122  UT_Matrix4D projectionXform() const;
123 
124  /// Transform from camera space to texture space for Vulkan rasterization
125  UT_Matrix4D projectionXformVk() const;
126 
127  /// Transform from image space to world space.
128  UT_Matrix4D baseTransform() const { return d->myTransform; }
129  UT_Matrix4D transform() const { return imageToWorldXform(); }
131  {
132  UT_Matrix4D xform = baseTransform();
133  xform.prescale(d->myImagingScale);
134 
135  // Image space has a unit z scale to world space.
136  // If this assert was triggered, we likely missed setBufferXforms().
137  UT_ASSERT(SYSisEqual(UT_Vector3D(xform(2)).length2(), 1.0));
138 
139  return xform;
140  }
141 
142  UT_Vector3D imagingScale() const { return d->myImagingScale; }
143 
144  /// Transform from world space to camera space.
145  /// Equal to invert(transform()).translate(-cameraPosition())
146  UT_Matrix4D inverseCameraXform() const;
147 
148  ////////////////////////////////////////////////////////////////
149  /// Coordinate transforms
150  // translate is always done after scale
151 
152  const UT_Vector2D &imageToPixelScale() const { return d->myImageToPixelScale; }
153  const UT_Vector2D &imageToPixelTranslate() const { return d->myImageToPixelTranslate; }
154 
155  const UT_Vector2D &bufferToPixelScale() const { return myBufferToPixelScale; }
157  { return 1.0 / UT_Vector2D(bufferWidth(), bufferHeight()); }
158  UT_Vector2D bufferToLocalScale() const { return UT_Vector2D(voxelSize()); }
160  { return UT_Vector2D(bufferWidth(), bufferHeight()); }
161  const UT_Vector2D &pixelScale() const { return myBufferToPixelScale; }
162  bool isPixelScale() const { return pixelScale() != UT_Vector2D(1,1); }
163  const UT_Vector2D &bufferToPixelTranslate() const { return myBufferToPixelTranslate; }
164 
166  { return d->myImageToPixelScale / myBufferToPixelScale; }
168  { return (d->myImageToPixelTranslate - myBufferToPixelTranslate) / myBufferToPixelScale; }
170  { return myBufferToPixelScale / d->myImageToPixelScale; }
171 
172  /// Image <-> Pixel
174  { return v * imageToPixelScale() + imageToPixelTranslate(); }
176  { return (v - imageToPixelTranslate()) / imageToPixelScale(); }
177 
178  /// Pixel <-> Buffer
180  { return (v - bufferToPixelTranslate()) / bufferToPixelScale(); }
182  { return v * bufferToPixelScale() + bufferToPixelTranslate(); }
183 
184  /// Image <-> Buffer
186  { return pixelToBuffer(imageToPixel(v)); }
188  { return pixelToImage(bufferToPixel(v)); }
189 
190  // Buffer <-> texture, this is not just a scale as texture goes
191  // to the corners of pixels, but buffer is to the center.
193  { return (v + 0.5f) * bufferToTextureScale(); }
195  { return v * textureToBufferScale() - 0.5f; }
196 
197  // Image <-> texture
199  { return bufferToTexture(imageToBuffer(v)); }
201  { return bufferToImage(textureToBuffer(v)); }
202 
203  // Transform point texture <-> pixel:
205  { return bufferToPixel(textureToBuffer(v)); }
207  { return bufferToTexture(pixelToBuffer(v)); }
208 
209  // Image <-> world
211  { return image3ToWorld(UT_Vector3D(v.x(), v.y(), 0)); }
213  { UT_Vector3D image = worldToImage3(v);
214  return UT_Vector2D(image.x(), image.y()); }
215  UT_Vector3D image3ToWorld(const UT_Vector3D &v) const;
216  UT_Vector3D worldToImage3(const UT_Vector3D &v) const;
217 
218  // Image <-> local
220  { return UT_Vector3D(v * imageToBufferScale() * bufferToLocalScale()); }
222  { return UT_Vector2D(v) / bufferToLocalScale() / imageToBufferScale(); }
224  {
225  UT_Vector3D s(imageToBufferScale() * bufferToLocalScale());
226  s.z() = 1;
227  return v * s;
228  }
230  {
231  UT_Vector3D s(imageToBufferScale() * bufferToLocalScale());
232  s.z() = 1;
233  return v / s;
234  }
235 
236  // Local <-> world
238  { return image3ToWorld(localToImage3(v)); }
240  { return image3ToLocal(worldToImage3(v)); }
241 
242  /// This is used to convert the layer to a volume, so the resulting
243  /// buffer coordinates will line up with the canonical "volume" space.
244  /// The z-scale is set so that the volume has isotropic voxels.
245  /// If pixels are not square, voxelsize.z is max(voxelsize.x, voxelsize.y).
246  UT_Matrix4D bufferUVToWorldXform(fpreal *taper = nullptr) const;
247  /// Sets the world transform such that the given transformation becomes this
248  /// layer's UV to world.
249  void setBufferUVToWorldXform(UT_Matrix4D xform, fpreal taper);
250 
251  /// Initializes this layer from a given voxel array. Number of channels in
252  /// the image will be set to tuple size of T, and the data type will also be
253  /// set accordingly. Z-resolution of src must be 1.
254  /// If data_too is true, the data is also copied from the source array;
255  /// otherwise, this layer is only appropriate formatted and sized to match
256  /// the input.
257  template <typename T>
258  void initFromVoxels(const UT_VoxelArray<T>& src, bool data_too);
259 
260  ////////////////////////////////////////////////////////////////
261  /// Modifications to layer metadata, in approximate order you call them.
262 
263  /// reset metadata to default value
264  void setDefault();
265 
266  /// Reset the transform and camera metadata to the default.
267  /// Unlike setDefault(), this does not reset the data or display windows.
268  void setCanonical();
269 
270  /// Copy everything except the buffer allocations, leaving the result dirty.
271  /// This avoids any chance that writing this layer will modify the original layer.
272  /// It also avoids shared pointer overhead and keeping buffers around longer than needed.
273  void copyMetadata(const IMX_Layer& a)
274  {
276  myBufferToPixelScale = a.myBufferToPixelScale;
277  myBufferToPixelTranslate = a.myBufferToPixelTranslate;
278  d = a.d;
279  myProperties = a.myProperties;
280  }
281 
282  /// Set pixel aspect ratio. This must be done before setDataWindow
283  void setPixelAspectRatio(fpreal64 pa) { wd()->myPixelAspectRatio = pa; }
284 
285  /// Set both dataWindow and displayWindow to the same rectangle
286  void setDataWindow(int w, int h) { setDataWindow(0, 0, w, h); }
287  void setDataWindow(int x, int y, int w, int h)
288  {
289  wd()->myDataWindow.set(x, y, w, h);
290  setDisplayWindow(x, y, w, h);
291  }
292 
293  /// Set dataWindow w/o changing displayWindow
294  void setDataWindowOnly(int x, int y, int w, int h) { wd()->myDataWindow.set(x, y, w, h); }
295 
296  /// Set the displayWindow w/o changing dataWindow
297  void setDisplayWindow(int w, int h) { setDisplayWindow(0, 0, w, h); }
298  void setDisplayWindow(int x, int y, int w, int h)
299  { setDisplayWindow(UT_Vector2D(x,y), UT_Vector2D(w,h)); }
300  void setDisplayWindow(const UT_Vector2D &xy, const UT_Vector2D &wh)
301  {
302  Metadata *w = wd();
303  w->myDisplayWindowSize = wh;
304  const fpreal64 pa = w->myPixelAspectRatio;
305  const fpreal64 m = (pa * wh[0] >= wh[1]) ? wh[0] / 2 : wh[1] / 2 / pa;
306  w->myImageToPixelScale.assign(m, m * pa);
307  w->myImageToPixelTranslate = xy + wh / 2;
308  }
309 
310  void setDisplayWindow(const UT_DimRect &rect)
311  {
312  setDisplayWindow(rect.x(), rect.y(), rect.w(), rect.h());
313  }
314 
315  /// Our "pixel" space 0,0 doesn't necessarily correspond to the
316  /// corner of our Image space. This adjusts that offset by panning
317  /// both the data and the dispaly window. Data window is always
318  /// integral so this only allows pixel level adjustment.
319  void translatePixelOrigin(int dx, int dy)
320  {
321  Metadata *w = wd();
322  w->myImageToPixelTranslate += UT_Vector2D(dx, dy);
323  w->myDataWindow.setX(w->myDataWindow.x()+dx);
324  w->myDataWindow.setY(w->myDataWindow.y()+dy);
325  myBufferToPixelTranslate += UT_Vector2D(dx, dy);
326  setBufferXforms();
327  }
328 
329  /// Set the aspect ratio of displayWindow exactly, centering the new displayWindow
330  /// into the old one, two sides will be unchanged, others may be non-integers.
331  void setApertureAspect(int n, int d) { setApertureAspect(fpreal64(n)/d); }
332  void setApertureAspect(fpreal64 a);
333 
334  // set up the camera. You must call these in approximately this order:
336  { if (statProjection() == p) return;
338  void setOrtho() { setProjection(IMX_Projection::IMX_ORTHOGRAPHIC); }
340  void setCameraPosition(const UT_Vector3D &p) { wdf()->myCamera = p; setBufferXforms(); }
341  void setCameraZ(fpreal64 z) { wdf()->myCamera[2] = z; setBufferXforms(); }
342  void setImagingDist(fpreal64 z);
343  void setAperture(fpreal64 mm) { wd()->myApertureMax = mm; setBufferXforms(); }
344  void setApertureOffset(const UT_Vector2D &p) { setApertureCenter(p * (2 / d->myApertureMax)); setBufferXforms(); }
345  void setApertureCenter(const UT_Vector2D &p) // same but in image units
346  { UT_Vector3D &c = wdf()->myCamera; c[0] = -p[0]; c[1] = -p[1]; setBufferXforms(); }
347  void setFocalLength(fpreal64 mm) { wdf()->myFocalLength = mm; setBufferXforms(); }
348  void setFStop(fpreal64 f) { wd()->myFStop = f; setBufferXforms(); }
349  void setLensDiameter(fpreal64 mm) { wd()->myFStop = mm / focalLength(); setBufferXforms(); }
350  void setClippingRange(const UT_Vector2D &v) { wd()->myClippingRange = v; setBufferXforms(); }
351  void setFocusDistance(fpreal64 f) { wd()->myFocusDistance = f; setBufferXforms(); }
352  void setShutter(const UT_Vector2D &v) { wd()->myShutter = v; setBufferXforms(); }
353 
354  /// this can be set at any time as it doesn't affect the buffer's xforms
355  /// it's only used to change the display of metadata only layers
356  /// as they display as cameras
357  void setGuideScale(fpreal64 scale) { wd()->myGuideScale = scale; }
358 
359  /// set the imageToWorld transform. This can be done at any time
360  void setBaseTransform(const UT_Matrix4D& m) { wdf()->myTransform = m; setBufferXforms(); }
361  void transform(const UT_Matrix4D& m) { wdf()->myTransform *= m; setBufferXforms(); }
362  void preTransform(const UT_Matrix4D& m) { wdf()->myTransform.preMultiply(m); setBufferXforms(); }
363  void setImageToWorldXform(const UT_Matrix4D &m);
364  /// set the inverseCameraTransform which will set the transform.
365  /// Using this avoids multiple inverts of the matrix to get the value back.
366  void setInverseCameraXform(const UT_Matrix4D& m);
367 
368  ////////////////////////////////////////////////////////////////
369  /// One of these functions *must* be called after changing the display or dataWindow.
370  /// This will correctly set up the buffer size and transformations.
371  /// ALL of these _may_ freeBuffers() and make your layer dirty(),
372  /// especially with constant source layers. They may leave it intact,
373  /// if resizing isn't needed, but that should not be relied upon.
374 
375  /// Directly set the buffer size. The bufferToPixel transform is set so
376  /// this rectangle is mapped to the dataWindow.
377  /// Note this overrides the IMX_Buffer method.
378  void setBufferSize(int w, int h);
379 
380  /// Set buffer size so each buffer pixel is approximately this many pixels.
381  /// Value is adjusted down so the width() and height() are an integer number of
382  /// buffer pixels. Very tiny numbers are clamped to a minimum.
383  void setPixelScale(const UT_Vector2D&);
384 
385  /// Make the buffer pixels match the pixels. Same as setPixelScale(1), or
386  /// setBufferSize(width(), height())
388  {
389  myBufferToPixelScale = 1;
390  myBufferToPixelTranslate.assign(x()+0.5f, y()+0.5f);
391  setBufferSize(width(), height());
392  setBufferXforms();
393  }
394 
395  /// Sets the buffer so isAligned(src) is true. Pretty much the same as
396  /// copying the pixelScale but this will allow the buffer edges to
397  /// not match the datawindow at all.
398  void setAligned(const IMX_Layer& src);
399 
400  /// Exactly set pixelScale, however upper-right pixels of buffer may
401  /// go outside of the dataWindow. Values outside the range 1..width() are
402  /// not recommended.
403  void setBufferToPixelScale(const UT_Vector2D &p);
404 
405  /// Adjust the transform so the lower-left corner of the dataWindow and buffer
406  /// don't match. This value is where the center of the lower-left buffer pixel
407  /// is in pixel space.
408  void setBufferToPixelTranslate(const UT_Vector2D &p);
409 
411  { myProperties = props; }
413  { return myProperties; }
414 
415  /// Updates the contents of the properties, first making sure it is
416  /// unique. The provided operator should take a reference to
417  /// a UT_Options that it will update.
418  /// this->update([](UT_Options &opt) { opt.setOptionS("test", "bar"); });
419  template <typename OP>
420  void updateProperties(const OP &op)
421  { myProperties.update(op); }
422 
423  /// Layer registration to allow layers to be converted
424  /// to integers across HOM boundaries.
425 
426  /// Registers & returns the handle, adding the handle to the registered
427  /// list
428  static int registerLayer(IMX_LayerConstPtr layer, UT_IntArray &registered);
429  /// Unregister all layers corresponding to the provided list,
430  /// erase the list afterwards. Assertion if handle wasn't regsitered
431  static void unregisterLayers(UT_IntArray &registered);
432  /// Look up a registered layer by handle.
433  static IMX_LayerConstPtr lookupLayer(int handle);
434 
435  /// a layer that is metadata only does not have a buffer
436  /// and is represented in the viewport by a camera along
437  /// with an imaging plane
438  /// layers marked metadata only can only be plugged into metadata inputs
439  void setIsMetadataOnly(bool v) { myIsMetadataOnly = v; }
440  bool isMetadataOnly() const { return myIsMetadataOnly; }
441 
442  /// Compute useful aggregate properties of the layer.
443  /// For integer layers, use computeMinI() and computeMaxI().
444  fpreal64 computeMin(int channel = 0) const;
445  fpreal64 computeMax(int channel = 0) const;
446  fpreal64 computeMinLength() const;
447  fpreal64 computeMaxLength() const;
448  fpreal64 computeAverage(int channel = 0) const;
449  exint computeMinI(int channel = 0) const;
450  exint computeMaxI(int channel = 0) const;
451 
452 private:
453  void setBufferXforms();
454 
455  /// The settings of this are also stored in IMX_Buffer::setBufferXforms.
456  /// This is kept here to avoid rounding errors recovering the values
457  UT_Vector2D myBufferToPixelScale{1,1};
458  UT_Vector2D myBufferToPixelTranslate{0.5, 0.5};
459 
460  /// All info that is often identical between images is in this shared object
461  struct Metadata
462  {
463  // Default size is 1x1, no one should be leaking default sizes
464  // but instead should be getting the proper values from
465  // context options or from input data.
466  UT_DimRect myDataWindow{0, 0, 1, 1}; // overall size
467  UT_Vector2D myDisplayWindowSize{1, 1};
468  fpreal64 myPixelAspectRatio = 1.0f;
469  UT_Vector2D myImageToPixelScale{0.5, 0.5};
470  UT_Vector2D myImageToPixelTranslate{0.5, 0.5};
471 
472  // Camera:
473  // Projection is in stat.
474  fpreal64 myApertureMax = 20.955;
475  fpreal64 myFocalLength = 10.4775;
476  // camera z implicitly defines the imaging plane's distance
477  // from the camera, as our imaging plane is at zero.
478  // Camera position is in imaging space-relative World space.
479  // It thus always represents world-distance offsets, so scaling
480  // myTransform would leave camera unscaled.
481  // It is relative to the origin of the imaging space, using
482  // the space (possibly non-ortho, but normalized) defined by
483  // myTransform.
484  UT_Vector3D myCamera{0, 0, 1}; // camera pos in image-relative world space
485  // The x and y components are the size of imaging plane,
486  // Has to update with cameraz/focallength/aperture
487  // Could be baked into myTransform, but then we'd lose precision
488  // on updates.
489  // The z component is the reciprocal of myTransform's z-scale,
490  // and ensures that image space has a unit z scale to world space.
491  UT_Vector3D myImagingScale{1, 1, 1};
492  // The scale sizes of the axes of the imaging space at the
493  // imaging origin (so independent of taper) This is baked
494  // into myTransform and is used to convert imagelengths to
495  // world lengths.
496  UT_Vector3D myTransformScale{1, 1, 1};
497  UT_Vector2D myClippingRange{0, 2}; // near/far in image space
498  fpreal64 myFocusDistance = 0; // relative to origin
499  fpreal64 myFStop = 0;
500  UT_Vector2D myShutter{-0.25, 0.25}; // usd default is 0,0
501 
502  // only used for metadata only layers as they draw as cameras
503  fpreal64 myGuideScale = 1.0;
504 
505  // lens distortion
506 
507  UT_Matrix4D myTransform{1}; // transform to world space
508  mutable UT_Matrix4D myICXform{1}; // myTransform.invert.translate(-myCamera)
509  mutable bool fixICXform = true; // myICXform is out of date
510  };
511 
513 
514  UT_OptionsHolder myProperties;
515 
516  Metadata *wd();
517  Metadata *wdf() { Metadata *w = wd(); w->fixICXform = true; return w; }
518 
519  bool myIsMetadataOnly = false;
520 };
UT_Vector2T< int64 > UT_Vector2I
void copyMetadata(const IMX_Buffer &source)
bool SYSisEqual(const UT_Vector2T< T > &a, const UT_Vector2T< T > &b, S tol)
Componentwise equality.
Definition: UT_Vector2.h:677
UT_Vector2I rt() const
Definition: IMX_Layer.h:85
UT_Vector2D bufferToPixel(const UT_Vector2D &v) const
Definition: IMX_Layer.h:181
UT_Vector2D textureToImage(const UT_Vector2D &v) const
Definition: IMX_Layer.h:200
UT_Vector2D imageToBuffer(const UT_Vector2D &v) const
Image <-> Buffer.
Definition: IMX_Layer.h:185
void setPerspective()
Definition: IMX_Layer.h:339
int x() const
Definition: IMX_Layer.h:77
void setCameraPosition(const UT_Vector3D &p)
Definition: IMX_Layer.h:340
bool isMetadataOnly() const
Definition: IMX_Layer.h:440
fpreal64 focalLength() const
Definition: IMX_Layer.h:107
void updateProperties(const OP &op)
Definition: IMX_Layer.h:420
const UT_Vector2D & imageToPixelTranslate() const
Definition: IMX_Layer.h:153
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
const UT_Vector2D & pixelScale() const
Definition: IMX_Layer.h:161
void setPixelAspectRatio(fpreal64 pa)
Set pixel aspect ratio. This must be done before setDataWindow.
Definition: IMX_Layer.h:283
UT_Vector2D imageToTexture(const UT_Vector2D &v) const
Definition: IMX_Layer.h:198
const GLdouble * v
Definition: glcorearb.h:837
UT_Vector2D textureToPixel(const UT_Vector2D &v) const
Definition: IMX_Layer.h:204
UT_Vector2D bufferToTexture(const UT_Vector2D &v) const
Definition: IMX_Layer.h:192
void setBufferToPixels()
Definition: IMX_Layer.h:387
UT_Vector3D imageToWorld(const UT_Vector2D &v) const
Definition: IMX_Layer.h:210
UT_Vector2T< fpreal64 > UT_Vector2D
fpreal64 focusDistance() const
Definition: IMX_Layer.h:111
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
fpreal64 fStop() const
Definition: IMX_Layer.h:108
UT_Vector2D textureToBuffer(const UT_Vector2D &v) const
Definition: IMX_Layer.h:194
IMX_Projection
Definition: IMX_Types.h:61
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector3.h:669
int64 exint
Definition: SYS_Types.h:125
void setApertureOffset(const UT_Vector2D &p)
Definition: IMX_Layer.h:344
const UT_DimRect & dataWindow() const
The dataWindow surrounds all the pixels.
Definition: IMX_Layer.h:76
UT_Vector3D localToImage3(const UT_Vector3D &v) const
Definition: IMX_Layer.h:229
int h() const
Get width/height dimensions.
Definition: UT_Rect.h:247
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
UT_Vector3D imagingScale() const
Definition: IMX_Layer.h:142
GLdouble s
Definition: glad.h:3009
const UT_Vector2D & bufferToPixelScale() const
Definition: IMX_Layer.h:155
const UT_Vector2D & clippingRange() const
Definition: IMX_Layer.h:110
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
void setIsMetadataOnly(bool v)
Definition: IMX_Layer.h:439
GLenum GLenum GLsizei void * image
Definition: glad.h:5132
GLint y
Definition: glcorearb.h:103
fpreal64 apertureMax() const
Definition: IMX_Layer.h:106
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:39
IMX_Layer()
Definition: IMX_Layer.h:36
void setLensDiameter(fpreal64 mm)
Definition: IMX_Layer.h:349
UT_Vector3D worldToLocal(const UT_Vector3D &v) const
Definition: IMX_Layer.h:239
IMX_Layer(const IMX_Layer &a, bool)
"copy constructor" that does not copy the buffer pixels
Definition: IMX_Layer.h:39
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
double fpreal64
Definition: SYS_Types.h:201
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector2.h:426
UT_Vector2D pixelToImage(const UT_Vector2D &v) const
Definition: IMX_Layer.h:175
void copyMetadata(const IMX_Layer &a)
Definition: IMX_Layer.h:273
UT_Vector2D pixelToBuffer(const UT_Vector2D &v) const
Pixel <-> Buffer.
Definition: IMX_Layer.h:179
GA_API const UT_StringHolder scale
GLint GLsizei GLsizei height
Definition: glcorearb.h:103
int t() const
Definition: IMX_Layer.h:84
GLdouble n
Definition: glcorearb.h:2008
GLfloat f
Definition: glcorearb.h:1926
const UT_Vector2D & displayWindowSize() const
Aperture in pixels.
Definition: IMX_Layer.h:94
void setFocalLength(fpreal64 mm)
Definition: IMX_Layer.h:347
UT_Vector2D imageToBufferTranslate() const
Definition: IMX_Layer.h:167
UT_Vector2D pixelToTexture(const UT_Vector2D &v) const
Definition: IMX_Layer.h:206
void setBufferSize(int width, int height)
Sets size of this buffer.
void setApertureCenter(const UT_Vector2D &p)
Definition: IMX_Layer.h:345
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
IMX_Projection statProjection() const
Returns the projection type.
void setDisplayWindow(const UT_Vector2D &xy, const UT_Vector2D &wh)
Definition: IMX_Layer.h:300
void setProperties(const UT_OptionsHolder &props)
Definition: IMX_Layer.h:410
UT_SharedPtr< const IMX_Layer > IMX_LayerConstPtr
Definition: IMX_Layer.h:28
bool isPerspective() const
Definition: IMX_Layer.h:105
fpreal64 apertureAspect() const
width / height of the aperture / displayWindow
Definition: IMX_Layer.h:99
void setDisplayWindow(const UT_DimRect &rect)
Definition: IMX_Layer.h:310
void setGuideScale(fpreal64 scale)
Definition: IMX_Layer.h:357
UT_Vector2D textureToBufferScale() const
Definition: IMX_Layer.h:159
void prescale(T sx, T sy, T sz, T sw=1)
Definition: UT_Matrix4.h:719
UT_Vector3D localToWorld(const UT_Vector3D &v) const
Definition: IMX_Layer.h:237
UT_Vector2D bufferPixelSize() const
Definition: IMX_Layer.h:169
void translatePixelOrigin(int dx, int dy)
Definition: IMX_Layer.h:319
void setAperture(fpreal64 mm)
Definition: IMX_Layer.h:343
void setBufferXforms(const UT_Vector2F &buffer_to_image_scale, const UT_Vector2F &buffer_to_image_xlate, const UT_Vector2F &buffer_from_image_scale, const UT_Vector2F &buffer_from_image_xlate, const UT_Vector2F &buffer_to_pixel_scale, const UT_Vector2F &buffer_to_pixel_xlate, const UT_Matrix4F &image_to_world, const UT_Matrix4F &world_to_image, const UT_Matrix4F &camera_to_world, const UT_Vector3F &camera_image_pos)
Set transform between image and buffer space.
int x() const
Get lower-left corner.
Definition: UT_Rect.h:226
void setApertureAspect(int n, int d)
Definition: IMX_Layer.h:331
UT_Vector3T< fpreal64 > UT_Vector3D
int r() const
Definition: IMX_Layer.h:83
exint bufferHeight() const
Get height (number of rows) of the buffer.
Definition: IMX_Buffer.h:187
UT_Vector2D imageToPixel(const UT_Vector2D &v) const
Image <-> Pixel.
Definition: IMX_Layer.h:173
int w() const
Get width/height dimensions.
Definition: UT_Rect.h:246
int height() const
Definition: IMX_Layer.h:81
const UT_Vector3D & cameraPosition() const
Definition: IMX_Layer.h:112
fpreal64 imagingDist() const
Definition: IMX_Layer.h:114
UT_Vector3D image3ToLocal(const UT_Vector3D &v) const
Definition: IMX_Layer.h:223
fpreal64 pixelAspectRatio() const
Distortion in image->pixel space transform.
Definition: IMX_Layer.h:88
GLint GLenum GLint x
Definition: glcorearb.h:409
fpreal64 lensDiameter() const
Definition: IMX_Layer.h:109
void setDataWindowOnly(int x, int y, int w, int h)
Set dataWindow w/o changing displayWindow.
Definition: IMX_Layer.h:294
void setDisplayWindow(int x, int y, int w, int h)
Definition: IMX_Layer.h:298
void setDataWindow(int x, int y, int w, int h)
Definition: IMX_Layer.h:287
bool isPixelScale() const
Definition: IMX_Layer.h:162
UT_Vector2D bufferToImage(const UT_Vector2D &v) const
Definition: IMX_Layer.h:187
UT_Matrix4D transform() const
Definition: IMX_Layer.h:129
int y() const
Definition: IMX_Layer.h:78
int width() const
Definition: IMX_Layer.h:80
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
A map of string to various well defined value types.
Definition: UT_Options.h:87
const UT_Vector2D & shutter() const
Definition: IMX_Layer.h:116
bool isOrtho() const
Definition: IMX_Layer.h:104
IMX_Layer(const PXL_Raster &rp)
Construct a layer from a PXL_Raster.
Definition: IMX_Layer.h:49
StorageType
Definition: CE_Image.h:27
const UT_Vector2D & imageToPixelScale() const
Coordinate transforms.
Definition: IMX_Layer.h:152
fpreal64 fpreal
Definition: SYS_Types.h:283
void transform(const UT_Matrix4D &m)
Definition: IMX_Layer.h:361
UT_OptionsHolder properties() const
Definition: IMX_Layer.h:412
void setProjection(IMX_Projection p)
Definition: IMX_Layer.h:335
void setDataWindow(int w, int h)
Set both dataWindow and displayWindow to the same rectangle.
Definition: IMX_Layer.h:286
UT_Vector2D worldToImage(const UT_Vector3D &v) const
Definition: IMX_Layer.h:212
fpreal64 guideScale() const
Definition: IMX_Layer.h:115
exint bufferWidth() const
Get width (number of columns in a row) of the buffer.
Definition: IMX_Buffer.h:185
UT_Matrix4D baseTransform() const
Transform from image space to world space.
Definition: IMX_Layer.h:128
void setFocusDistance(fpreal64 f)
Definition: IMX_Layer.h:351
void preTransform(const UT_Matrix4D &m)
Definition: IMX_Layer.h:362
GU_API void xform(CE_Context &context, bool recompile, int npts, const cl::Buffer &outPos, const cl::Buffer &inPos, const cl::Buffer &surfacexform, const cl::Buffer *grp=nullptr)
int y() const
Get lower-left corner.
Definition: UT_Rect.h:227
void setClippingRange(const UT_Vector2D &v)
Definition: IMX_Layer.h:350
GLint GLsizei width
Definition: glcorearb.h:103
void setFStop(fpreal64 f)
Definition: IMX_Layer.h:348
#define IMX_API
Definition: IMX_API.h:8
UT_Vector3D imageToLocal(const UT_Vector2D &v) const
Definition: IMX_Layer.h:219
void setOrtho()
Definition: IMX_Layer.h:338
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:165
void assign(T xx=0.0f, T yy=0.0f)
Set the values of the vector components.
Definition: UT_Vector2.h:449
IMX_Layer(int width, int height, CE_Image::StorageType storage, int channels)
Initialize the IMX_Buffer.
Definition: IMX_Layer.h:42
IMX_Projection projection() const
Camera.
Definition: IMX_Layer.h:103
UT_Vector2D imageToBufferScale() const
Definition: IMX_Layer.h:165
UT_Vector2I xy() const
Definition: IMX_Layer.h:79
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector3.h:667
UT_Vector2D localToImage(const UT_Vector3D &v) const
Definition: IMX_Layer.h:221
UT_Vector2I wh() const
Definition: IMX_Layer.h:82
void setBaseTransform(const UT_Matrix4D &m)
set the imageToWorld transform. This can be done at any time
Definition: IMX_Layer.h:360
fpreal64 cameraZ() const
Definition: IMX_Layer.h:113
void setStatProjection(IMX_Projection projection)
void setShutter(const UT_Vector2D &v)
Definition: IMX_Layer.h:352
UT_SharedPtr< IMX_Layer > IMX_LayerPtr
Definition: IMX_Layer.h:27
void setDisplayWindow(int w, int h)
Set the displayWindow w/o changing dataWindow.
Definition: IMX_Layer.h:297
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector2.h:428
UT_Vector2D bufferToLocalScale() const
Definition: IMX_Layer.h:158
UT_Matrix4D imageToWorldXform() const
Definition: IMX_Layer.h:130
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
UT_Vector2D bufferToTextureScale() const
Definition: IMX_Layer.h:156
const UT_Vector2D & bufferToPixelTranslate() const
Definition: IMX_Layer.h:163
void setCameraZ(fpreal64 z)
Definition: IMX_Layer.h:341
GLenum GLuint GLsizei const GLenum * props
Definition: glcorearb.h:2525
GLenum src
Definition: glcorearb.h:1793
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector3.h:665
UT_Vector2D displayWindowRT() const
Definition: IMX_Layer.h:96
UT_Vector2D displayWindowXY() const
Definition: IMX_Layer.h:95