Workspace 6.21.5
Public Member Functions | List of all members
Texture3D Class Reference

Generic 3D image texture. More...

#include <Rendering/SceneComponents/Models/texture3d.h>

Inheritance diagram for Texture3D:
[legend]

Public Member Functions

 Texture3D ()
 
 Texture3D (const Texture3D &texturizer)
 
 ~Texture3D () override
 
void clearImages ()
 
Texture3Dclone () const override
 
virtual QString getCacheId () const
 
unsigned getDimensions () const override
 
const DataAnalysis::Image3dgetImage (int index=0) const
 
unsigned getNumImages () const override
 
const QString & getStateNameR () const
 
const QString & getStateNameS () const
 
const QString & getStateNameT () const
 
Mesh::Vector3d getTextureCoords (const Mesh::NodeHandle &node) const override
 
TextureImage getTextureImage (int index) const override
 
bool load (const DataExecution::SerializedItem &item) override
 
Texture3Doperator= (const Texture3D &texturizer)
 
bool save (DataExecution::SerializedItem &item) const override
 
int setImage (const DataAnalysis::Image3d *image, int index=-1)
 
void setStateNameR (const QString &name)
 
void setStateNameS (const QString &name)
 
void setStateNameT (const QString &name)
 
bool setTexturedModel (const Mesh::MeshModelInterface &model, bool glyphing) override
 
- Public Member Functions inherited from Texturizer
 ~Texturizer () override
 
bool canSerialize () const override
 
Texturizerclone () const override=0
 
QString getCacheId () const
 
virtual unsigned getDimensions () const =0
 
bool getEnabled () const
 
bool getInterpolate () const
 
unsigned getNumDimensionsEnabled () const
 
virtual unsigned getNumImages () const =0
 
unsigned getNumImagesEnabled () const
 
virtual Mesh::Vector3d getTextureCoords (const Mesh::NodeHandle &node) const =0
 
virtual TextureImage getTextureImage (int index) const =0
 
Wrapping getWrapping () const
 
bool load (const DataExecution::SerializedItem &item) override
 
bool save (DataExecution::SerializedItem &item) const override
 
void setEnabled (bool b)
 
void setInterpolate (bool b)
 
virtual bool setTexturedModel (const Mesh::MeshModelInterface &model, bool glyphing)
 
void setWrapping (Wrapping wrap)
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()=default
 
virtual Clonableclone () const =0
 
- Public Member Functions inherited from Serialize
virtual ~Serialize ()=default
 
virtual bool canSerialize () const =0
 
virtual bool load (const SerializedItem &item)=0
 
virtual bool save (SerializedItem &item) const =0
 

Additional Inherited Members

- Public Types inherited from Texturizer
enum  Wrapping { ClampToEdge , ClampToBorder , Repeat , MirroredRepeat }
 
- Protected Member Functions inherited from Texturizer
 Texturizer ()
 
 Texturizer (const Texturizer &t)
 
Texturizeroperator= (const Texturizer &t)
 

Detailed Description

3D image textures should generally have a width and height that is a power of 2. If they don't, some renderers might scale them accordingly which will still yield the correct result, but the image quality might not be as good as if a correctly sized image was provided in the first place.

Warning
This class assumes that all the element state lists have identical state array layouts. Requesting a state at a particular index for a segment, a shell or a volume element must all refer to the same state, both in name and in type.

Constructor & Destructor Documentation

◆ Texture3D() [1/2]

Texture3D ( )

◆ Texture3D() [2/2]

Texture3D ( const Texture3D texturizer)

◆ ~Texture3D()

~Texture3D ( )
override

Member Function Documentation

◆ clearImages()

void clearImages ( )

Discards all images currently held by the texturizer.

◆ clone()

Texture3D * clone ( ) const
overridevirtual
Returns
A clone of this object.
Note
Subclasses would normally return their own type rather than the Clonable type. The C++ language rules allow a more derived type to be returned from a virtual function and the compiler will still treat it as a valid override.

Implements Texturizer.

◆ getCacheId()

QString getCacheId ( ) const
virtual

◆ getDimensions()

unsigned getDimensions ( ) const
overridevirtual
Returns
The number of dimensions this texturizer supports. This should always be 1, 2 or 3, although it is conceivable that a texturizer might have 4 dimensions (but really that would be a modification of 3 dimensions with the 4th dimension being associated with the w component). A value of zero can also be returned as a special case to denote a texturizer which does not apply a texture at all.

Implements Texturizer.

◆ getImage()

const Image3d & getImage ( int  index = 0) const
Parameters
indexThe index of the image to retrieve.
Returns
The image at the specified index which will be used as the 3D texture image.
See also
setImage(), getTextureImage()

◆ getNumImages()

unsigned getNumImages ( ) const
overridevirtual
Returns
The number of images this texturizer holds. Some texturizers provide only one image, whereas others provide a set of images and the image to use for any given element is found by calling getTextureImage(). The getNumImages() function can be used by model processors to work out how many images they will need to handle during processing.

Implements Texturizer.

◆ getStateNameR()

const QString & getStateNameR ( ) const
Returns
The name of the node state which specifies the T component of the (S,T,R) texture co-ordinate space.
See also
setStateNameR()

◆ getStateNameS()

const QString & getStateNameS ( ) const
Returns
The name of the node state which specifies the S component of the (S,T) texture co-ordinate space.
See also
setStateNameS()

◆ getStateNameT()

const QString & getStateNameT ( ) const
Returns
The name of the node state which specifies the T component of the (S,T) texture co-ordinate space.
See also
setStateNameT()

◆ getTextureCoords()

Vector3d getTextureCoords ( const Mesh::NodeHandle node) const
overridevirtual
Parameters
nodeThe node we want the texture co-ordinate of
Precondition
setTexturedModel must have already been called with the MeshModelInterface that the supplied node belongs to.
Returns
The texture co-ordinates for the specified node. While the result returned is a 3D vector corresponding to the (s,t,r) texture co-ordinates, for lower dimensional textures simply ignore the latter components (eg 2D textures ignore the r component). For consistency, lower dimensional texturizers must set components they don't use to zero.
See also
getTextureImage(), setTexturedModel()

Implements Texturizer.

◆ getTextureImage()

TextureImage getTextureImage ( int  index) const
overridevirtual
Parameters
indexThe index of the texture image to retrieve. It must be a non-negative number less than the result of getNumImages().
Returns
The texture image corresponding to the specified index.

Implements Texturizer.

◆ load()

bool load ( const DataExecution::SerializedItem item)
overridevirtual
Parameters
itemSupplies the state to be loaded into this object.

This function will load the state of this object from item. For many object types, this is most easily implemented in terms of the object's input operator (>>).

It would be reasonable for subclass implementations to assume that the data provided in item is in the same form as would have been saved from a call to save.

Returns
If the state of the object could not be loaded, the function returns false. A return value of true implies that the object state was successfully loaded. If canSerialize() returns false, this function must do nothing except return false as well.

Implements Serialize.

◆ operator=()

Texture3D & operator= ( const Texture3D texturizer)

◆ save()

bool save ( DataExecution::SerializedItem item) const
overridevirtual
Parameters
itemWhere to save the state of this object.

This function will serialise the object by saving it to item. For most object types, this is most easily implemented in terms of the object's output operator (<<).

It is allowable for an object to only serialize part of itself. This would be useful if the data it represents has a set of defaults and only those values different to the defaults need to be serialized. Such an implementation then needs to be careful how it handles the complimentary load member function.

Returns
If an object could not be serialised or if the underlying object type does not support serialisation, this function should return false. A return value of true implies that the object was successfully saved to item. If canSerialize() returns false, this function must do nothing except return false as well.

Implements Serialize.

◆ setImage()

int setImage ( const DataAnalysis::Image3d image,
int  index = -1 
)
Parameters
imageThe image to use for the 3D texture. It should normally have a width and height that is an integer power of 2.
indexThe index of the image. If omitted, the default value of -1 indicates that the image should be appended to the array of images already added.
Returns
The index of the image after it was added. If index was a non-negative value, then this return value should be the same as index.
See also
getImage(), getTextureImage()

◆ setStateNameR()

void setStateNameR ( const QString &  name)
Parameters
nameThe name of the node state which specifies the T component of the (S,T,R) texture co-ordinate space.
See also
getStateNameR()

◆ setStateNameS()

void setStateNameS ( const QString &  name)
Parameters
nameThe name of the node state which specifies the S component of the (S,T) texture co-ordinate space.
See also
getStateNameS()

◆ setStateNameT()

void setStateNameT ( const QString &  name)
Parameters
nameThe name of the node state which specifies the T component of the (S,T) texture co-ordinate space.
See also
getStateNameT()

◆ setTexturedModel()

bool setTexturedModel ( const Mesh::MeshModelInterface model,
bool  glyphing 
)
overridevirtual
Parameters
modelThe model about to be textured.
glyphingIf true, the texture image selection by getTextureImage() should be based on node states instead of element states, since the the glyph that will be textured reflects the node states and no model elements are normally present or shown.

Subclasses can reimplement this function to save internal data about the model that will be used for subsequent calls to getTextureCoords() and getTextureImage(). Clients are free to call this function at any time, so the subclass must keep this in mind, although it will usually only be called by a model appearance processor just before it uses the texturizer to process the specified model or before it outputs a glyph.

Returns
True if successful or false if there was an error when trying to use the specified model. If the texturizer will not be able to return valid texture co-ordinates (eg texture co-ordinate node states are missing in the model), this function should return false.

Reimplemented from Texturizer.