00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TIL_TILE_H
00020 #define TIL_TILE_H
00021
00022 #include "TIL_API.h"
00023 #include <SYS/SYS_Types.h>
00024
00025 #include <iostream.h>
00026 #include <sys/types.h>
00027 #include <UT/UT_Endian.h>
00028 #include <UT/UT_LinkList.h>
00029 #include <UT/UT_String.h>
00030 #include <UT/UT_RefArray.h>
00031
00032 #include "TIL_HoldingQueue.h"
00033 #include "TIL_Defines.h"
00034 #include "TIL_TileList.h"
00035
00036 class UT_TokenString;
00037 class TIL_TileCache;
00038 class TIL_Plane;
00039 class til_AlignedBlock;
00040
00041 class TIL_API TIL_Tile : public TIL_HoldingNode
00042 {
00043 public:
00044
00045
00046
00047
00048 void reset();
00049
00050
00051 void clear(float value = 0.0F, int scanstep=1,
00052 int scanoff =0);
00053
00054 void lineDouble(bool odd);
00055
00056 int matches(const UT_TokenString *image_id,
00057 int tilex, int tiley) const;
00058
00059 int compare(const UT_TokenString *image_id,
00060 int tilex, int tiley) const;
00061
00062
00063
00064
00065
00066 void setVectorName(const char *name, int vector =0);
00067 const char * getVectorName() const {return myVectorName;}
00068 void setCompName(const char *name);
00069 const char * getCompName() const { return myCompName; }
00070 int getVectorIndex() const {return myVectorIndex;}
00071
00072
00073 void setFormat(TIL_DataFormat f);
00074 TIL_DataFormat getFormat() const { return myFormat; }
00075
00076
00077 void setStorage(TIL_Storage storage) { myStorage = storage;}
00078 TIL_Storage getStorage() const { return myStorage; }
00079
00080
00081 void setImageNum(int n) { myImageNum = n; }
00082 int getImageNum() const { return myImageNum; }
00083
00084
00085 void setBlackWhitePoints(int black,int white);
00086 int usesBlackWhitePoints() const;
00087 void getBlackWhitePoints(unsigned int &black,
00088 unsigned int &white) const
00089 { black = myBlackLevel; white = myWhiteLevel; }
00090
00091
00092 void setOffset(int x,int y) { myXOffset=x; myYOffset=y; }
00093 void getOffset(int &x, int &y) const
00094 { x=myXOffset; y=myYOffset; }
00095
00096
00097 void setSize(int x, int y);
00098 void getSize(int &x, int &y) const
00099 { x = myXSize; y = myYSize; }
00100
00101 int getNumPixels() const;
00102
00103
00104 void setParent(void *parent) { myParent = parent; }
00105 void * getParent() const { return myParent; }
00106
00107
00108
00109 void setNodePath(const char *path);
00110 const char * getNodePath() const { return myNodePath;}
00111
00112
00113 void setImageIdentifier(UT_TokenString *token)
00114 { myImageIdentifier = token; }
00115 const UT_TokenString *getImageIdentifier() const
00116 { return myImageIdentifier; }
00117
00118
00119 void setCooked(bool done = true) { myCookedFlag =done; }
00120 bool isCooked() const { return myCookedFlag;}
00121
00122 bool isCheckpoint() const { return myCheckpointCount != 0; }
00123 int getCheckpointCount() const { return myCheckpointCount; }
00124 void incrementCheckpointCount();
00125 void decrementCheckpointCount();
00126
00127 bool determineIfConstant();
00128 bool isConstantTile() const { return myConstantTileFlag; }
00129 float getConstantColor() const;
00130
00131
00132
00133 void setConstantTile(bool constant);
00134
00135
00136
00137 int lock(int access, int block = 1);
00138
00139 void lockWriteToRead(int score);
00140 void unlock(int access);
00141
00142
00143 void setProxyHold(bool on) { myProxyHoldFlag = on; }
00144
00145
00146 int getMemSize() const { return myMemSize; }
00147
00148
00149 unsigned int getTotalSize() const;
00150
00151
00152
00153 void setImageData(til_AlignedBlock * data)
00154 { myImageData = data; }
00155
00156 void getImageData(const unsigned char *&data) const;
00157 void getImageData(const unsigned short *&data) const;
00158 void getImageData(const unsigned int *&data) const;
00159 void getImageData(const float *&data) const;
00160 void getImageData(const fpreal16 *&data) const;
00161 const void * getImageData() const { return (void *) *myImageData; }
00162
00163 void getImageData(unsigned char *&data);
00164 void getImageData(unsigned short *&data);
00165 void getImageData(unsigned int *&data);
00166 void getImageData(float *&data);
00167 void getImageData(fpreal16 *&data);
00168 void * getImageData() { return (void *) *myImageData; }
00169
00170 til_AlignedBlock *getImageBlock() { return myImageData; }
00171
00172
00173
00174
00175 void setPriority(unsigned int p) { myPriority = p; }
00176 int getPriority() const { return myPriority; }
00177
00178
00179 int isCacheLocked() const;
00180 bool isReadLocked() const;
00181 bool isWriteLocked() const;
00182
00183 bool isBorrowedImage() const { return myBorrowedImageFlag; }
00184 void setBorrowedImage(bool b) { myBorrowedImageFlag = b;
00185 myMemSize = 0; }
00186
00187
00188
00189
00190
00191 static void setNewTileSize(int xsize, int ysize);
00192
00193
00194 static int getTileSizeX();
00195 static int getTileSizeY();
00196 static int getTile8Mem();
00197 static int getTile16Mem();
00198 static int getTile32Mem();
00199
00200 static void setTileCachePtr(TIL_TileCache *tc);
00201
00202
00203 void print(ostream &os) const;
00204 static void setCopPrintCallback(void(*callback)(void *,ostream &));
00205
00206 private:
00207
00208 TIL_Tile();
00209 ~TIL_Tile();
00210
00211
00212
00213 const char *myVectorName;
00214 const char *myCompName;
00215 int myVectorIndex;
00216 int myImageNum;
00217
00218
00219 TIL_DataFormat myFormat;
00220 unsigned int myBlackLevel;
00221 unsigned int myWhiteLevel;
00222 int myXSize;
00223 int myYSize;
00224 int myXOffset;
00225 int myYOffset;
00226 int myMemSize;
00227 TIL_Storage myStorage;
00228 char *myNodePath;
00229
00230
00231 unsigned int myPriority;
00232 void * myParent;
00233 UT_TokenString * myImageIdentifier;
00234 int myCheckpointCount;
00235
00236
00237 unsigned int myCompNameAlloc : 1,
00238 myConstantTileFlag : 1,
00239 myBorrowedImageFlag : 1,
00240 myCookedFlag : 1,
00241 myProxyHoldFlag : 1,
00242 myVectorNameAlloc : 1;
00243
00244
00245 union {
00246 unsigned char myConstantVal8;
00247 unsigned short myConstantVal16;
00248 unsigned int myConstantVal32;
00249 float myConstantValFP;
00250 };
00251 fpreal16 myConstantValFP16;
00252
00253
00254 TIL_FastLock myMainLock;
00255 int myReadLocks;
00256 int myWriteLock;
00257
00258
00259 til_AlignedBlock *myImageData;
00260
00261 friend class TIL_TileCache;
00262 };
00263
00264
00265 #endif // TIL_TILE_H