Field3D
SparseField< Data_T >::block_iterator Class Reference

#include <SparseField.h>

Public Types

typedef SparseField< Data_T > class_type
 Convenience typedef. More...
 

Public Member Functions

 block_iterator (const class_type &field, const Box3i &window, const V3i &currentPos)
 Constructor. More...
 
const Box3iblockBoundingBox ()
 Returns a reference to the bounding box representing the current block. More...
 
bool operator!= (const block_iterator &rhs) const
 Inequality check. More...
 
const block_iteratoroperator++ ()
 Increment iterator. More...
 
bool operator== (const block_iterator &rhs) const
 Equality check. More...
 

Public Attributes

int x
 Current block index. More...
 
int y
 
int z
 

Private Member Functions

void recomputeBlockBoundingBox ()
 

Private Attributes

Box3i m_currentBlockWindow
 Bounding box in voxel coordinates for the current block. More...
 
const class_typem_field
 Pointer to field we're traversing. More...
 
Box3i m_window
 Bounding box for block indices. More...
 

Detailed Description

template<class Data_T>
class SparseField< Data_T >::block_iterator

Note
This iterator type can not be dereferenced. It's only used to provide a bounding box and indices for each block.

Definition at line 1213 of file SparseField.h.

Member Typedef Documentation

◆ class_type

template<class Data_T >
typedef SparseField<Data_T> SparseField< Data_T >::block_iterator::class_type

Convenience typedef.

Definition at line 1217 of file SparseField.h.

Constructor & Destructor Documentation

◆ block_iterator()

template<class Data_T >
SparseField< Data_T >::block_iterator::block_iterator ( const class_type field,
const Box3i window,
const V3i currentPos 
)
inline

Constructor.

Definition at line 1219 of file SparseField.h.

1221  : x(currentPos.x), y(currentPos.y), z(currentPos.z),
1222  m_window(window), m_field(field)
1223  {
1225  }

Member Function Documentation

◆ operator++()

template<class Data_T >
const block_iterator& SparseField< Data_T >::block_iterator::operator++ ( )
inline

Increment iterator.

Definition at line 1227 of file SparseField.h.

1228  {
1229  if (x == m_window.max.x) {
1230  if (y == m_window.max.y) {
1231  x = m_window.min.x;
1232  y = m_window.min.y;
1233  ++z;
1234  } else {
1235  x = m_window.min.x;
1236  ++y;
1237  }
1238  } else {
1239  ++x;
1240  }
1242  return *this;
1243  }

References SparseField< Data_T >::block_iterator::x.

◆ operator==()

template<class Data_T >
bool SparseField< Data_T >::block_iterator::operator== ( const block_iterator rhs) const
inline

Equality check.

Definition at line 1245 of file SparseField.h.

1246  {
1247  return x == rhs.x && y == rhs.y && z == rhs.z;
1248  }

References SparseField< Data_T >::block_iterator::x, SparseField< Data_T >::block_iterator::y, and SparseField< Data_T >::block_iterator::z.

◆ operator!=()

template<class Data_T >
bool SparseField< Data_T >::block_iterator::operator!= ( const block_iterator rhs) const
inline

Inequality check.

Definition at line 1250 of file SparseField.h.

1251  {
1252  return x != rhs.x || y != rhs.y || z != rhs.z;
1253  }

References SparseField< Data_T >::block_iterator::x, SparseField< Data_T >::block_iterator::y, and SparseField< Data_T >::block_iterator::z.

◆ blockBoundingBox()

template<class Data_T >
const Box3i& SparseField< Data_T >::block_iterator::blockBoundingBox ( )
inline

Returns a reference to the bounding box representing the current block.

Definition at line 1255 of file SparseField.h.

1256  {
1257  return m_currentBlockWindow;
1258  }

◆ recomputeBlockBoundingBox()

template<class Data_T >
void SparseField< Data_T >::block_iterator::recomputeBlockBoundingBox ( )
inlineprivate

Definition at line 1262 of file SparseField.h.

1263  {
1264  Box3i box;
1265  int blockSize = m_field.blockSize();
1266  box.min = V3i(x * blockSize, y * blockSize, z * blockSize);
1267  box.max = box.min + V3i(blockSize - 1, blockSize - 1, blockSize - 1);
1268  // Clamp the box
1269  box.min = FIELD3D_CLIP(box.min, m_field.dataWindow());
1270  box.max = FIELD3D_CLIP(box.max, m_field.dataWindow());
1271  // Set the member variable
1272  m_currentBlockWindow = box;
1273  }

References SparseField< Data_T >::blockSize(), and FIELD3D_CLIP.

Member Data Documentation

◆ x

template<class Data_T >
int SparseField< Data_T >::block_iterator::x

◆ y

template<class Data_T >
int SparseField< Data_T >::block_iterator::y

◆ z

template<class Data_T >
int SparseField< Data_T >::block_iterator::z

◆ m_window

template<class Data_T >
Box3i SparseField< Data_T >::block_iterator::m_window
private

Bounding box for block indices.

Definition at line 1275 of file SparseField.h.

◆ m_field

template<class Data_T >
const class_type& SparseField< Data_T >::block_iterator::m_field
private

Pointer to field we're traversing.

Definition at line 1277 of file SparseField.h.

◆ m_currentBlockWindow

template<class Data_T >
Box3i SparseField< Data_T >::block_iterator::m_currentBlockWindow
private

Bounding box in voxel coordinates for the current block.

Definition at line 1279 of file SparseField.h.


The documentation for this class was generated from the following file:
FieldRes::dataWindow
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
Definition: Field.h:253
V3i
Imath::V3i V3i
Definition: SpiMathLib.h:71
SparseField::block_iterator::x
int x
Current block index.
Definition: SparseField.h:1260
SparseField::block_iterator::recomputeBlockBoundingBox
void recomputeBlockBoundingBox()
Definition: SparseField.h:1262
FIELD3D_CLIP
#define FIELD3D_CLIP
Definition: SpiMathLib.h:90
SparseField::block_iterator::z
int z
Definition: SparseField.h:1260
SparseField::block_iterator::m_currentBlockWindow
Box3i m_currentBlockWindow
Bounding box in voxel coordinates for the current block.
Definition: SparseField.h:1279
SparseField::block_iterator::y
int y
Definition: SparseField.h:1260
SparseField::block_iterator::m_window
Box3i m_window
Bounding box for block indices.
Definition: SparseField.h:1275
Box3i
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
SparseField::blockSize
int blockSize() const
Returns the block size.
Definition: SparseField.h:1483
SparseField::block_iterator::m_field
const class_type & m_field
Pointer to field we're traversing.
Definition: SparseField.h:1277