RixDeepTexture.h Source File

RixDeepTexture.h
1 #ifndef RixDeepTexture_H
2 #define RixDeepTexture_H
3 /* $Revision: #1 $ $Date: 2015/04/23 $
4 # ------------------------------------------------------------------------------
5 #
6 # Copyright (c) 2010 Pixar Animation Studios. All rights reserved.
7 #
8 # The information in this file (the "Software") is provided for the
9 # exclusive use of the software licensees of Pixar. Licensees have
10 # the right to incorporate the Software into other products for use
11 # by other authorized software licensees of Pixar, without fee.
12 # Except as expressly permitted herein, the Software may not be
13 # disclosed to third parties, copied or duplicated in any form, in
14 # whole or in part, without the prior written permission of
15 # Pixar Animation Studios.
16 #
17 # The copyright notices in the Software and this entire statement,
18 # including the above license grant, this restriction and the
19 # following disclaimer, must be included in all copies of the
20 # Software, in whole or in part, and all permitted derivative works of
21 # the Software, unless such copies or derivative works are solely
22 # in the form of machine-executable object code generated by a
23 # source language processor.
24 #
25 # PIXAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
26 # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
27 # SHALL PIXAR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
28 # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
29 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
30 # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
31 # SOFTWARE.
32 #
33 # Pixar
34 # 1200 Park Ave
35 # Emeryville CA 94608
36 #
37 # ------------------------------------------------------------------------------
38 */
39 #include "RixInterfaces.h"
40 
58 {
59 protected:
62 
63 public:
64  enum Compression
65  {
66  k_CmpNone = 0,
67  k_CmpRLE = 2,
68  k_CmpLZW = 3,
69  k_CmpHUFFMAN = 5,
70  k_CmpZIP = 6
71  };
72 
73  enum DataType
74  {
75  k_TypeBYTE = 1,
76  k_TypeSHORT = 2,
77  k_TypeWORD = 3,
78  k_TypeFLOAT = 4,
79  k_TypeHALF = 5
80  };
81 
83  {
86  k_ErrREADONLY = -12,
88  k_ErrCAPACITY = -11,
90  k_ErrTILECOMPRESSION = -10,
93  k_ErrRANGE = -8,
95  k_ErrNOMEM = -7,
96  k_ErrEMPTY = -6,
97  k_ErrNOIMAGE = -5,
100  k_ErrBADFILE = -3,
102  k_ErrNOFILE = -2,
103  k_ErrERR = -1,
105  };
106 
107  // forward declaration of our types...
108  class DeepCache;
109  class DeepFile;
110  class DeepImage;
111  class DeepMetadata;
112  class DeepPixel;
113 
116  virtual DeepCache *CreateCache(int numTiles)=0;
117 
120  virtual int DestroyCache(DeepCache *)=0;
121 
124  virtual int CreateFile(const char *name, DeepCache *, DeepFile **result)=0;
125 
129  virtual int IsDeepFile(const char *name, DeepCache *, int *version)=0;
130 
133  virtual int OpenFile(const char *name, const char *mode, DeepCache *,
134  DeepFile **result)=0;
135 
137  virtual int DestroyFile(DeepFile *)=0;
138 
140  virtual DeepPixel *CreatePixel(int numChan)=0;
141 
143  virtual void DestroyPixel(DeepPixel *)=0;
144 
145  class DeepCache
146  {
147  public:
148  virtual int Sync()=0;
149 
150  protected:
152  virtual ~DeepCache() {}
153  };
154 
161  class DeepFile
162  {
163  protected:
165  virtual ~DeepFile() {}
166 
167  public:
168 
170  virtual int FileVersion()=0;
171 
174  virtual DeepMetadata *GetMetadata()=0;
175 
177  virtual int CountImages()=0;
178 
180  virtual int AddImage(const char *nm, int numChan,
181  int w, int h,
182  int tw, int th,
183  float *NP,
184  float *Nl,
185  Compression,
186  DataType,
187  DeepImage **result)=0;
188 
191  virtual int AddImage(const char *nm, int numChan,
192  int w, int h,
193  int tw, int th,
194  float *NP,
195  float *Nl,
196  Compression,
197  DataType,
198  const char *formatType,
199  int formatVersion,
200  DeepImage **result)=0;
201 
202 
207  virtual int GetImageByName(const char *, DeepImage **result)=0;
208 
213  virtual int GetImageByIndex(int, DeepImage **result)=0;
214 
216  virtual int Close()=0;
217 
220  virtual int Sync()=0;
221  };
222 
229  class DeepImage
230  {
231  protected:
233  virtual ~DeepImage() {}
234 
235  public:
239  virtual const char *GetName()=0;
241  virtual int GetNumChan()=0;
243  virtual int GetWidth()=0;
245  virtual int GetHeight()=0;
247  virtual int GetTileWidth()=0;
249  virtual int GetTileHeight()=0;
251  virtual int GetNP(float *NP)=0;
253  virtual int GetNl(float *Nl)=0;
255  virtual Compression GetCompression()=0;
257  virtual DataType GetDataType()=0;
260  virtual DeepMetadata *GetMetadata()=0;
261 
262 
266  virtual int SetPixelData(int x, int y, int numPoints,
267  float *data)=0;
268 
274  virtual int SetPixel(int x, int y, DeepPixel *pix)=0;
275 
283  virtual int GetPixel(int x, int y, DeepPixel *pix)=0;
284 
288  virtual int Eval(int x, int y, float z, float *data)=0;
289 
294  virtual int GetZRange(int x, int y, float *min, float *max)=0;
295 
298  virtual int GetMeanDepth(int x, int y, float *mean, float *alpha)=0;
299  };
300 
317  {
318  protected:
320  virtual ~DeepMetadata() {}
321 
322  public:
323 
326  virtual int Set(char const *token, void const *value)=0;
327 
329  virtual int Count()=0;
330 
337  virtual int GetByIndex(int index,
338  char const **token, void const **value)=0;
339 
341  virtual int GetByName(char const *name,
342  char const **token, void const **value)=0;
343  };
344 
362  class DeepPixel
363  {
364  protected:
366  virtual ~DeepPixel() {}
367 
368  public:
369  virtual int Clear(int numChan)=0;
370  virtual int Empty()=0;
371 
373  virtual int SpecifyPixel(int numChan, int numPoints, float *data)=0;
374 
377  virtual int IsMonochrome()=0;
378 
380  virtual int GetNumChan()=0;
381 
385  virtual int GetNumPoints()=0;
386 
393  virtual int GetPoint(int i, float *z, float *data)=0;
394 
400  virtual int SetPoint(int i, float z, float *data)=0;
401 
404  virtual int Copy(DeepPixel *src)=0;
405 
411  virtual int Merge(DeepPixel *src) = 0;
412 
426  virtual int Merge(DeepPixel *src,
427  int rgbChannel, int alphaChannel) = 0;
428 
429 
435  virtual int Finish()=0;
436 
441  virtual int Append(float z, float *data, float tolerance)=0;
442 
446  virtual int Eval(float z, float *data)=0;
447 
458  virtual int Composite(int rgbChannel, int alphaChannel, float *data)=0;
459 
466  virtual int GetZRange(float *zmin, float *zmax)=0;
467 
470  virtual int Average(int n, DeepPixel *pixels[], float weights[],
471  float tolerance)=0;
472 
475  virtual int Compress(DeepPixel *src, float tolerance)=0;
476 
477  }; /* end of DeepPixel */
478 
479 }; /* end of RixDeepTexture */
480 
481 #endif