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

#include <UT_VoxelArray.h>

Public Member Functions

 UT_VoxelArrayIterator ()
 
 UT_VoxelArrayIterator (UT_VoxelArray< T > *vox)
 
 UT_VoxelArrayIterator (UT_COWReadHandle< UT_VoxelArray< T > > handle)
 
 ~UT_VoxelArrayIterator ()
 
void setArray (UT_VoxelArray< T > *vox)
 
void setConstArray (const UT_VoxelArray< T > *vox)
 
void setHandle (UT_COWReadHandle< UT_VoxelArray< T > > handle)
 
void setPartialRange (int idx, int numranges)
 
void splitByTile (const UT_JobInfo &info)
 
template<typename S >
void setTile (const UT_VoxelArrayIterator< S > &vit, UT_VoxelArray< T > *array)
 
void setTile (const UT_VoxelArrayIterator< T > &vit)
 
void setInterrupt (UT_Interrupt *interrupt)
 
void detectInterrupts ()
 
void restrictToBBox (const UT_BoundingBox &bbox)
 
void restrictToBBox (int xmin, int xmax, int ymin, int ymax, int zmin, int zmax)
 The [xmin, xmax] are inclusive and measured in voxels. More...
 
void rewind ()
 Resets the iterator to point to the first voxel. More...
 
bool atEnd () const
 Returns true if we have iterated over all of the voxels. More...
 
void advance ()
 Advances the iterator to point to the next voxel. More...
 
int x () const
 Retrieve the current location of the iterator. More...
 
int y () const
 
int z () const
 
int idx (int idx) const
 
T getValue () const
 
void setValue (T t) const
 Sets the voxel we are currently pointing to the given value. More...
 
bool isTileConstant () const
 Returns true if the tile we are currently in is a constant tile. More...
 
void getTileVoxels (UT_Vector3I &start, UT_Vector3I &end) const
 This tile will iterate over the voxels indexed [start,end). More...
 
UT_BoundingBoxI getTileBBox () const
 
bool isStartOfTile () const
 Returns true if we are at the start of a new tile. More...
 
UT_VoxelTile< T > * getTile () const
 Returns the VoxelTile we are currently processing. More...
 
int getLinearTileNum () const
 
void advanceTile ()
 
void skipToEndOfTile ()
 
bool getCompressOnExit () const
 
void setCompressOnExit (bool shouldcompress)
 
template<typename OP >
void applyOperation (OP &op)
 
template<typename OP , typename S >
void applyOperation (OP &op, const UT_VoxelArray< S > &a)
 
template<typename OP >
void applyOperation (OP &op, T a)
 
template<typename OP , typename S , typename R >
void applyOperation (OP &op, const UT_VoxelArray< S > &a, const UT_VoxelArray< R > &b)
 
template<typename OP , typename S , typename R , typename Q >
void applyOperation (OP &op, const UT_VoxelArray< S > &a, const UT_VoxelArray< R > &b, const UT_VoxelArray< Q > &c)
 
template<typename OP , typename S >
void applyOperationCheckNoop (OP &op, const UT_VoxelArray< S > &a)
 
template<typename OP >
void applyOperationCheckNoop (OP &op, T a)
 
template<typename OP , typename M >
void maskedApplyOperation (OP &op, const UT_VoxelArray< M > &mask)
 
template<typename OP , typename S , typename M >
void maskedApplyOperation (OP &op, const UT_VoxelArray< S > &a, const UT_VoxelArray< M > &mask)
 
template<typename OP , typename S , typename R , typename M >
void maskedApplyOperation (OP &op, const UT_VoxelArray< S > &a, const UT_VoxelArray< R > &b, const UT_VoxelArray< M > &mask)
 
template<typename OP , typename S , typename R , typename Q , typename M >
void maskedApplyOperation (OP &op, const UT_VoxelArray< S > &a, const UT_VoxelArray< R > &b, const UT_VoxelArray< Q > &c, const UT_VoxelArray< M > &mask)
 
template<typename OP , typename S >
void assignOperation (OP &op, const UT_VoxelArray< S > &a)
 
template<typename OP , typename S , typename R >
void assignOperation (OP &op, const UT_VoxelArray< S > &a, const UT_VoxelArray< R > &b)
 
template<typename OP , typename S , typename R , typename Q >
void assignOperation (OP &op, const UT_VoxelArray< S > &a, const UT_VoxelArray< R > &b, const UT_VoxelArray< Q > &c)
 
template<typename OP , typename S , typename M >
void maskedAssignOperation (OP &op, const UT_VoxelArray< S > &a, const UT_VoxelArray< M > &mask)
 
template<typename OP , typename S , typename R , typename M >
void maskedAssignOperation (OP &op, const UT_VoxelArray< S > &a, const UT_VoxelArray< R > &b, const UT_VoxelArray< M > &mask)
 
template<typename OP , typename S , typename R , typename Q , typename M >
void maskedAssignOperation (OP &op, const UT_VoxelArray< S > &a, const UT_VoxelArray< R > &b, const UT_VoxelArray< Q > &c, const UT_VoxelArray< M > &mask)
 
template<typename OP >
void reduceOperation (OP &op)
 
UT_VoxelArray< T > * getArray () const
 

Public Attributes

int myCurTile
 Our current linear tile idx. A value of -1 implies at end. More...
 
int myCurTileListIdx
 Our current index into the tile list. More...
 
int myTileStart
 
int myTileEnd
 
int myTilePos [3]
 Which tile we are as per tx,ty,tz rather than linear index. More...
 
int myTileLocalPos [3]
 Our position within the current tile. More...
 
int myTileSize [3]
 The size of the current tile. More...
 
const UT_JobInfomyJobInfo
 The job info to use for tilefetching. More...
 
UT_InterruptmyInterrupt
 

Protected Attributes

UT_VoxelArray< T > * myArray
 The array we belong to. More...
 
UT_COWReadHandle
< UT_VoxelArray< T > > 
myHandle
 
int myPos [3]
 Absolute index into voxel array. More...
 
bool myShouldCompressOnExit
 
bool myUseTileList
 
UT_IntArray myTileList
 

Detailed Description

template<typename T>
class UT_VoxelArrayIterator< T >

Iterator for Voxel Arrays

This class eliminates the need for having for (z = 0; z < zres; z++) ... for (x = 0; x < xres; x++) loops everywhere.

Note that the order of iteration is undefined! (The actual order is to complete each tile in turn, thereby hopefully improving cache coherency)

It is safe to write to the voxel array while this iterator is active. It is not safe to resize the voxel array (or destroy it)

The iterator is similar in principal to an STL iterator, but somewhat simpler. The classic STL loop for ( it = begin(); it != end(); ++it ) is done using for ( it.rewind(); !it.atEnd(); it.advance() )

Examples:
field3d/f3d_io.C, and SIM/SIM_GasAdd.C.

Definition at line 1584 of file UT_VoxelArray.h.

Constructor & Destructor Documentation

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

Definition at line 6454 of file UT_VoxelArray.C.

template<typename T >
UT_VoxelArrayIterator< T >::UT_VoxelArrayIterator ( UT_VoxelArray< T > *  vox)

Definition at line 6466 of file UT_VoxelArray.C.

template<typename T >
UT_VoxelArrayIterator< T >::UT_VoxelArrayIterator ( UT_COWReadHandle< UT_VoxelArray< T > >  handle)

Definition at line 6476 of file UT_VoxelArray.C.

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

Definition at line 6486 of file UT_VoxelArray.C.

Member Function Documentation

template<typename T>
void UT_VoxelArrayIterator< T >::advance ( )
inline

Advances the iterator to point to the next voxel.

Examples:
field3d/f3d_io.C, and SIM/SIM_GasAdd.C.

Definition at line 1678 of file UT_VoxelArray.h.

template<typename T >
void UT_VoxelArrayIterator< T >::advanceTile ( )

Advances the iterator to point to the next tile. Useful if the constant test showed that you didn't need to deal with this one.

Definition at line 6724 of file UT_VoxelArray.C.

template<typename T >
template<typename OP >
void UT_VoxelArrayIterator< T >::applyOperation ( OP &  op)

These templated algorithms are designed to apply simple operations across all of the voxels with as little overhead as possible. The iterator should already point to a voxel array and if multithreaded had its partial range set. The source arrays must be matching size. The operator should support a () operator, and the result is vit.setValue( op(vit.getValue(), a->getValue(vit), ...); Passing T instead of UT_VoxelArray will treat it as a constant source Note if both source and destination tiles are constant, only a single operation is invoked.

Definition at line 7232 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S >
void UT_VoxelArrayIterator< T >::applyOperation ( OP &  op,
const UT_VoxelArray< S > &  a 
)

Definition at line 7241 of file UT_VoxelArray.C.

template<typename T >
template<typename OP >
void UT_VoxelArrayIterator< T >::applyOperation ( OP &  op,
T  a 
)

Definition at line 6855 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S , typename R >
void UT_VoxelArrayIterator< T >::applyOperation ( OP &  op,
const UT_VoxelArray< S > &  a,
const UT_VoxelArray< R > &  b 
)

Definition at line 7253 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S , typename R , typename Q >
void UT_VoxelArrayIterator< T >::applyOperation ( OP &  op,
const UT_VoxelArray< S > &  a,
const UT_VoxelArray< R > &  b,
const UT_VoxelArray< Q > &  c 
)

Definition at line 7267 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S >
void UT_VoxelArrayIterator< T >::applyOperationCheckNoop ( OP &  op,
const UT_VoxelArray< S > &  a 
)

These variants will invoke op.isNoop(a, b, ...) which will return true if those values won't affect the destination. This allows constant source tiles to be skipped, for example when adding 0.

Definition at line 6898 of file UT_VoxelArray.C.

template<typename T >
template<typename OP >
void UT_VoxelArrayIterator< T >::applyOperationCheckNoop ( OP &  op,
T  a 
)

Definition at line 6999 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S >
void UT_VoxelArrayIterator< T >::assignOperation ( OP &  op,
const UT_VoxelArray< S > &  a 
)

Assign operation works like apply operation, but *this is written to without reading, so there is one less parameter to the () callback. This can optimize constant tile writes as the constant() status of the destination doesn't matter.

Definition at line 7343 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S , typename R >
void UT_VoxelArrayIterator< T >::assignOperation ( OP &  op,
const UT_VoxelArray< S > &  a,
const UT_VoxelArray< R > &  b 
)

Definition at line 7355 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S , typename R , typename Q >
void UT_VoxelArrayIterator< T >::assignOperation ( OP &  op,
const UT_VoxelArray< S > &  a,
const UT_VoxelArray< R > &  b,
const UT_VoxelArray< Q > &  c 
)

Definition at line 7369 of file UT_VoxelArray.C.

template<typename T>
bool UT_VoxelArrayIterator< T >::atEnd ( ) const
inline

Returns true if we have iterated over all of the voxels.

Examples:
field3d/f3d_io.C, and SIM/SIM_GasAdd.C.

Definition at line 1674 of file UT_VoxelArray.h.

template<typename T>
void UT_VoxelArrayIterator< T >::detectInterrupts ( )
inline

Definition at line 1656 of file UT_VoxelArray.h.

template<typename T>
UT_VoxelArray<T>* UT_VoxelArrayIterator< T >::getArray ( ) const
inline

Definition at line 1895 of file UT_VoxelArray.h.

template<typename T>
bool UT_VoxelArrayIterator< T >::getCompressOnExit ( ) const
inline

Sets a flag which causes the iterator to tryCompress() tiles when it is done with them.

Definition at line 1806 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelArrayIterator< T >::getLinearTileNum ( ) const
inline

Definition at line 1788 of file UT_VoxelArray.h.

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

Returns the VoxelTile we are currently processing.

Examples:
SIM/SIM_GasAdd.C.

Definition at line 1783 of file UT_VoxelArray.h.

template<typename T>
UT_BoundingBoxI UT_VoxelArrayIterator< T >::getTileBBox ( ) const
inline

This tile will iterate over the inclusive voxels indexed in the returned boudning box.

Definition at line 1769 of file UT_VoxelArray.h.

template<typename T>
void UT_VoxelArrayIterator< T >::getTileVoxels ( UT_Vector3I start,
UT_Vector3I end 
) const
inline

This tile will iterate over the voxels indexed [start,end).

Definition at line 1756 of file UT_VoxelArray.h.

template<typename T>
T UT_VoxelArrayIterator< T >::getValue ( ) const
inline

Retrieves the value that we are currently pointing at. This is faster than an operator(x,y,z) as we already know our current tile and that bounds checking isn't needed.

Examples:
field3d/f3d_io.C, and SIM/SIM_GasAdd.C.

Definition at line 1718 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelArrayIterator< T >::idx ( int  idx) const
inline

Definition at line 1713 of file UT_VoxelArray.h.

template<typename T>
bool UT_VoxelArrayIterator< T >::isStartOfTile ( ) const
inline

Returns true if we are at the start of a new tile.

Examples:
SIM/SIM_GasAdd.C.

Definition at line 1777 of file UT_VoxelArray.h.

template<typename T>
bool UT_VoxelArrayIterator< T >::isTileConstant ( ) const
inline

Returns true if the tile we are currently in is a constant tile.

Examples:
SIM/SIM_GasAdd.C.

Definition at line 1745 of file UT_VoxelArray.h.

template<typename T >
template<typename OP , typename M >
void UT_VoxelArrayIterator< T >::maskedApplyOperation ( OP &  op,
const UT_VoxelArray< M > &  mask 
)

These variants of apply operation also accept a mask array. The operation is applied only where the mask is greater than 0.5.

Definition at line 7283 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S , typename M >
void UT_VoxelArrayIterator< T >::maskedApplyOperation ( OP &  op,
const UT_VoxelArray< S > &  a,
const UT_VoxelArray< M > &  mask 
)

Definition at line 7295 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S , typename R , typename M >
void UT_VoxelArrayIterator< T >::maskedApplyOperation ( OP &  op,
const UT_VoxelArray< S > &  a,
const UT_VoxelArray< R > &  b,
const UT_VoxelArray< M > &  mask 
)

Definition at line 7309 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S , typename R , typename Q , typename M >
void UT_VoxelArrayIterator< T >::maskedApplyOperation ( OP &  op,
const UT_VoxelArray< S > &  a,
const UT_VoxelArray< R > &  b,
const UT_VoxelArray< Q > &  c,
const UT_VoxelArray< M > &  mask 
)

Definition at line 7325 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S , typename M >
void UT_VoxelArrayIterator< T >::maskedAssignOperation ( OP &  op,
const UT_VoxelArray< S > &  a,
const UT_VoxelArray< M > &  mask 
)

These variants of assign operation also accept a mask array. The assignment operation is performed only where the mask is greater than 0.5.

Definition at line 7385 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S , typename R , typename M >
void UT_VoxelArrayIterator< T >::maskedAssignOperation ( OP &  op,
const UT_VoxelArray< S > &  a,
const UT_VoxelArray< R > &  b,
const UT_VoxelArray< M > &  mask 
)

Definition at line 7399 of file UT_VoxelArray.C.

template<typename T >
template<typename OP , typename S , typename R , typename Q , typename M >
void UT_VoxelArrayIterator< T >::maskedAssignOperation ( OP &  op,
const UT_VoxelArray< S > &  a,
const UT_VoxelArray< R > &  b,
const UT_VoxelArray< Q > &  c,
const UT_VoxelArray< M > &  mask 
)

Definition at line 7415 of file UT_VoxelArray.C.

template<typename T >
template<typename OP >
void UT_VoxelArrayIterator< T >::reduceOperation ( OP &  op)

Reduction operators. op.reduce(T a) called for each voxel, but, op.reduceMany(T a, int n) called to reduce constant blocks.

Definition at line 7433 of file UT_VoxelArray.C.

template<typename T >
void UT_VoxelArrayIterator< T >::restrictToBBox ( const UT_BoundingBox bbox)

Restricts this iterator to the tiles that intersect the given bounding box of voxel coordinates. Note that this will not be a precise restriction as each tile is either included or not. You should setPartialRange() after setting the bbox range The bounding box is on the [0..1]^3 range.

Definition at line 6569 of file UT_VoxelArray.C.

template<typename T >
void UT_VoxelArrayIterator< T >::restrictToBBox ( int  xmin,
int  xmax,
int  ymin,
int  ymax,
int  zmin,
int  zmax 
)

The [xmin, xmax] are inclusive and measured in voxels.

Definition at line 6593 of file UT_VoxelArray.C.

template<typename T >
void UT_VoxelArrayIterator< T >::rewind ( )

Resets the iterator to point to the first voxel.

Examples:
field3d/f3d_io.C, and SIM/SIM_GasAdd.C.

Definition at line 6653 of file UT_VoxelArray.C.

template<typename T>
void UT_VoxelArrayIterator< T >::setArray ( UT_VoxelArray< T > *  vox)
inline
Examples:
field3d/f3d_io.C, and SIM/SIM_GasAdd.C.

Definition at line 1592 of file UT_VoxelArray.h.

template<typename T>
void UT_VoxelArrayIterator< T >::setCompressOnExit ( bool  shouldcompress)
inline
Examples:
field3d/f3d_io.C, and SIM/SIM_GasAdd.C.

Definition at line 1807 of file UT_VoxelArray.h.

template<typename T>
void UT_VoxelArrayIterator< T >::setConstArray ( const UT_VoxelArray< T > *  vox)
inline

Definition at line 1600 of file UT_VoxelArray.h.

template<typename T>
void UT_VoxelArrayIterator< T >::setHandle ( UT_COWReadHandle< UT_VoxelArray< T > >  handle)
inline

Iterates over the array pointed to by the handle. Only supports read access during the iteration as it does a read lock.

Examples:
field3d/f3d_io.C.

Definition at line 1608 of file UT_VoxelArray.h.

template<typename T>
void UT_VoxelArrayIterator< T >::setInterrupt ( UT_Interrupt interrupt)
inline

Assigns an interrupt handler. This will be tested whenever it advances to a new tile. If it is interrupted, the iterator will jump forward to atEnd()

Definition at line 1655 of file UT_VoxelArray.h.

template<typename T >
void UT_VoxelArrayIterator< T >::setPartialRange ( int  idx,
int  numranges 
)

Restricts this iterator to only run over a subset of the tiles. The tiles will be divided into approximately numrange equal groups, this will be the idx'th. The resulting iterator may have zero tiles.

Examples:
SIM/SIM_GasAdd.C.

Definition at line 6492 of file UT_VoxelArray.C.

template<typename T>
template<typename S >
void UT_VoxelArrayIterator< T >::setTile ( const UT_VoxelArrayIterator< S > &  vit,
UT_VoxelArray< T > *  array 
)
inline

Sets this iterator to run over the tile specified by the referenced iterator. This assumes the underlying arrays are matching.

Definition at line 1636 of file UT_VoxelArray.h.

template<typename T>
void UT_VoxelArrayIterator< T >::setTile ( const UT_VoxelArrayIterator< T > &  vit)
inline

Definition at line 1647 of file UT_VoxelArray.h.

template<typename T>
void UT_VoxelArrayIterator< T >::setValue ( T  t) const
inline

Sets the voxel we are currently pointing to the given value.

Examples:
field3d/f3d_io.C, and SIM/SIM_GasAdd.C.

Definition at line 1731 of file UT_VoxelArray.h.

template<typename T >
void UT_VoxelArrayIterator< T >::skipToEndOfTile ( )

Advances the iterator to pointing just before the next tile so the next advance() will be an advanceTile(). This is useful if you want to do a continue; as your break but the forloop is doing advance() Note the iterator is in a bad state until advance() is called.

Examples:
SIM/SIM_GasAdd.C.

Definition at line 6845 of file UT_VoxelArray.C.

template<typename T >
void UT_VoxelArrayIterator< T >::splitByTile ( const UT_JobInfo info)

Ties this iterator to the given jobinfo so it will match the jobinfo's processing.

Definition at line 6553 of file UT_VoxelArray.C.

template<typename T>
int UT_VoxelArrayIterator< T >::x ( ) const
inline

Retrieve the current location of the iterator.

Examples:
field3d/f3d_io.C.

Definition at line 1710 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelArrayIterator< T >::y ( ) const
inline
Examples:
field3d/f3d_io.C.

Definition at line 1711 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelArrayIterator< T >::z ( ) const
inline
Examples:
field3d/f3d_io.C.

Definition at line 1712 of file UT_VoxelArray.h.

Member Data Documentation

template<typename T>
UT_VoxelArray<T>* UT_VoxelArrayIterator< T >::myArray
protected

The array we belong to.

Definition at line 1899 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelArrayIterator< T >::myCurTile

Our current linear tile idx. A value of -1 implies at end.

Definition at line 1916 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelArrayIterator< T >::myCurTileListIdx

Our current index into the tile list.

Definition at line 1919 of file UT_VoxelArray.h.

template<typename T>
UT_COWReadHandle<UT_VoxelArray<T> > UT_VoxelArrayIterator< T >::myHandle
protected

The handle that we have locked to get our array. It is null by default which makes the lock/unlock nops.

Definition at line 1902 of file UT_VoxelArray.h.

template<typename T>
UT_Interrupt* UT_VoxelArrayIterator< T >::myInterrupt

Definition at line 1937 of file UT_VoxelArray.h.

template<typename T>
const UT_JobInfo* UT_VoxelArrayIterator< T >::myJobInfo

The job info to use for tilefetching.

Definition at line 1935 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelArrayIterator< T >::myPos[3]
protected

Absolute index into voxel array.

Definition at line 1905 of file UT_VoxelArray.h.

template<typename T>
bool UT_VoxelArrayIterator< T >::myShouldCompressOnExit
protected

Flag determining if we should compress tiles whenever we advance out of them.

Definition at line 1909 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelArrayIterator< T >::myTileEnd

Definition at line 1923 of file UT_VoxelArray.h.

template<typename T>
UT_IntArray UT_VoxelArrayIterator< T >::myTileList
protected

Definition at line 1912 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelArrayIterator< T >::myTileLocalPos[3]

Our position within the current tile.

Definition at line 1929 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelArrayIterator< T >::myTilePos[3]

Which tile we are as per tx,ty,tz rather than linear index.

Definition at line 1926 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelArrayIterator< T >::myTileSize[3]

The size of the current tile.

Definition at line 1932 of file UT_VoxelArray.h.

template<typename T>
int UT_VoxelArrayIterator< T >::myTileStart

Our start & end tiles for processing a subrange. The tile range is half open [start, end)

Definition at line 1923 of file UT_VoxelArray.h.

template<typename T>
bool UT_VoxelArrayIterator< T >::myUseTileList
protected

Definition at line 1911 of file UT_VoxelArray.h.


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