27#ifndef vtkPixelExtent_h
28#define vtkPixelExtent_h
30#include "vtkCommonDataModelModule.h"
52 this->SetData(T(0), width - T(1), T(0),
height - T(1));
63 const int&
operator[](
int i)
const {
return this->Data[i]; }
71 void SetData(
const T* ext);
74 void SetData(T ilo, T ihi, T jlo, T jhi);
81 const int*
GetData()
const {
return this->Data; }
86 unsigned int*
GetDataU() {
return reinterpret_cast<unsigned int*
>(this->Data); }
88 const unsigned int*
GetDataU()
const {
return reinterpret_cast<const unsigned int*
>(this->Data); }
94 void GetStartIndex(
int first[2])
const;
95 void GetStartIndex(
int first[2],
const int origin[2])
const;
96 void GetEndIndex(
int last[2])
const;
114 int Contains(
int i,
int j)
const;
125 template <
typename T>
126 void Size(T nCells[2])
const;
148 void Grow(
int q,
int n);
149 void GrowLow(
int q,
int n);
150 void GrowHigh(
int q,
int n);
158 void Shrink(
int q,
int n);
179 void Shift(
int q,
int n);
200 template <
typename T>
272 static void Merge(std::deque<vtkPixelExtent>& exts);
281VTKCOMMONDATAMODEL_EXPORT
288 Data[0] =
static_cast<int>(ext[0]);
289 Data[1] =
static_cast<int>(ext[1]);
290 Data[2] =
static_cast<int>(ext[2]);
291 Data[3] =
static_cast<int>(ext[3]);
298 T ext[4] = { ilo, ihi, jlo, jhi };
312 data[0] =
static_cast<T
>(this->Data[0]);
313 data[1] =
static_cast<T
>(this->Data[1]);
314 data[2] =
static_cast<T
>(this->Data[2]);
315 data[3] =
static_cast<T
>(this->Data[3]);
321 this->SetData<int>(INT_MAX, INT_MIN, INT_MAX, INT_MIN);
341 this->
SetData(ilo, ihi, jlo, jhi);
349 this->Data[0] = other.Data[0];
350 this->Data[1] = other.Data[1];
351 this->Data[2] = other.Data[2];
352 this->Data[3] = other.Data[3];
367 nCells[0] = ext[1] - ext[0] + 1;
368 nCells[1] = ext[3] - ext[2] + 1;
374 return (ext[1] - ext[0] + 1) * (ext[3] - ext[2] + 1);
393 first[0] = this->Data[0];
394 first[1] = this->Data[2];
400 first[0] = this->Data[0] - origin[0];
401 first[1] = this->Data[2] - origin[1];
407 last[0] = this->Data[1];
408 last[1] = this->Data[3];
414 if (this->Data[0] > this->Data[1] || this->Data[2] > this->Data[3])
424 if ((this->Data[0] == other.Data[0]) && (this->Data[1] == other.Data[1]) &&
425 (this->Data[2] == other.Data[2]) && (this->Data[3] == other.Data[3]))
435 if ((this->Data[0] <= other.Data[0]) && (this->Data[1] >= other.Data[1]) &&
436 (this->Data[2] <= other.Data[2]) && (this->Data[3] >= other.Data[3]))
446 if ((this->Data[0] <= i) && (this->Data[1] >= i) && (this->Data[2] <= j) && (this->Data[3] >= j))
467 this->Data[0] =
std::max(this->Data[0], other.Data[0]);
468 this->Data[1] = std::min(this->Data[1], other.Data[1]);
469 this->Data[2] =
std::max(this->Data[2], other.Data[2]);
470 this->Data[3] = std::min(this->Data[3], other.Data[3]);
492 this->Data[0] = std::min(this->Data[0], other.Data[0]);
493 this->Data[1] =
std::max(this->Data[1], other.Data[1]);
494 this->Data[2] = std::min(this->Data[2], other.Data[2]);
495 this->Data[3] =
std::max(this->Data[3], other.Data[3]);
502 return other.
Empty();
520 this->Data[q + 1] += n;
526 this->Data[2 * q] -= n;
532 this->Data[2 * q + 1] += n;
549 this->Data[q + 1] -= n;
555 this->Data[0] += n[0];
556 this->Data[1] += n[0];
557 this->Data[2] += n[1];
558 this->Data[3] += n[1];
566 this->Data[q + 1] += n;
572 for (
int q = 0; q < 2; ++q)
578 this->Data[qq + 1] += n;
585 for (
int q = 0; q < 2; ++q)
588 int n = -this->Data[qq];
591 this->Data[qq + 1] += n;
601 int l = this->Data[q + 1] - this->Data[q] + 1;
609 this->Data[q + 1] = s - 1;
Representation of a cartesian pixel plane and common operations on it.
void CellToNode()
In-place conversion from cell based to node based extent, and vise-versa.
static vtkPixelExtent Grow(const vtkPixelExtent &inputExt, const vtkPixelExtent &problemDomain, int n)
static vtkPixelExtent GrowLow(const vtkPixelExtent &ext, int q, int n)
vtkPixelExtent & operator=(const vtkPixelExtent &other)
const int * GetData() const
vtkPixelExtent Split(int dir)
Divide the extent in half in the given direction.
bool operator==(const vtkPixelExtent &other) const
Test for equivalence.
vtkPixelExtent(T width, T height)
static vtkPixelExtent Grow(const vtkPixelExtent &inputExt, int n)
Add or remove ghost cells.
void SetData(const vtkPixelExtent &ext)
Set the extent.
static void Merge(std::deque< vtkPixelExtent > &exts)
Merge compatible extents in the list.
size_t Size() const
Get the total number.
void operator&=(const vtkPixelExtent &other)
In place intersection.
static vtkPixelExtent Shrink(const vtkPixelExtent &inputExt, const vtkPixelExtent &problemDomain, int n)
Remove ghost cells.
static vtkPixelExtent GrowHigh(const vtkPixelExtent &ext, int q, int n)
void NodeToCell()
In-place conversion from cell based to node based extent, and vise-versa.
const unsigned int * GetDataU() const
int Disjoint(vtkPixelExtent other) const
Return non-zero if the extent is disjoint from the other.
static vtkPixelExtent Shrink(const vtkPixelExtent &inputExt, int n)
int & operator[](int i)
Element access.
void GetStartIndex(int first[2]) const
Get the start/end index.
void Shrink(int n)
Shrink the extent by n.
void Shift()
Shifts by low corner of this, moving to the origin.
int * GetData()
Direct access to internal data.
static void Shift(int *ij, int n)
Shift by the given amount while respecting mode.
int Contains(const vtkPixelExtent &other) const
Return non-zero if this extent contains the other.
static vtkPixelExtent NodeToCell(const vtkPixelExtent &inputExt)
Convert from point extent to cell extent while respecting the dimensionality of the data.
unsigned int * GetDataU()
void GetEndIndex(int last[2]) const
Get the start/end index.
void Size(T nCells[2]) const
Get the number in each direction.
int Empty() const
Return true if empty.
const int & operator[](int i) const
static void Split(int i, int j, const vtkPixelExtent &ext, std::deque< vtkPixelExtent > &newExts)
Split ext at i,j, resulting extents (up to 4) are appended to newExts.
static void Subtract(const vtkPixelExtent &A, const vtkPixelExtent &B, std::deque< vtkPixelExtent > &C)
A - B = C C is a set of disjoint extents such that the intersection of B and C is empty and the inter...
static void Shift(int *ij, int *n)
Shift by the given amount while respecting mode.
void GrowLow(int q, int n)
Expand the extents by n.
void operator|=(const vtkPixelExtent &other)
In place union.
void Grow(int n)
Expand the extents by n.
static vtkPixelExtent CellToNode(const vtkPixelExtent &inputExt)
Convert from cell extent to point extent while respecting the dimensionality of the data.
void GrowHigh(int q, int n)
Expand the extents by n.
vtkSmartPointer< vtkDataArray > GetData(const Ioss::GroupingEntity *entity, const std::string &fieldname, Ioss::Transform *transform=nullptr, Cache *cache=nullptr, const std::string &cachekey=std::string())
Returns a VTK array for a given field (fieldname) on the chosen block (or set) entity.
bool operator<(const vtkPixelExtent &l, const vtkPixelExtent &r)
VTKCOMMONDATAMODEL_EXPORT std::ostream & operator<<(std::ostream &os, const vtkPixelExtent &ext)
Stream insertion operator for formatted output of pixel extents.
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)