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
00178 const unsigned char* getValue( SbVec3s& size, int& nc ) const;
00179
00187 SoBufferObject* getBufferObject( SbVec3i32& size, int& nc, SoSFImage::DataType& dataType ) const;
00188
00196 SoBufferObject* getBufferObject( SbVec3s& size, int& nc ) const;
00197
00202 void setValue( const SbVec3i32& size, int nc,
00203 SoSFImage::DataType dataType,
00204 const void* data,
00205 CopyPolicy copy = COPY );
00206
00218 void setValue( const SbVec3i32& size, int nc,
00219 SoSFImage::DataType dataType,
00220 SoBufferObject* bufferObject,
00221 CopyPolicy copy = COPY );
00222
00227 void setValue( const SbVec3s &size,
00228 int nc,
00229 unsigned char *bytes,
00230 CopyPolicy copy = COPY );
00231
00235 void setValue( const SbVec3s &size,
00236 int nc,
00237 SoBufferObject* bufferObject,
00238 CopyPolicy copy = COPY );
00239
00249 void setSubValue( const SbVec3i32& subSize,
00250 const SbVec3i32& offset,
00251 void* bytes,
00252 CopyPolicy copy = COPY );
00253
00264 void setSubValue( const SbVec3s& subSize,
00265 const SbVec3s& offset,
00266 unsigned char* bytes,
00267 CopyPolicy copy = COPY );
00268
00278 void setSubValues( const SbVec3i32* subSizes,
00279 const SbVec3i32* offsets,
00280 int num,
00281 void** data,
00282 CopyPolicy copy = COPY );
00283
00294 void setSubValues( const SbVec3s* subSizes,
00295 const SbVec3s* offsets,
00296 int num,
00297 unsigned char** bytes,
00298 CopyPolicy copy = COPY );
00299
00303 int operator==(const SoSFImage3 &f) const;
00307 int operator!=(const SoSFImage3 &f) const
00308 { return ! ((*this) == f); }
00309
00325 void* startEditing( SbVec3i32& size, int& nc, SoSFImage::DataType& dataType );
00326
00343 unsigned char* startEditing( SbVec3s& size, int& nc );
00344
00359 void finishEditing();
00360
00370 void* getSubTexture( int index, SbVec3i32& size, SbVec3i32& offset, SoSFImage::DataType& dataType );
00371
00383 unsigned char* getSubTexture( int index, SbVec3s& size, SbVec3s& offset );
00384
00391 SbBool hasSubTextures(int &numSubTextures);
00392
00399 void setNeverWrite(SbBool neverWrite);
00406 SbBool isNeverWrite()
00407 { return m_neverWrite; }
00408
00409
00410 SoBufferObject* getBufferObject() const;
00411
00413 int getNumComponents() const;
00414
00415 private:
00416
00417 static void initClass();
00418 static void exitClass();
00419 void resetSubTextures();
00420
00421 void deleteBytesArray();
00422
00423 private:
00424
00425
00426 SbVec3i32 m_size;
00427
00428
00429 int m_numComponents;
00430
00434 unsigned char* m_buffer;
00435
00436
00437 SoRef<SoBufferObject> m_bufferObject;
00438
00442 SoRef<SoCpuBufferObject> m_cpuBufferObject;
00443
00444 CopyPolicy m_copyPolicy;
00445
00446
00447 SbPList m_subTextures;
00448
00449 SbBool m_neverWrite;
00450
00451 SoSFImage::DataType m_dataType;
00452
00453 size_t getImageValueSize() const;
00454
00455
00456 virtual SbBool readValue(SoInput *in);
00457 virtual void writeValue(SoOutput *out) const;
00458 };
00459
00460 inline SoBufferObject*
00461 SoSFImage3::getBufferObject() const
00462 {
00463 return m_bufferObject.ptr();
00464 }
00465
00466 inline int
00467 SoSFImage3::getNumComponents() const
00468 {
00469 return m_numComponents;
00470 }
00471
00472 #endif
00473
00474