00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_SF_IMAGE_3_
00025 #define _SO_SF_IMAGE_3_
00026
00027 #include <Inventor/fields/SoSubField.h>
00028 #include <Inventor/SbLinear.h>
00029 #include <Inventor/SbPList.h>
00030 #include <Inventor/devices/SoBufferObject.h>
00031
00032 class SoCpuBufferObject;
00033
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00060
00120 class SoSFImage3 : public SoSField {
00121
00122
00123
00124 SO_SFIELD_REQUIRED_HEADER(SoSFImage3);
00125 SO_SFIELD_CONSTRUCTOR_HEADER(SoSFImage3);
00126
00127 public:
00128
00138 enum CopyPolicy {
00142 COPY = 0,
00146 NO_COPY = 1,
00151 NO_COPY_AND_DELETE = 2,
00156 NO_COPY_AND_FREE = 3
00157 };
00158
00169 const unsigned char *getValue(SbVec3s &size, int &nc) const;
00170
00178 SoBufferObject *getBufferObject(SbVec3s &size, int &nc) const;
00179
00193 void setValue(const SbVec3s &size,
00194 int nc,
00195 unsigned char *bytes,
00196 CopyPolicy copy = COPY);
00197
00198
00199 void setValue(const SbVec3s &size,
00200 int nc,
00201 SoBufferObject* bufferObject,
00202 CopyPolicy copy = COPY);
00203
00212 void setSubValue(const SbVec3s &subSize,
00213 const SbVec3s &offset,
00214 unsigned char *bytes,
00215 CopyPolicy copy = COPY);
00225 void setSubValues(const SbVec3s *subSizes,
00226 const SbVec3s *offsets,
00227 int num,
00228 unsigned char **bytes,
00229 CopyPolicy copy = COPY);
00230
00234 int operator==(const SoSFImage3 &f) const;
00238 int operator!=(const SoSFImage3 &f) const
00239 { return ! ((*this) == f); }
00240
00253 unsigned char *startEditing(SbVec3s &size, int &nc);
00254
00266 void finishEditing();
00267
00277 unsigned char *getSubTexture(int index, SbVec3s &size, SbVec3s &offset);
00278
00285 SbBool hasSubTextures(int &numSubTextures);
00286
00293 void setNeverWrite(SbBool neverWrite);
00300 SbBool isNeverWrite()
00301 { return m_neverWrite; }
00302
00303
00304 SoBufferObject* getBufferObject() const;
00305
00306 private:
00307
00308 static void initClass();
00309 static void exitClass();
00310 void resetSubTextures();
00311
00312 void deleteBytesArray();
00313
00314 int getNumComponents() const;
00315
00316 private:
00317
00318
00319 SbVec3s m_size;
00320
00321
00322 int m_numComponents;
00323
00327 unsigned char* m_buffer;
00328
00329
00330 SoRef<SoBufferObject> m_bufferObject;
00331
00335 SoRef<SoCpuBufferObject> m_cpuBufferObject;
00336
00337 CopyPolicy m_copyPolicy;
00338
00339
00340 SbPList m_subTextures;
00341
00342 SbBool m_neverWrite;
00343
00344
00345 virtual SbBool readValue(SoInput *in);
00346 virtual void writeValue(SoOutput *out) const;
00347 };
00348
00349 inline SoBufferObject*
00350 SoSFImage3::getBufferObject() const
00351 {
00352 return m_bufferObject.ptr();
00353 }
00354
00355 inline int
00356 SoSFImage3::getNumComponents() const
00357 {
00358 return m_numComponents;
00359 }
00360
00361 #endif
00362
00363