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 #include <Inventor/fields/SoSFImage.h>
00032
00033 class SoCpuBufferObject;
00034
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00061
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
00167 const void* getValue( SbVec3i32& size, int& nc, SoSFImage::DataType& dataType ) const;
00168
00180 const unsigned char* getValue( SbVec3s& size, int& nc ) const;
00181
00189 SoBufferObject* getBufferObject( SbVec3i32& size, int& nc, SoSFImage::DataType& dataType ) const;
00190
00198 SoBufferObject* getBufferObject( SbVec3s& size, int& nc ) const;
00199
00204 void setValue( const SbVec3i32& size, int nc,
00205 SoSFImage::DataType dataType,
00206 const void* data,
00207 CopyPolicy copy = COPY );
00208
00220 void setValue( const SbVec3i32& size, int nc,
00221 SoSFImage::DataType dataType,
00222 SoBufferObject* bufferObject,
00223 CopyPolicy copy = COPY );
00224
00229 void setValue( const SbVec3s &size,
00230 int nc,
00231 unsigned char *bytes,
00232 CopyPolicy copy = COPY );
00233
00237 void setValue( const SbVec3s &size,
00238 int nc,
00239 SoBufferObject* bufferObject,
00240 CopyPolicy copy = COPY );
00241
00251 void setSubValue( const SbVec3i32& subSize,
00252 const SbVec3i32& offset,
00253 void* bytes,
00254 CopyPolicy copy = COPY );
00255
00266 void setSubValue( const SbVec3s& subSize,
00267 const SbVec3s& offset,
00268 unsigned char* bytes,
00269 CopyPolicy copy = COPY );
00270
00280 void setSubValues( const SbVec3i32* subSizes,
00281 const SbVec3i32* offsets,
00282 int num,
00283 void** data,
00284 CopyPolicy copy = COPY );
00285
00296 void setSubValues( const SbVec3s* subSizes,
00297 const SbVec3s* offsets,
00298 int num,
00299 unsigned char** bytes,
00300 CopyPolicy copy = COPY );
00301
00305 int operator==(const SoSFImage3 &f) const;
00309 int operator!=(const SoSFImage3 &f) const
00310 { return ! ((*this) == f); }
00311
00327 void* startEditing( SbVec3i32& size, int& nc, SoSFImage::DataType& dataType );
00328
00345 unsigned char* startEditing( SbVec3s& size, int& nc );
00346
00361 void finishEditing();
00362
00372 void* getSubTexture( int index, SbVec3i32& size, SbVec3i32& offset, SoSFImage::DataType& dataType );
00373
00385 unsigned char* getSubTexture( int index, SbVec3s& size, SbVec3s& offset );
00386
00393 SbBool hasSubTextures(int &numSubTextures);
00394
00401 void setNeverWrite(SbBool neverWrite);
00408 SbBool isNeverWrite()
00409 { return m_neverWrite; }
00410
00411
00412 SoBufferObject* getBufferObject() const;
00413
00415 int getNumComponents() const;
00416
00417 private:
00418
00419 static void initClass();
00420 static void exitClass();
00421 void resetSubTextures();
00422
00423 void deleteBytesArray();
00424
00425 private:
00426
00427
00428 SbVec3i32 m_size;
00429
00430
00431 int m_numComponents;
00432
00436 unsigned char* m_buffer;
00437
00438
00439 SoRef<SoBufferObject> m_bufferObject;
00440
00444 SoRef<SoCpuBufferObject> m_cpuBufferObject;
00445
00446 CopyPolicy m_copyPolicy;
00447
00448
00449 SbPList m_subTextures;
00450
00451 SbBool m_neverWrite;
00452
00453 SoSFImage::DataType m_dataType;
00454
00455 size_t getImageValueSize() const;
00456
00457
00458 virtual SbBool readValue(SoInput *in);
00459 virtual void writeValue(SoOutput *out) const;
00460 };
00461
00462 inline SoBufferObject*
00463 SoSFImage3::getBufferObject() const
00464 {
00465 return m_bufferObject.ptr();
00466 }
00467
00468 inline int
00469 SoSFImage3::getNumComponents() const
00470 {
00471 return m_numComponents;
00472 }
00473
00474 #endif
00475
00476