VTK  9.1.0
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
vtkArrayExtents Class Reference

Stores the number of dimensions and valid coordinate ranges along each dimension for vtkArray. More...

#include <vtkArrayExtents.h>

Public Types

typedef vtkArrayCoordinates::DimensionT DimensionT
 
typedef vtkArrayCoordinates::CoordinateT CoordinateT
 
typedef vtkTypeUInt64 SizeT
 

Public Member Functions

 vtkArrayExtents ()
 Create zero-dimensional extents. More...
 
 vtkArrayExtents (const CoordinateT i)
 Create zero-based one-dimensional extents. More...
 
 vtkArrayExtents (const vtkArrayRange &i)
 Create one-dimensional extents. More...
 
 vtkArrayExtents (const CoordinateT i, const CoordinateT j)
 Create zero-based two-dimensional extents. More...
 
 vtkArrayExtents (const vtkArrayRange &i, const vtkArrayRange &j)
 Create two-dimensional extents. More...
 
 vtkArrayExtents (const CoordinateT i, const CoordinateT j, const CoordinateT k)
 Create zero-based three-dimensional extents. More...
 
 vtkArrayExtents (const vtkArrayRange &i, const vtkArrayRange &j, const vtkArrayRange &k)
 Create three-dimensional extents. More...
 
void Append (const vtkArrayRange &extent)
 Grow the number of dimensions by one, specifying the extent of the new dimension. More...
 
DimensionT GetDimensions () const
 Return the current number of dimensions. More...
 
SizeT GetSize () const
 Return the number of values that could be stored using the current extents. More...
 
void SetDimensions (DimensionT dimensions)
 Set the current number of dimensions. More...
 
vtkArrayRangeoperator[] (DimensionT i)
 Accesses the extent of the i-th dimension. More...
 
const vtkArrayRangeoperator[] (DimensionT i) const
 Accesses the extent of the i-th dimension. More...
 
vtkArrayRange GetExtent (DimensionT i) const
 Get the extent of the i-th dimension. More...
 
void SetExtent (DimensionT i, const vtkArrayRange &)
 Set the extent of the i-th dimension. More...
 
bool operator== (const vtkArrayExtents &rhs) const
 Equality comparison. More...
 
bool operator!= (const vtkArrayExtents &rhs) const
 Inequality comparison. More...
 
bool ZeroBased () const
 Returns true iff every range in the current extents is zero-based. More...
 
bool SameShape (const vtkArrayExtents &rhs) const
 Returns true iff the given extents have the same number of dimensions and size along each dimension. More...
 
void GetLeftToRightCoordinatesN (SizeT n, vtkArrayCoordinates &coordinates) const
 Returns coordinates that reference the n-th value in the extents, where n is in the range [0, GetSize()). More...
 
void GetRightToLeftCoordinatesN (SizeT n, vtkArrayCoordinates &coordinates) const
 Returns coordinates that reference the n-th value in the extents, where n is in the range [0, GetSize()). More...
 
bool Contains (const vtkArrayExtents &extents) const
 Returns true if the given extents are a non-overlapping subset of the current extents. More...
 
bool Contains (const vtkArrayCoordinates &coordinates) const
 Returns true if the given array coordinates are completely contained by the current extents (i.e. More...
 

Static Public Member Functions

static vtkArrayExtents Uniform (DimensionT n, CoordinateT m)
 Create n-dimensional extents with extent [0, m) along each dimension. More...
 

Friends

VTKCOMMONCORE_EXPORT friend ostream & operator<< (ostream &stream, const vtkArrayExtents &rhs)
 

Detailed Description

Stores the number of dimensions and valid coordinate ranges along each dimension for vtkArray.

vtkArrayExtents describes the number of dimensions and coordinate ranges along each dimension of an N-way collection of values. It is used to retrieve and update the extents of a vtkArray object.

Conceptually, vtkArrayExtents is a collection of vtkArrayRange objects, one per dimension, that store the half-open range of valid coordinates (the "extent") for that dimension. Because each extent is stored as a range rather than a size, you can: create arrays that use one-based coordinates for consistency with mathematics and tools such as MATLAB; easily represent arbitrary subsets of an array; and easily store and manipulate distributed arrays using "global" coordinates.

Convenience constructors are provided for creating extents along one, two, and three dimensions. For higher dimensions, you can:

Use the static Uniform() factory method to create extents that have the same size along an arbitrary number of dimensions.

Use the default constructor and the Append() method to "grow" your extents to the correct number of dimensions.

Use the default constructuor, SetDimensions() and operator[] to assign a size along each dimension.

See also
vtkArray, vtkArrayRange, vtkArrayCoordinates
Thanks:
Developed by Timothy M. Shead (tshea.nosp@m.d@sa.nosp@m.ndia..nosp@m.gov) at Sandia National Laboratories.

Definition at line 68 of file vtkArrayExtents.h.

Member Typedef Documentation

◆ DimensionT

Definition at line 71 of file vtkArrayExtents.h.

◆ CoordinateT

Definition at line 72 of file vtkArrayExtents.h.

◆ SizeT

typedef vtkTypeUInt64 vtkArrayExtents::SizeT

Definition at line 73 of file vtkArrayExtents.h.

Constructor & Destructor Documentation

◆ vtkArrayExtents() [1/7]

vtkArrayExtents::vtkArrayExtents ( )

Create zero-dimensional extents.

◆ vtkArrayExtents() [2/7]

vtkArrayExtents::vtkArrayExtents ( const CoordinateT  i)
explicit

Create zero-based one-dimensional extents.

This constructor is shorthand for vtkArrayExtents(vtkArrayRange(0, i)).

◆ vtkArrayExtents() [3/7]

vtkArrayExtents::vtkArrayExtents ( const vtkArrayRange i)
explicit

Create one-dimensional extents.

◆ vtkArrayExtents() [4/7]

vtkArrayExtents::vtkArrayExtents ( const CoordinateT  i,
const CoordinateT  j 
)

Create zero-based two-dimensional extents.

This constructor is shorthand for vtkArrayExtents(vtkArrayRange(0, i), vtkArrayRange(0, j)).

◆ vtkArrayExtents() [5/7]

vtkArrayExtents::vtkArrayExtents ( const vtkArrayRange i,
const vtkArrayRange j 
)

Create two-dimensional extents.

◆ vtkArrayExtents() [6/7]

vtkArrayExtents::vtkArrayExtents ( const CoordinateT  i,
const CoordinateT  j,
const CoordinateT  k 
)

Create zero-based three-dimensional extents.

This constructor is shorthand for vtkArrayExtents(vtkArrayRange(0, i), vtkArrayRange(0, j), vtkArrayRange(0, k)).

◆ vtkArrayExtents() [7/7]

vtkArrayExtents::vtkArrayExtents ( const vtkArrayRange i,
const vtkArrayRange j,
const vtkArrayRange k 
)

Create three-dimensional extents.

Member Function Documentation

◆ Uniform()

static vtkArrayExtents vtkArrayExtents::Uniform ( DimensionT  n,
CoordinateT  m 
)
static

Create n-dimensional extents with extent [0, m) along each dimension.

This is useful for creating e.g: a square matrix.

◆ Append()

void vtkArrayExtents::Append ( const vtkArrayRange extent)

Grow the number of dimensions by one, specifying the extent of the new dimension.

◆ GetDimensions()

DimensionT vtkArrayExtents::GetDimensions ( ) const

Return the current number of dimensions.

◆ GetSize()

SizeT vtkArrayExtents::GetSize ( ) const

Return the number of values that could be stored using the current extents.

This is equal to the product of the size of the extent along each dimension.

◆ SetDimensions()

void vtkArrayExtents::SetDimensions ( DimensionT  dimensions)

Set the current number of dimensions.

Note that this method resets the extent along each dimension to an empty range, so you must assign each dimension's extent explicitly using operator[] after calling SetDimensions().

◆ operator[]() [1/2]

vtkArrayRange & vtkArrayExtents::operator[] ( DimensionT  i)

Accesses the extent of the i-th dimension.

◆ operator[]() [2/2]

const vtkArrayRange & vtkArrayExtents::operator[] ( DimensionT  i) const

Accesses the extent of the i-th dimension.

◆ GetExtent()

vtkArrayRange vtkArrayExtents::GetExtent ( DimensionT  i) const

Get the extent of the i-th dimension.

◆ SetExtent()

void vtkArrayExtents::SetExtent ( DimensionT  i,
const vtkArrayRange  
)

Set the extent of the i-th dimension.

◆ operator==()

bool vtkArrayExtents::operator== ( const vtkArrayExtents rhs) const

Equality comparison.

◆ operator!=()

bool vtkArrayExtents::operator!= ( const vtkArrayExtents rhs) const

Inequality comparison.

◆ ZeroBased()

bool vtkArrayExtents::ZeroBased ( ) const

Returns true iff every range in the current extents is zero-based.

This is useful as a precondition test for legacy filters/operations that predate the switch to range-based extents and assume that all extents are zero-based. In general, new code should be written to work with arbitrary range extents, so won't need to perform this check.

◆ SameShape()

bool vtkArrayExtents::SameShape ( const vtkArrayExtents rhs) const

Returns true iff the given extents have the same number of dimensions and size along each dimension.

Note that the ranges along each dimension may have different values, so long as their sizes match.

◆ GetLeftToRightCoordinatesN()

void vtkArrayExtents::GetLeftToRightCoordinatesN ( SizeT  n,
vtkArrayCoordinates coordinates 
) const

Returns coordinates that reference the n-th value in the extents, where n is in the range [0, GetSize()).

The returned coordinates will be ordered so that the left-most indices vary fastest. This is equivalent to column-major ordering for matrices, and corresponds to the order in which consecutive array values would be stored in languages such as Fortran, MATLAB, Octave, and R.

◆ GetRightToLeftCoordinatesN()

void vtkArrayExtents::GetRightToLeftCoordinatesN ( SizeT  n,
vtkArrayCoordinates coordinates 
) const

Returns coordinates that reference the n-th value in the extents, where n is in the range [0, GetSize()).

The returned coordinates will be ordered so that the right-most indices vary fastest. This is equivalent to row-major ordering for matrices, and corresponds to the order in which consecutive array values would be stored in languages including C and C++.

◆ Contains() [1/2]

bool vtkArrayExtents::Contains ( const vtkArrayExtents extents) const

Returns true if the given extents are a non-overlapping subset of the current extents.

Returns false if any of the given extents fall outside the current extents, or there is a mismatch in the number of dimensions.

◆ Contains() [2/2]

bool vtkArrayExtents::Contains ( const vtkArrayCoordinates coordinates) const

Returns true if the given array coordinates are completely contained by the current extents (i.e.

extent begin <= coordinate and coordinate < extent end along every dimension). Returns false if the array coordinates are outside the current extents, or contain a different number of dimensions.

Friends And Related Function Documentation

◆ operator<<

VTKCOMMONCORE_EXPORT friend ostream & operator<< ( ostream &  stream,
const vtkArrayExtents rhs 
)
friend

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