HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_VoxelTile< T > Class Template Reference

#include <UT_VoxelArray.h>

Public Types

enum  CompressionType {
  COMPRESS_RAW, COMPRESS_RAWFULL, COMPRESS_CONSTANT, COMPRESS_FPREAL16,
  COMPRESS_ENGINE
}
 

Public Member Functions

 UT_VoxelTile ()
 
 ~UT_VoxelTile ()
 
 UT_VoxelTile (const UT_VoxelTile< T > &src)
 
const UT_VoxelTile< T > & operator= (const UT_VoxelTile< T > &src)
 
SYS_FORCE_INLINE T operator() (int x, int y, int z) const
 
SYS_STATIC_FORCE_INLINE T lerpValues (T v1, T v2, fpreal32 bias)
 Lerps two numbers, templated to work with T. More...
 
SYS_FORCE_INLINE T lerp (int x, int y, int z, float fx, float fy, float fz) const
 
template<int AXIS2D>
SYS_FORCE_INLINE T lerpAxis (int x, int y, int z, float fx, float fy, float fz) const
 
SYS_NO_DISCARD_RESULT
SYS_FORCE_INLINE bool 
extractSample (int x, int y, int z, T *sample) const
 
template<int AXIS2D>
SYS_NO_DISCARD_RESULT
SYS_FORCE_INLINE bool 
extractSampleAxis (int x, int y, int z, T *sample) const
 
SYS_FORCE_INLINE bool extractSamplePlus (int x, int y, int z, T *sample) const
 
TfillCacheLine (T *cacheline, int &stride, int x, int y, int z, bool forcecopy, bool strideofone) const
 
void writeCacheLine (T *cacheline, int y, int z)
 Fills a cache line from an external buffer into our own data. More...
 
void copyFragment (int dstx, int dsty, int dstz, const UT_VoxelTile< T > &srctile, int srcx, int srcy, int srcz)
 
template<typename S >
void flatten (S *dst, int dststride) const
 Flattens ourself into the given destination buffer. More...
 
template<typename S >
void writeData (const S *src, int srcstride)
 
void setValue (int x, int y, int z, T t)
 
void findMinMax (T &min, T &max) const
 Finds the minimum and maximum T values. More...
 
void findAverage (T &avg) const
 Determines the average value of the tile. More...
 
bool isConstant () const
 Returns if this tile is constant. More...
 
bool hasNan () const
 Returns true if any NANs are in this tile. More...
 
bool isRaw () const
 Returns if this tile is in raw format. More...
 
bool isRawFull () const
 Returns if this tile is in raw full format. More...
 
bool isSimpleCompression () const
 
bool tryCompress (const UT_VoxelCompressOptions &options)
 
void makeConstant (T t)
 Turns this tile into a constant tile of the given value. More...
 
void makeFpreal16 ()
 Explicit compress to fpreal16. Lossy. No-op if already constant. More...
 
void uncompress ()
 Turns a compressed tile into a raw tile. More...
 
void uncompressFull ()
 Turns a tile into a raw full tile. More...
 
void makeRawUninitialized ()
 
TrawFullData ()
 Returns the raw full data of the tile. More...
 
TrawData ()
 
const TrawData () const
 
int xres () const
 Read the current resolution. More...
 
int yres () const
 
int zres () const
 
int getRes (int dim) const
 
int numVoxels () const
 
int64 getMemoryUsage (bool inclusive) const
 Returns the amount of memory used by this tile. More...
 
exint getDataLength () const
 Returns the amount of data used by the tile myData pointer. More...
 
void weightedSum (int pstart[3], int pend[3], const float *weights[3], int start[3], T &result)
 
void save (std::ostream &os) const
 
bool save (UT_JSONWriter &w) const
 
void load (UT_IStream &is, const UT_IntArray &compression)
 
bool load (UT_JSONParser &p, const UT_IntArray &compression)
 
SYS_FORCE_INLINE void freeData ()
 
template<int AXIS2D>
T lerpAxis (int x, int y, int z, fpreal32 fx, fpreal32 fy, fpreal32 fz) const
 
template<int AXIS2D>
bool extractSampleAxis (int x, int y, int z, T *sample) const
 

Static Public Member Functions

static void expandMinMax (T v, T &min, T &max)
 Designed to be specialized according to T. More...
 
static fpreal dist (T a, T b)
 
static void registerCompressionEngine (UT_VoxelTileCompress< T > *engine)
 
static int lookupCompressionEngine (const char *name)
 
static UT_VoxelTileCompress< T > * getCompressionEngine (int index)
 
static void saveCompressionTypes (std::ostream &os)
 Stores a list of compresson engines to os. More...
 
static bool saveCompressionTypes (UT_JSONWriter &w)
 
static void loadCompressionTypes (UT_IStream &is, UT_IntArray &compressions)
 
static bool loadCompressionTypes (UT_JSONParser &p, UT_IntArray &compressions)
 

Public Attributes

voidmyData
 

Protected Member Functions

bool writeThrough (int x, int y, int z, T t)
 
void setRes (int xr, int yr, int zr)
 
SYS_FORCE_INLINE bool inlineConstant () const
 
SYS_FORCE_INLINE T rawConstVal () const
 
SYS_FORCE_INLINE TrawConstData () const
 
void setForeignData (void *data, int8 compress_type)
 

Friends

class UT_VoxelTileCompress< T >
 
class UT_VoxelArray< T >
 
template<typename S , bool DoWrite, bool DoRead, bool TestForWrites>
class UT_VoxelProbe
 

Detailed Description

template<typename T>
class UT_VoxelTile< T >

UT_VoxelTile

A UT_VoxelArray is composed of a number of these tiles. This is done for two reasons: 1) Increased memory locality when processing neighbouring points. 2) Ability to compress or page out unneeded tiles. Currently, the only special ability is the ability to create constant tiles.

To the end user of the UT_VoxelArray, the UT_VoxelTile should be usually transparent. The only exception may be if they want to do a FOR_ALL_TILES in order to ensure an optimal traversal order.

Examples:
field3d/f3d_io.C.

Definition at line 79 of file UT_VoxelArray.h.

Member Enumeration Documentation

template<typename T>
enum UT_VoxelTile::CompressionType
Enumerator
COMPRESS_RAW 
COMPRESS_RAWFULL 
COMPRESS_CONSTANT 
COMPRESS_FPREAL16 
COMPRESS_ENGINE 

Definition at line 310 of file UT_VoxelArray.h.

Constructor & Destructor Documentation

template<typename T >
UT_VoxelTile< T >::UT_VoxelTile ( )

Definition at line 100 of file UT_VoxelArray.C.

template<typename T >
UT_VoxelTile< T >::~UT_VoxelTile ( )

Definition at line 126 of file UT_VoxelArray.C.

template<typename T>
UT_VoxelTile< T >::UT_VoxelTile ( const UT_VoxelTile< T > &  src)

Definition at line 132 of file UT_VoxelArray.C.

Member Function Documentation

template<typename T>
void UT_VoxelTile< T >::copyFragment ( int  dstx,
int  dsty,
int  dstz,
const UT_VoxelTile< T > &  srctile,
int  srcx,
int  srcy,
int  srcz 
)

Copies between two tiles. The tile's voxels match up, but don't have the same offset. The maximal overlapping voxels are copied. this->setValue(dst, dsty, dstz, src(srcx, srcy, srcz));

Definition at line 1340 of file UT_VoxelArray.C.

template<typename T>
static fpreal UT_VoxelTile< T >::dist ( T  a,
T  b 
)
inlinestatic

Return the "distance" of a & b. This is used for tolerance checks on equality comparisons.

Definition at line 506 of file UT_VoxelArray.h.

template<typename T>
static void UT_VoxelTile< T >::expandMinMax ( T  v,
T min,
T max 
)
inlinestatic

Designed to be specialized according to T.

Update min & max to encompass T itself.

Definition at line 499 of file UT_VoxelArray.h.

template<typename T>
bool UT_VoxelTile< T >::extractSample ( int  x,
int  y,
int  z,
T sample 
) const

Extracts a sample of [x,y,z] to [x+1,y+1,z+1]. The sample array should have 8 elements, x minor, z major. Requires it is in bounds. Returns true if all constant, in which case only a single sample is filled, [0]

Definition at line 697 of file UT_VoxelArray.C.

template<typename T>
template<int AXIS2D>
SYS_NO_DISCARD_RESULT SYS_FORCE_INLINE bool UT_VoxelTile< T >::extractSampleAxis ( int  x,
int  y,
int  z,
T sample 
) const
template<typename T>
template<int AXIS2D>
bool UT_VoxelTile< T >::extractSampleAxis ( int  x,
int  y,
int  z,
T sample 
) const

Definition at line 988 of file UT_VoxelArray.C.

template<typename T>
bool UT_VoxelTile< T >::extractSamplePlus ( int  x,
int  y,
int  z,
T sample 
) const

Extracts +/- dx, +/- dy, +/- dz and then the center into 7 samples.

Definition at line 785 of file UT_VoxelArray.C.

template<typename T>
T * UT_VoxelTile< T >::fillCacheLine ( T cacheline,
int stride,
int  x,
int  y,
int  z,
bool  forcecopy,
bool  strideofone 
) const

Returns a cached line to our internal data, at local address x,y,z. cacheline is a caller allocated structure to fill out if we have to decompress. If forcecopy isn't set and we can, the result may be an internal pointer. stride is set to the update for moving one x position in the cache. strideofone should be set to true if you want to prevent 0 stride results for constant tiles.

Definition at line 1201 of file UT_VoxelArray.C.

template<typename T>
void UT_VoxelTile< T >::findAverage ( T avg) const

Determines the average value of the tile.

Definition at line 1756 of file UT_VoxelArray.C.

template<typename T>
void UT_VoxelTile< T >::findMinMax ( T min,
T max 
) const

Finds the minimum and maximum T values.

Definition at line 1915 of file UT_VoxelArray.C.

template<typename T >
template<typename S >
void UT_VoxelTile< T >::flatten ( S dst,
int  dststride 
) const

Flattens ourself into the given destination buffer.

Definition at line 1407 of file UT_VoxelArray.C.

template<typename T>
SYS_FORCE_INLINE void UT_VoxelTile< T >::freeData ( )
inline

Frees myData and sets it to zero. This is a bit tricky as the constant tiles may be inlined. This is only public for the compression engines.

Definition at line 583 of file UT_VoxelArray.h.

template<typename T >
UT_VoxelTileCompress< T > * UT_VoxelTile< T >::getCompressionEngine ( int  index)
static

Definition at line 2437 of file UT_VoxelArray.C.

template<typename T >
int64 UT_VoxelTile< T >::getDataLength ( ) const

Returns the amount of data used by the tile myData pointer.

Definition at line 2204 of file UT_VoxelArray.C.

template<typename T >
int64 UT_VoxelTile< T >::getMemoryUsage ( bool  inclusive) const

Returns the amount of memory used by this tile.

Definition at line 2195 of file UT_VoxelArray.C.

template<typename T>
int UT_VoxelTile< T >::getRes ( int  dim) const
inline

Definition at line 476 of file UT_VoxelArray.h.

template<typename T >
bool UT_VoxelTile< T >::hasNan ( ) const

Returns true if any NANs are in this tile.

Definition at line 1991 of file UT_VoxelArray.C.

template<typename T>
SYS_FORCE_INLINE bool UT_VoxelTile< T >::inlineConstant ( ) const
inlineprotected

Definition at line 551 of file UT_VoxelArray.h.

template<typename T>
bool UT_VoxelTile< T >::isConstant ( ) const
inline

Returns if this tile is constant.

Definition at line 407 of file UT_VoxelArray.h.

template<typename T>
bool UT_VoxelTile< T >::isRaw ( ) const
inline

Returns if this tile is in raw format.

Definition at line 414 of file UT_VoxelArray.h.

template<typename T>
bool UT_VoxelTile< T >::isRawFull ( ) const
inline

Returns if this tile is in raw full format.

Definition at line 418 of file UT_VoxelArray.h.

template<typename T>
bool UT_VoxelTile< T >::isSimpleCompression ( ) const
inline

Returns true if this is a simple form of compression, either constant, raw, or a raw full that isn't padded

Definition at line 423 of file UT_VoxelArray.h.

template<typename T >
T UT_VoxelTile< T >::lerp ( int  x,
int  y,
int  z,
float  fx,
float  fy,
float  fz 
) const

Does a trilinear interpolation. x,y,z should be local to this as should x+1, y+1, and z+1. fx-fz should be 0..1.

Definition at line 276 of file UT_VoxelArray.C.

template<typename T>
template<int AXIS2D>
SYS_FORCE_INLINE T UT_VoxelTile< T >::lerpAxis ( int  x,
int  y,
int  z,
float  fx,
float  fy,
float  fz 
) const
template<typename T>
template<int AXIS2D>
T UT_VoxelTile< T >::lerpAxis ( int  x,
int  y,
int  z,
fpreal32  fx,
fpreal32  fy,
fpreal32  fz 
) const

Definition at line 421 of file UT_VoxelArray.C.

template<typename T>
SYS_STATIC_FORCE_INLINE T UT_VoxelTile< T >::lerpValues ( T  v1,
T  v2,
fpreal32  bias 
)
inline

Lerps two numbers, templated to work with T.

Definition at line 324 of file UT_VoxelArray.h.

template<typename T >
void UT_VoxelTile< T >::load ( UT_IStream is,
const UT_IntArray compression 
)

Loads tile data. Uses the compression index to map the saved compression types into the correct loading compression types.

Definition at line 2525 of file UT_VoxelArray.C.

template<typename T >
bool UT_VoxelTile< T >::load ( UT_JSONParser p,
const UT_IntArray compression 
)

Definition at line 2718 of file UT_VoxelArray.C.

template<typename T >
void UT_VoxelTile< T >::loadCompressionTypes ( UT_IStream is,
UT_IntArray compressions 
)
static

Builds a translation table from the given stream's compression types into our own valid compression types.

Definition at line 2856 of file UT_VoxelArray.C.

template<typename T >
bool UT_VoxelTile< T >::loadCompressionTypes ( UT_JSONParser p,
UT_IntArray compressions 
)
static

Definition at line 2919 of file UT_VoxelArray.C.

template<typename T >
int UT_VoxelTile< T >::lookupCompressionEngine ( const char *  name)
static

Definition at line 2417 of file UT_VoxelArray.C.

template<typename T>
void UT_VoxelTile< T >::makeConstant ( T  t)

Turns this tile into a constant tile of the given value.

Definition at line 2121 of file UT_VoxelArray.C.

template<typename T >
void UT_VoxelTile< T >::makeFpreal16 ( )

Explicit compress to fpreal16. Lossy. No-op if already constant.

Definition at line 2137 of file UT_VoxelArray.C.

template<typename T >
void UT_VoxelTile< T >::makeRawUninitialized ( )

Like uncompress() except it leaves the data uninitialized. Result is either COMPRESS_RAW or COMPRESS_RAWFULL depending on the tile res.

Note
USE WITH CAUTION!

Definition at line 1739 of file UT_VoxelArray.C.

template<typename T>
int UT_VoxelTile< T >::numVoxels ( ) const
inline

Definition at line 479 of file UT_VoxelArray.h.

template<typename T >
T UT_VoxelTile< T >::operator() ( int  x,
int  y,
int  z 
) const

Fetch a given local value. (x,y,z) should be local to this tile.

Definition at line 237 of file UT_VoxelArray.C.

template<typename T>
const UT_VoxelTile< T > & UT_VoxelTile< T >::operator= ( const UT_VoxelTile< T > &  src)

Definition at line 142 of file UT_VoxelArray.C.

template<typename T>
SYS_FORCE_INLINE T* UT_VoxelTile< T >::rawConstData ( ) const
inlineprotected

Definition at line 559 of file UT_VoxelArray.h.

template<typename T>
SYS_FORCE_INLINE T UT_VoxelTile< T >::rawConstVal ( ) const
inlineprotected

Definition at line 556 of file UT_VoxelArray.h.

template<typename T>
T* UT_VoxelTile< T >::rawData ( )
inline

This only makes sense for simple compression. Use with extreme care.

Definition at line 462 of file UT_VoxelArray.h.

template<typename T>
const T* UT_VoxelTile< T >::rawData ( ) const
inline

Definition at line 466 of file UT_VoxelArray.h.

template<typename T>
T* UT_VoxelTile< T >::rawFullData ( )
inline

Returns the raw full data of the tile.

Definition at line 454 of file UT_VoxelArray.h.

template<typename T>
void UT_VoxelTile< T >::registerCompressionEngine ( UT_VoxelTileCompress< T > *  engine)
static

Definition at line 2398 of file UT_VoxelArray.C.

template<typename T >
void UT_VoxelTile< T >::save ( std::ostream &  os) const

Saves this tile's data, in compressed form. May save in uncompressed form is the compression type does not support saving.

Definition at line 2446 of file UT_VoxelArray.C.

template<typename T >
bool UT_VoxelTile< T >::save ( UT_JSONWriter w) const

Definition at line 2613 of file UT_VoxelArray.C.

template<typename T >
void UT_VoxelTile< T >::saveCompressionTypes ( std::ostream &  os)
static

Stores a list of compresson engines to os.

Definition at line 2832 of file UT_VoxelArray.C.

template<typename T >
bool UT_VoxelTile< T >::saveCompressionTypes ( UT_JSONWriter w)
static

Definition at line 2892 of file UT_VoxelArray.C.

template<typename T>
void UT_VoxelTile< T >::setForeignData ( void data,
int8  compress_type 
)
inlineprotected

Definition at line 563 of file UT_VoxelArray.h.

template<typename T>
void UT_VoxelTile< T >::setRes ( int  xr,
int  yr,
int  zr 
)
inlineprotected

Sets the local res of the tile. Does not resize the allocated memory.

Definition at line 548 of file UT_VoxelArray.h.

template<typename T>
void UT_VoxelTile< T >::setValue ( int  x,
int  y,
int  z,
T  t 
)

The setData is intentionally seperate so we can avoid expanding constant data when we write the same value to it.

Definition at line 1544 of file UT_VoxelArray.C.

template<typename T >
bool UT_VoxelTile< T >::tryCompress ( const UT_VoxelCompressOptions options)

Attempts to compress this tile. Returns true if any compression performed.

Definition at line 2042 of file UT_VoxelArray.C.

template<typename T >
void UT_VoxelTile< T >::uncompress ( )

Turns a compressed tile into a raw tile.

Definition at line 1566 of file UT_VoxelArray.C.

template<typename T >
void UT_VoxelTile< T >::uncompressFull ( )

Turns a tile into a raw full tile.

Definition at line 1703 of file UT_VoxelArray.C.

template<typename T>
void UT_VoxelTile< T >::weightedSum ( int  pstart[3],
int  pend[3],
const float weights[3],
int  start[3],
T result 
)

A routine used by filtered evaluation to accumulated a partial filtered sum in this tile. pstart, pend - voxel bounds (in UT_VoxelArray coordinates) weights - weight array start - UT_VoxelArray coordinates at [0] in the weight array

Definition at line 2240 of file UT_VoxelArray.C.

template<typename T>
void UT_VoxelTile< T >::writeCacheLine ( T cacheline,
int  y,
int  z 
)

Fills a cache line from an external buffer into our own data.

Definition at line 1287 of file UT_VoxelArray.C.

template<typename T >
template<typename S >
void UT_VoxelTile< T >::writeData ( const S src,
int  srcstride 
)

Fills our values from the given dense flat buffer. Will create a constant tile if the source is constant.

Definition at line 1486 of file UT_VoxelArray.C.

template<typename T>
bool UT_VoxelTile< T >::writeThrough ( int  x,
int  y,
int  z,
T  t 
)
protected

Definition at line 203 of file UT_VoxelArray.C.

template<typename T>
int UT_VoxelTile< T >::xres ( ) const
inline

Read the current resolution.

Definition at line 472 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelTile< T >::yres ( ) const
inline

Definition at line 473 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelTile< T >::zres ( ) const
inline

Definition at line 474 of file UT_VoxelArray.h.

Friends And Related Function Documentation

template<typename T>
friend class UT_VoxelArray< T >
friend

Definition at line 617 of file UT_VoxelArray.h.

template<typename T>
template<typename S , bool DoWrite, bool DoRead, bool TestForWrites>
friend class UT_VoxelProbe
friend

Definition at line 619 of file UT_VoxelArray.h.

template<typename T>
friend class UT_VoxelTileCompress< T >
friend

Definition at line 616 of file UT_VoxelArray.h.

Member Data Documentation

template<typename T>
void* UT_VoxelTile< T >::myData

Definition at line 600 of file UT_VoxelArray.h.


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