RixDeepTexture.h

00001 #ifndef RixDeepTexture_H
00002 #define RixDeepTexture_H
00003 /*
00004 # ------------------------------------------------------------------------------
00005 #
00006 # Copyright (c) 2010 Pixar Animation Studios. All rights reserved.
00007 #
00008 # The information in this file is provided for the exclusive use of the
00009 # software licensees of Pixar.  It is UNPUBLISHED PROPRIETARY SOURCE CODE
00010 # of Pixar Animation Studios; the contents of this file may not be disclosed
00011 # to third parties, copied or duplicated in any form, in whole or in part,
00012 # without the prior written permission of Pixar Animation Studios.
00013 # Use of copyright notice is precautionary and does not imply publication.
00014 #
00015 # PIXAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
00016 # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
00017 # SHALL PIXAR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
00018 # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00019 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
00020 # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00021 # SOFTWARE.
00022 #
00023 # Pixar
00024 # 1200 Park Ave
00025 # Emeryville CA 94608
00026 #
00027 # ------------------------------------------------------------------------------
00028 */
00029 #include "RixInterfaces.h"
00030 
00031 /* $Revision: #6 $ */
00032 
00033 /*
00034  * RixDeepTexture
00035  *
00036  * This interface provides the classes and methods necessary to create,
00037  * load, and modify Pixar deep texture files.  It maintains a tile cache
00038  * under the covers, making it possible to work on files without loading
00039  * them entirely into memory.
00040  *
00041  * The API supports an arbitrary number of images in a single file, each
00042  * with its own resolution, tile size, and view matrices.
00043  *
00044  * The library can read and write old deep shadow files in addition to
00045  * newer, more general deep texture files.  Deep shadow files are
00046  * limited to a single sub-image, but otherwise have the same API as the
00047  * newer interface.
00048  */
00049 
00050 class RixDeepTexture : public RixInterface
00051 {
00052 protected:
00053     RixDeepTexture() : RixInterface(1) {}
00054 
00055 public:
00056     enum Compression
00057     {
00058         k_CmpNone = 0,
00059         k_CmpRLE = 2,
00060         k_CmpLZW = 3,
00061         k_CmpHUFFMAN = 5,
00062         k_CmpZIP = 6
00063     };
00064     
00065     enum DataType
00066     {
00067         k_TypeBYTE = 1,
00068         k_TypeSHORT = 2,
00069         k_TypeWORD = 3,
00070         k_TypeFLOAT = 4
00071     };
00072     
00073     enum ErrorCodes
00074     {
00075         k_ErrBADCHANNEL = -13, 
00076         k_ErrREADONLY = -12, 
00077         k_ErrCAPACITY = -11, 
00078         k_ErrTILECOMPRESSION  = -10,  
00079         k_ErrUNFINISHED = -9, 
00080 
00081         k_ErrRANGE = -8,  
00082         k_ErrNOMEM = -7,  
00083         k_ErrEMPTY = -6,  
00084         k_ErrNOIMAGE = -5,
00085         k_ErrUNSUPPORTED = -4, 
00086         k_ErrBADFILE = -3,
00087         k_ErrNOFILE = -2, 
00088         k_ErrERR = -1,    
00089         k_ErrNOERR = 0    
00090     };
00091     
00093     class DeepCache;
00094     class DeepFile;
00095     class DeepImage;
00096     class DeepPixel;
00097     
00100     virtual DeepCache *CreateCache(int numTiles)=0L;
00101 
00104     virtual int DestroyCache(DeepCache *)=0L;
00105     
00108     virtual int CreateFile(const char *name, DeepCache *, DeepFile **result)=0;
00109 
00112     virtual int OpenFile(const char *name, const char *mode, DeepCache *, 
00113                         DeepFile **result)=0;
00114 
00116     virtual int DestroyFile(DeepFile *)=0;
00117 
00119     virtual DeepPixel *CreatePixel(int numChan)=0;
00120 
00122     virtual void DestroyPixel(DeepPixel *)=0;
00123 
00124     class DeepCache
00125     {
00126     public:
00127         virtual int Sync()=0;
00128 
00129     protected:
00130         virtual ~DeepCache() {} // use RixDeepTexture::DestroyCache
00131     };
00132 
00133     class DeepFile
00134     {
00135     protected:
00136         virtual ~DeepFile() {} // use RixDeepTexture::DestroyFile
00137 
00138     public:
00140         virtual int CountImages()=0;
00141         
00143         virtual int AddImage(const char *nm, int numChan,
00144                      int w, int h, 
00145                      int tw, int th,
00146                      float *NP,
00147                      float *Nl,
00148                      Compression,
00149                      DataType,
00150                      DeepImage **result)=0;
00151 
00156         virtual int GetImageByName(const char *, DeepImage **result)=0;
00157                      
00162         virtual int GetImageByIndex(int, DeepImage **result)=0;
00163         
00165         virtual int Close()=0;
00166         
00169         virtual int Sync()=0;
00170         
00171     };
00172 
00173     class DeepImage
00174     {
00175     protected:
00176         virtual ~DeepImage() {}
00177 
00178     public:
00182         virtual const char *GetName()=0;
00184         virtual int GetNumChan()=0;
00186         virtual int GetWidth()=0;
00188         virtual int GetHeight()=0;
00190         virtual int GetTileWidth()=0;
00192         virtual int GetTileHeight()=0;
00194         virtual int GetNP(float *NP)=0;
00196         virtual int GetNl(float *Nl)=0;
00198         virtual Compression GetCompression()=0;
00200         virtual DataType GetDataType()=0;
00201 
00205         virtual int SetPixelData(int x, int y, int numPoints, 
00206                                  float *data)=0;
00207 
00213         virtual int SetPixel(int x, int y, DeepPixel *pix)=0; 
00214 
00222         virtual int GetPixel(int x, int y, DeepPixel *pix)=0;
00223 
00227         virtual int Eval(int x, int y, float z, float *data)=0;
00228 
00233         virtual int GetZRange(int x, int y, float *min, float *max)=0;
00234 
00237         virtual int GetMeanDepth(int x, int y, float *mean, float *alpha)=0;
00238     };
00239     
00257     class DeepPixel
00258     {
00259     protected:
00260         virtual ~DeepPixel() {} 
00261 
00262     public:
00263         virtual int Clear(int numChan)=0;
00264         virtual int Empty()=0;
00265 
00267         virtual int SpecifyPixel(int numChan, int numPoints, float *data)=0;
00268 
00271         virtual int IsMonochrome()=0;
00272 
00274         virtual int GetNumChan()=0;
00275 
00279         virtual int GetNumPoints()=0;
00280 
00287         virtual int GetPoint(int i, float *z, float *data)=0;
00288 
00294         virtual int SetPoint(int i, float z, float *data)=0;
00295 
00298         virtual int Copy(DeepPixel *src)=0;
00299         
00305         virtual int Merge(DeepPixel *src) = 0;
00306 
00312         virtual int Finish()=0;
00313 
00318         virtual int Append(float z, float *data, float tolerance)=0;
00319 
00323         virtual int Eval(float z, float *data)=0;
00324 
00335         virtual int Composite(int rgbChannel, int alphaChannel, float *data)=0;
00336 
00343         virtual int GetZRange(float *zmin, float *zmax)=0;
00344 
00347         virtual int Average(int n, DeepPixel *pixels[], float weights[],
00348                             float tolerance)=0;
00349 
00352         virtual int Compress(DeepPixel *src, float tolerance)=0;
00353         
00354     }; /* end of DeepPixel */
00355     
00356 }; /* end of RixDeepTexture */
00357 
00358 #endif

Generated on Mon Nov 15 10:14:34 2010 for PRManHeaders by  doxygen 1.4.6