Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoSFImage3 Class Reference

VSG extension Field containing a 3D image. More...

#include <Inventor/fields/SoSFImage3.h>

+ Inheritance diagram for SoSFImage3:

Public Types

enum  CopyPolicy {
  COPY = 0 ,
  NO_COPY = 1 ,
  NO_COPY_AND_DELETE = 2 ,
  NO_COPY_AND_FREE = 3
}
 SoSFImage3 may be manipulating some large amounts of memory. More...
 

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
const SoSFImage3operator= (const SoSFImage3 &f)
 Copy from another field of same type.
 
 SoSFImage3 ()
 Default constructor.
 
virtual ~SoSFImage3 ()
 Destructor.
 
const void * getValue (SbVec3i32 &size, int &nc, SoSFImage::DataType &dataType) const
 Returns the pixels in the image as an array of values of type <dataType>.
 
const unsigned char * getValue (SbVec3s &size, int &nc) const
 Returns the pixels in the image as an array of unsigned chars.
 
SoBufferObjectgetBufferObject (SbVec3i32 &size, int &nc, SoSFImage::DataType &dataType) const
 Returns the pixels in the image as a buffer object.
 
SoBufferObjectgetBufferObject (SbVec3s &size, int &nc) const
 Returns the pixels in the image as a buffer object.
 
void setValue (const SbVec3i32 &size, int nc, SoSFImage::DataType dataType, const void *data, CopyPolicy copy=COPY)
 Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values.
 
void setValue (const SbVec3i32 &size, int nc, SoSFImage::DataType dataType, SoBufferObject *bufferObject, CopyPolicy copy=COPY)
 Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values.
 
void setValue (const SbVec3s &size, int nc, unsigned char *bytes, CopyPolicy copy=COPY)
 Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values.
 
void setValue (const SbVec3s &size, int nc, SoBufferObject *bufferObject, CopyPolicy copy=COPY)
 Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values.
 
void setSubValue (const SbVec3i32 &subSize, const SbVec3i32 &offset, void *bytes, CopyPolicy copy=COPY)
 These methods may be used for subtexturing: instead of replacing the entire texture in texture memory, only parts of it are replaced.
 
void setSubValue (const SbVec3s &subSize, const SbVec3s &offset, unsigned char *bytes, CopyPolicy copy=COPY)
 These methods may be used for subtexturing: instead of replacing the entire texture in texture memory, only parts of it are replaced.
 
void setSubValues (const SbVec3i32 *subSizes, const SbVec3i32 *offsets, int num, void **data, CopyPolicy copy=COPY)
 These methods may be used for subtexturing: instead of replacing the entire texture in texture memory, only parts of it are replaced.
 
void setSubValues (const SbVec3s *subSizes, const SbVec3s *offsets, int num, unsigned char **bytes, CopyPolicy copy=COPY)
 These methods may be used for subtexturing: instead of replacing the entire texture in texture memory, only parts of it are replaced.
 
int operator== (const SoSFImage3 &f) const
 Equality/inequality tests.
 
int operator!= (const SoSFImage3 &f) const
 Equality/inequality tests.
 
void * startEditing (SbVec3i32 &size, int &nc, SoSFImage::DataType &dataType)
 These methods can be used to efficiently edit the values in an image field.
 
unsigned char * startEditing (SbVec3s &size, int &nc)
 These methods can be used to efficiently edit the values in an image field.
 
void finishEditing ()
 These methods can be used to efficiently edit the values in an image field.
 
void * getSubTexture (int index, SbVec3i32 &size, SbVec3i32 &offset, SoSFImage::DataType &dataType)
 Returns a buffer to a given subTexture set by setSubValue, setSubValues, or a startEditing()/finishEditing() pair.
 
unsigned char * getSubTexture (int index, SbVec3s &size, SbVec3s &offset)
 Returns a buffer to a given subTexture set by setSubValue, setSubValues, or a startEditing()/finishEditing() pair.
 
SbBool hasSubTextures (int &numSubTextures)
 Returns TRUE if subTextures have been defined or FALSE if none have been defined.
 
void setNeverWrite (SbBool neverWrite)
 As this field may have to handle large amounts of data and its representation in an .iv file is not very efficient, it is often a good idea not to allow that data to be written out when required by a write action.
 
SbBool isNeverWrite ()
 As this field may have to handle large amounts of data and its representation in an .iv file is not very efficient, it is often a good idea not to allow that data to be written out when required by a write action.
 
SoBufferObjectgetBufferObject () const
 
int getNumComponents () const
 Returns the number of components in each pixels of the image.
 
- Public Member Functions inherited from SoField
void setIgnored (SbBool ig)
 Sets the ignore flag for this field.
 
SbBool isIgnored () const
 Gets the ignore flag for this field.
 
SbBool isDefault () const
 Gets the state of default flag of the field.
 
void enableConnection (SbBool flag)
 Field connections may be enabled and disabled.
 
SbBool isConnectionEnabled () const
 Returns FALSE if connections to this field are disabled.
 
SbBool connectFrom (SoEngineOutput *engineOutput)
 Connects this field from an engine output.
 
SbBool connectFrom (SoField *field)
 Connects this field to another field.
 
SbBool connectFrom (SoVRMLInterpOutput *interpOutput)
 Connects this field from an interpOutput.
 
SbBool appendConnection (SoEngineOutput *engineOutput)
 Appends this field to the list of connections from another engineOutput.
 
SbBool appendConnection (SoField *field)
 Appends this field to the list of connections from another field.
 
SbBool appendConnection (SoVRMLInterpOutput *interpOutput)
 Appends this field to the list of connections from another interpOutput.
 
void disconnect (SoEngineOutput *engineOutput)
 Disconnect the field from the requested engineOutput.
 
void disconnect (SoField *field)
 Disconnect the field from the requested field.
 
void disconnect (SoVRMLInterpOutput *interpOutput)
 Disconnect the field from the requested interpOutput.
 
int getNumConnections () const
 Returns the number of connections to this field.
 
int getConnections (SoFieldList &list)
 Returns a list of the connections to this field.
 
void disconnect ()
 Disconnect the field from whatever it was connected to.
 
SbBool isConnected () const
 Returns TRUE if the field is connected to anything.
 
SbBool isConnectedFromVRMLInterp () const
 Returns TRUE if the field is connected to a VRML interpOutput.
 
SbBool isConnectedFromEngine () const
 Returns TRUE if the field is connected to an engine's output.
 
SbBool isConnectedFromField () const
 Returns TRUE if the field is connected to another field.
 
SbBool getConnectedEngine (SoEngineOutput *&engineOutput) const
 Returns TRUE if this field is being written into by an engine, and returns the engine output it is connected to in engineOutput.
 
SbBool getConnectedField (SoField *&writingField) const
 Returns TRUE if this field is being written into by another field, and returns the field it is connected to in writingField.
 
SbBool getConnectedVRMLInterp (SoVRMLInterpOutput *&interpOutput) const
 Returns the VRMLInterpolator output field is connected to.
 
int getForwardConnections (SoFieldList &list) const
 Adds references to all of the fields that this field is writing into (either fields in nodes, global fields or engine inputs) to the given field list, and returns the number of forward connections.
 
SoFieldContainergetContainer () const
 Returns the object that contains this field.
 
SoNONUNICODE SbBool set (const char *valueString)
 Sets the field to the given value, which is an ASCII string in the Open Inventor file format.
 
SbBool set (const SbString &valueString)
 Sets the field to the given value, which is an ASCII string in the Open Inventor file format.
 
void get (SbString &valueString)
 Returns the value of the field in the Open Inventor file format, even if the field has its default value.
 
virtual size_t getValueSize () const
 Gets the size of the value.
 
virtual void touch ()
 Simulates a change to the field, causing attached sensors to fire, connected fields and engines to be marked as needing evaluation, and so forth.
 
int operator== (const SoField &f) const
 Return TRUE if this field is of the same type and has the same value as f.
 
int operator!= (const SoField &f) const
 Return FALSE if this field is of the same type and has the same value as f.
 
- Public Member Functions inherited from SoTypedObject
SbBool isOfType (const SoType &type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
template<typename TypedObjectClass >
SbBool isOfType () const
 Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- Static Public Member Functions inherited from SoSField
static SoType getClassTypeId ()
 Return the type identifier for this field class.
 
- Static Public Member Functions inherited from SoField
static SoType getClassTypeId ()
 Return the type identifier for this field class.
 
- Static Public Member Functions inherited from SoTypedObject
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 

Detailed Description

VSG extension Field containing a 3D image.

A field containing a three-dimensional image. A three-dimensional image can be thought of as a sequence of two-dimensional image "slices."

Images can be grayscale (intensity), grayscale with transparency information, RGB, or RGB with transparency. Each component of the image (intensity, red, green, blue or transparency (alpha)) can have an unsigned one-byte value from 0 to 255.

Values are returned as arrays of unsigned chars. The image is stored in this array starting at the bottom left front corner of the image with the intensity or red component of that pixel, followed by either the alpha, the green and blue, or the green, blue and alpha components (depending on the number of components in the image). The next value is the first component of the next pixel to the right.

SoSFImage3s are written to file as four integers representing the width, height, depth and number of components in the image, followed by width*height*depth hexadecimal values representing the pixels in the image, separated by whitespace. A one-component image will have one-byte hexadecimal values representing the intensity of the image. For example, 0xFF is full intensity, 0x00 is no intensity. A two-component image puts the intensity in the first (high) byte and the transparency in the second (low) byte. Pixels in a three-component image have the red component in the first (high) byte, followed by the green and blue components (so 0xFF0000 is red). Four-component images put the transparency byte after red/green/blue (so 0x0000FF80 is semi-transparent blue). Note: each pixel is actually read as a single unsigned number, so a 3-component pixel with value "0x0000FF" can also be written as "0xFF" or "255" (decimal).

For example,

   1 2 3 1 0xFF 0x00 0x00 0xFF 0xFF 0x00

is a 1 pixel wide by 2 pixel high by 3 pixel deep grayscale image, with the bottom pixel white and the top pixel black in the first (front-most) slice. In the second slice the bottom pixel is black and the top pixel is white. And:

   2 4 3 3 0xFF0000 0xFF00 0 0 0 0 0xFFFFFF 0xFFFF00 ...

is a 2 pixel wide by 4 pixel high by 3 pixel deep RGB image, with the bottom left pixel red, the bottom right pixel green, the two middle rows of pixels black, the top left pixel white, and the top right pixel yellow in the first slice. Subsequent slices are not shown.

SEE ALSO

SoField, SoSField

Definition at line 120 of file SoSFImage3.h.

Member Enumeration Documentation

◆ CopyPolicy

SoSFImage3 may be manipulating some large amounts of memory.

It is therefore convienent to be able to set the memory usage policy dynamically (copying a small 256x256x256 image with only 8 bits color already takes 16MB). By default, the memory policy is COPY, which is consistent with other OIV fields. The most likely to be efficient is NO_COPY. See also setNeverWrite.

Enumerator
COPY 

Open Inventor will make a copy of the data (default)

NO_COPY 

Passed buffer used , user will delete .

NO_COPY_AND_DELETE 

Passed buffer used, SoSFImage3 will delete .


Use this if memory is allocated with "new".

NO_COPY_AND_FREE 

Passed buffer used, SoSFImage3 will free .


Use this if memory is allocated with "malloc".

Definition at line 138 of file SoSFImage3.h.

Constructor & Destructor Documentation

◆ SoSFImage3()

SoSFImage3::SoSFImage3 ( )

Default constructor.

◆ ~SoSFImage3()

virtual SoSFImage3::~SoSFImage3 ( )
virtual

Destructor.

Member Function Documentation

◆ finishEditing()

void SoSFImage3::finishEditing ( )

These methods can be used to efficiently edit the values in an image field.

startEditing() returns the size of the image in the size and nc arguments; writing past the end of the array returned is a good way to cause hard-to-find core dumps.

Doing a start/finishEditing is the same as doing a call to setSubValues on the whole texture. The getSubTexture will return one more updated regions when called after finishEditing.

Avoid copying the values in/out, if you are just changing the bytes and not changing the dimensions of the image. This is equivalent to getValue(), but returns a pointer you can change. Using startEditing() allows subtexturing, which is a more efficient way of doing texture modification.

◆ getBufferObject() [1/3]

SoBufferObject * SoSFImage3::getBufferObject ( ) const
inline

Definition at line 472 of file SoSFImage3.h.

◆ getBufferObject() [2/3]

SoBufferObject * SoSFImage3::getBufferObject ( SbVec3i32 size,
int &  nc,
SoSFImage::DataType dataType 
) const

Returns the pixels in the image as a buffer object.

The size and nc arguments are filled in with the dimensions of the image and the number of components in the image; the number of bytes in the array returned will be size [0]* size [1]* size [2]* nc *sizeof(<dataType>).

◆ getBufferObject() [3/3]

SoBufferObject * SoSFImage3::getBufferObject ( SbVec3s size,
int &  nc 
) const

Returns the pixels in the image as a buffer object.

The size and nc arguments are filled in with the dimensions of the image and the number of components in the image; the number of bytes in the array returned will be size [0]* size [1]* size [2]* nc .

◆ getClassTypeId()

static SoType SoSFImage3::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getNumComponents()

int SoSFImage3::getNumComponents ( ) const
inline

Returns the number of components in each pixels of the image.

Definition at line 478 of file SoSFImage3.h.

◆ getSubTexture() [1/2]

void * SoSFImage3::getSubTexture ( int  index,
SbVec3i32 size,
SbVec3i32 offset,
SoSFImage::DataType dataType 
)

Returns a buffer to a given subTexture set by setSubValue, setSubValues, or a startEditing()/finishEditing() pair.

These methods append subTextures to a list. Also returns the size of the subtexture, the offset from the beginning of the image and the data type of the requested subImage.

◆ getSubTexture() [2/2]

unsigned char * SoSFImage3::getSubTexture ( int  index,
SbVec3s size,
SbVec3s offset 
)

Returns a buffer to a given subTexture set by setSubValue, setSubValues, or a startEditing()/finishEditing() pair.

These methods append subTextures to a list. Also returns the size of the subtexture and the offset from the beginning of the image of the requested subImage.
This is a convenience method for the unsigned char datatype.

◆ getTypeId()

virtual SoType SoSFImage3::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Implements SoTypedObject.

◆ getValue() [1/2]

const void * SoSFImage3::getValue ( SbVec3i32 size,
int &  nc,
SoSFImage::DataType dataType 
) const

Returns the pixels in the image as an array of values of type <dataType>.

The size and nc arguments are filled in with the dimensions of the image and the number of components in the image; the number of bytes in the array returned will be size [0]* size [1]* size [2]* nc *sizeof(<dataType>).

◆ getValue() [2/2]

const unsigned char * SoSFImage3::getValue ( SbVec3s size,
int &  nc 
) const

Returns the pixels in the image as an array of unsigned chars.

The size and nc arguments are filled in with the dimensions of the image and the number of components in the image; the number of bytes in the array returned will be size [0]* size [1]* size [2]* nc *sizeof(<dataType>).
This is a convenience method for the unsigned char datatype.

◆ hasSubTextures()

SbBool SoSFImage3::hasSubTextures ( int &  numSubTextures)

Returns TRUE if subTextures have been defined or FALSE if none have been defined.

Also returns the number of subTextures defined.

◆ isNeverWrite()

SbBool SoSFImage3::isNeverWrite ( )
inline

As this field may have to handle large amounts of data and its representation in an .iv file is not very efficient, it is often a good idea not to allow that data to be written out when required by a write action.

By default, the "neverWrite" condition is TRUE.

Definition at line 406 of file SoSFImage3.h.

◆ operator!=()

int SoSFImage3::operator!= ( const SoSFImage3 f) const
inline

Equality/inequality tests.

Definition at line 307 of file SoSFImage3.h.

◆ operator=()

const SoSFImage3 & SoSFImage3::operator= ( const SoSFImage3 f)

Copy from another field of same type.

◆ operator==()

int SoSFImage3::operator== ( const SoSFImage3 f) const

Equality/inequality tests.

◆ setNeverWrite()

void SoSFImage3::setNeverWrite ( SbBool  neverWrite)

As this field may have to handle large amounts of data and its representation in an .iv file is not very efficient, it is often a good idea not to allow that data to be written out when required by a write action.

By default, the "neverWrite" condition is TRUE.

◆ setSubValue() [1/2]

void SoSFImage3::setSubValue ( const SbVec3i32 subSize,
const SbVec3i32 offset,
void *  bytes,
CopyPolicy  copy = COPY 
)

These methods may be used for subtexturing: instead of replacing the entire texture in texture memory, only parts of it are replaced.

This is much faster and uses less memory. In any case these methods affect the texture in system memory. Note that the sub-images must have the same number of components as the one contained in this object. The texture in texture memory will not actually be modified until the next render traversal.

◆ setSubValue() [2/2]

void SoSFImage3::setSubValue ( const SbVec3s subSize,
const SbVec3s offset,
unsigned char *  bytes,
CopyPolicy  copy = COPY 
)

These methods may be used for subtexturing: instead of replacing the entire texture in texture memory, only parts of it are replaced.

This is much faster and uses less memory. In any case these methods affect the texture in system memory. Note that the sub-images must have the same number of components as the one contained in this object. The texture in texture memory will not actually be modified until the next render traversal.
This is a convenience method for the unsigned char datatype.

◆ setSubValues() [1/2]

void SoSFImage3::setSubValues ( const SbVec3i32 subSizes,
const SbVec3i32 offsets,
int  num,
void **  data,
CopyPolicy  copy = COPY 
)

These methods may be used for subtexturing: instead of replacing the entire texture in texture memory, only parts of it are replaced.

This is much faster and uses less memory. In any case these methods affect the texture in system memory. Note that the sub-images must have the same number of components as the one contained in this object. The texture in texture memory will not actually be modified until the next render traversal.

◆ setSubValues() [2/2]

void SoSFImage3::setSubValues ( const SbVec3s subSizes,
const SbVec3s offsets,
int  num,
unsigned char **  bytes,
CopyPolicy  copy = COPY 
)

These methods may be used for subtexturing: instead of replacing the entire texture in texture memory, only parts of it are replaced.

This is much faster and uses less memory. In any case these methods affect the texture in system memory. Note that the sub-images must have the same number of components as the one contained in this object. The texture in texture memory will not actually be modified until the next render traversal.
This is a convenience method for the unsigned char datatype.

◆ setValue() [1/4]

void SoSFImage3::setValue ( const SbVec3i32 size,
int  nc,
SoSFImage::DataType  dataType,
const void *  data,
CopyPolicy  copy = COPY 
)

Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values.

size[0]*size[1]*size[2]*nc*sizeof(<dataType>) bytes from the given array will be copied into internal storage maintained by the SoSFImage3 field.

At times, SoSFImage3 may need to manipulate large amounts of memory. Therefore, it is useful to be able to specify the memory usage policy dynamically. By default, the memory policy is COPY, which is consistent with other Open Inventor fields. The most likely to be efficient is NO_COPY. See also setNeverWrite().

◆ setValue() [2/4]

void SoSFImage3::setValue ( const SbVec3i32 size,
int  nc,
SoSFImage::DataType  dataType,
SoBufferObject bufferObject,
CopyPolicy  copy = COPY 
)

Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values.

size[0]*size[1]*size[2]*nc*sizeof(<dataType>) bytes from the given array will be copied into internal storage maintained by the SoSFImage3 field.

At times, SoSFImage3 may need to manipulate large amounts of memory. Therefore, it is useful to be able to specify the memory usage policy dynamically. By default, the memory policy is COPY, which is consistent with other Open Inventor fields. The most likely to be efficient is NO_COPY. See also setNeverWrite().

◆ setValue() [3/4]

void SoSFImage3::setValue ( const SbVec3s size,
int  nc,
SoBufferObject bufferObject,
CopyPolicy  copy = COPY 
)

Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values.

size[0]*size[1]*size[2]*nc*sizeof(<dataType>) bytes from the given array will be copied into internal storage maintained by the SoSFImage3 field.

At times, SoSFImage3 may need to manipulate large amounts of memory. Therefore, it is useful to be able to specify the memory usage policy dynamically. By default, the memory policy is COPY, which is consistent with other Open Inventor fields. The most likely to be efficient is NO_COPY. See also setNeverWrite().

◆ setValue() [4/4]

void SoSFImage3::setValue ( const SbVec3s size,
int  nc,
unsigned char *  bytes,
CopyPolicy  copy = COPY 
)

Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values.

size[0]*size[1]*size[2]*nc*sizeof(<dataType>) bytes from the given array will be copied into internal storage maintained by the SoSFImage3 field.

At times, SoSFImage3 may need to manipulate large amounts of memory. Therefore, it is useful to be able to specify the memory usage policy dynamically. By default, the memory policy is COPY, which is consistent with other Open Inventor fields. The most likely to be efficient is NO_COPY. See also setNeverWrite().
This is a convenience method for the unsigned char datatype.

◆ startEditing() [1/2]

void * SoSFImage3::startEditing ( SbVec3i32 size,
int &  nc,
SoSFImage::DataType dataType 
)

These methods can be used to efficiently edit the values in an image field.

startEditing() returns the size of the image in the size and nc arguments; writing past the end of the array returned is a good way to cause hard-to-find core dumps.

Calling this method is the same as doing a call to setSubValues on the whole texture. The getSubTexture will return one more updated regions when called after finishEditing.

Avoid copying the values in/out, if you are just changing the bytes and not changing the dimensions of the image. This is equivalent to getValue(), but returns a pointer you can change. Using startEditing() allows subtexturing, which is a more efficient way of doing texture modification.

◆ startEditing() [2/2]

unsigned char * SoSFImage3::startEditing ( SbVec3s size,
int &  nc 
)

These methods can be used to efficiently edit the values in an image field.

startEditing() returns the size of the image in the size and nc arguments; writing past the end of the array returned is a good way to cause hard-to-find core dumps.

Calling this method is the same as doing a call to setSubValues on the whole texture. The getSubTexture will return one more updated regions when called after finishEditing.

Avoid copying the values in/out, if you are just changing the bytes and not changing the dimensions of the image. This is equivalent to getValue(), but returns a pointer you can change. Using startEditing() allows subtexturing, which is a more efficient way of doing texture modification.
This is a convenience method for the unsigned char datatype.


The documentation for this class was generated from the following file: