| IOLink 1.11.0

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
iolink::Region< T, N > Class Template Referencefinal

A multi-dimensional region defined by its origin and its size. More...

`#include <iolink/Region.h>`

## Public Types
using | VectorType = Vector< T, N >
using | SizeType = Vector< T, N >

## Public Member Functions
| Region ()
| Create an empty region.
| Region (const VectorType &origin, const SizeType &size)
| Create a region with given origin and size.
template<typename U , size_t P>
| Region (const Region< U, P > &other)
| Build a region from another of different dimension and different type.
size_t | dimensionCount () const
| Return number of dimension of this region.
const VectorType & | origin () const
| Return region's origin.
const SizeType & | size () const
| return size of region
size_t | elementCount () const
| Return number of elements (pixel, voxel, samples) contained in the region.
VectorType | min () const
| return min region coordinates
VectorType | max () const
| return max region coordinates
bool | isEmpty () const
| Indicates if region is empty.
bool | contains (const Region &other) const
| Returns if the current region contains the given one.
bool | contains (const VectorType &position) const
| Returns if the given region contains the given position vector.
bool | intersect (const Region &other) const
| Returns if the given region intersects the given position vector.
Region | intersection (const Region &other) const
| Returns the intersection region between current and given one.
Region | extractSliceFromAxis (size_t dimension, T origin) const
| Returns a region of size one along one axis.
bool | operator== (const Region &other) const
| Returns the intersection region between current and given one.
| Region (const RegionX< T > &other)
| operator RegionX< T > () const
std::string | toString () const
| Return a string representation.

## Detailed Description

template<typename T, size_t N>
class iolink::Region< T, N >

A multi-dimensional region defined by its origin and its size.

Origin is always the left-bottom corner of the region.

Template Parameters

  T | The type of region indexers
  N | The dimension of the region.

Region definition is different according to its indexer type. Float-indexed-regions are defined from origin point (Org) to Max = Org + region size. Integer-indexed-regions are defined from Org to Max = Org + region size - 1

Up-boundaries are not included for integer-indexers-regions (except when size is 0 and region is a point).

Up-boundaries are included for float-indexers-regions.

Aliases can be used to made this class more practical to use. They use the following convention: RegionNX

Where N is the dimension and X the type. The types currently available are:

- F for single precision floats.
- D for double precision floats.
- U64 for uint64_t.

Examples:

- Region2u64: 2 dimensional uint64_t region.

## Constructor & Destructor Documentation

## ◆ Region() [1/2]

template<typename T , size_t N>

iolink::Region< T, N >::Region | ( | const VectorType & | origin,
|  | const SizeType & | size
| ) |  |

Create a region with given origin and size.

Parameters

  origin | vector containing region origin
  size | vector containing region size

## ◆ Region() [2/2]

template<typename T , size_t N>
template<typename U , size_t P>

iolink::Region< T, N >::Region | ( | const Region< U, P > & | other | ) |
| inline explicit

Build a region from another of different dimension and different type.

If dimension of other is smaller than dimension of region (ex. creating a 3D region from a 2D region) behavior is as follow:

- For Integer-indexed-regions, origin is set to 0 and size is set to 1. i.e, if creating a 3D volume from a 2D slice, resulting region will be ({x, y, 0}, {sizeX, sizeY, 1})
- For Float-indexed-regions, origin is set to 0 and size is set to 0. i.e, if creating a 3D volume from a 2D slice, resulting region will be ({x, y, 0}, {sizeX, sizeY, 0})

## Member Function Documentation

## ◆ contains() [1/2]

template<typename T , size_t N>

bool iolink::Region< T, N >::contains | ( | const Region< T, N > & | other | ) | const

Returns if the current region contains the given one.

Parameters

  other | region to test if it is contained into current one

Returns
  if the given region is contained into current one

## ◆ contains() [2/2]

template<typename T , size_t N>

bool iolink::Region< T, N >::contains | ( | const VectorType & | position | ) | const

Returns if the given region contains the given position vector.

Parameters

  position | point to test if it is contained into current one

Returns
  if the given position is contained into current region

## ◆ elementCount()

template<typename T , size_t N>

size_t iolink::Region< T, N >::elementCount | ( |  | ) | const

Return number of elements (pixel, voxel, samples) contained in the region.

For Integer-indexed-regions, it return product of each dimensions. This method has no sense for Float-indexed-regions and thus return 0

## ◆ extractSliceFromAxis()

template<typename T , size_t N>

Region iolink::Region< T, N >::extractSliceFromAxis | ( | size_t | dimension,
|  | T | origin
| ) |  | const

Returns a region of size one along one axis.

Parameters

  dimension | axis on which the slice must be selected
  origin | position of slice in given dimension

Returns
  the slice at given position for given dimension

Exceptions

  InvalidArgument | if dimension or origin are out of range

e.g. a 3D region {{0, 0, 0}, {5, 6, 7}}

- extractSliceFromAxis(0, 3) returns 3D region {{3, 0, 0}, {1, 6, 7}}
- extractSliceFromAxis(1, 4) returns 3D region {{0, 4, 0}, {5, 1, 7}}
- extractSliceFromAxis(2, 5) returns 3D region {{0, 0, 5}, {5, 6, 1}}

e.g. a 3D region with non-null origin { {2, 3, 4}, {5, 6, 7}}

extractSliceFromAxis(0, 3) returns 3D region {{5, 3, 4}, {1, 6, 7}}

## ◆ intersect()

template<typename T , size_t N>

bool iolink::Region< T, N >::intersect | ( | const Region< T, N > & | other | ) | const

Returns if the given region intersects the given position vector.

Parameters

  other | region to test if it intersects with current one

Returns
  if the given region intersects current region

## ◆ intersection()

template<typename T , size_t N>

Region iolink::Region< T, N >::intersection | ( | const Region< T, N > & | other | ) | const

Returns the intersection region between current and given one.

Parameters

  other | region

Returns
  intersection region if it intersects or empty region otherwise

## ◆ isEmpty()

template<typename T , size_t N>

bool iolink::Region< T, N >::isEmpty | ( |  | ) | const

Indicates if region is empty.

Returns
  if region is empty

## ◆ max()

template<typename T , size_t N>

VectorType iolink::Region< T, N >::max | ( |  | ) | const

return max region coordinates

Returns
  max region vector

## ◆ min()

template<typename T , size_t N>

VectorType iolink::Region< T, N >::min | ( |  | ) | const
| inline

return min region coordinates

Returns
  min region vector

## ◆ operator==()

template<typename T , size_t N>

bool iolink::Region< T, N >::operator== | ( | const Region< T, N > & | other | ) | const

Returns the intersection region between current and given one.

Parameters

  other | region

Returns
  if current region and given one are identical (same origin if both null size, same origin and size otherwise)

## ◆ size()

template<typename T , size_t N>

const SizeType & iolink::Region< T, N >::size | ( |  | ) | const
| inline

return size of region

Returns
  size vector of the region

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

- iolink/public/include/iolink/Region.h