 |
VTK
9.1.0
|
Go to the documentation of this file.
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);
281 VTKCOMMONDATAMODEL_EXPORT
285 template <
typename T>
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]);
295 template <
typename T>
298 T ext[4] = { ilo, ihi, jlo, jhi };
309 template <
typename T>
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);
331 template <
typename T>
338 template <
typename T>
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];
364 template <
typename T>
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);
378 template <
typename T>
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;
const unsigned int * GetDataU() const
int Empty() const
Return true if empty.
int Disjoint(vtkPixelExtent other) const
Return non-zero if the extent is disjoint from the other.
void operator|=(const vtkPixelExtent &other)
In place union.
unsigned int * GetDataU()
static vtkPixelExtent CellToNode(const vtkPixelExtent &inputExt)
Convert from cell extent to point extent while respecting the dimensionality of the data.
static vtkPixelExtent Grow(const vtkPixelExtent &inputExt, const vtkPixelExtent &problemDomain, int n)
void Grow(int n)
Expand the extents by n.
size_t Size() const
Get the total number.
const int * GetData() const
VTKCOMMONDATAMODEL_EXPORT std::ostream & operator<<(std::ostream &os, const vtkPixelExtent &ext)
Stream insertion operator for formatted output of pixel extents.
void Shift()
Shifts by low corner of this, moving to the origin.
vtkPixelExtent & operator=(const vtkPixelExtent &other)
static vtkPixelExtent GrowHigh(const vtkPixelExtent &ext, int q, int n)
int Contains(const vtkPixelExtent &other) const
Return non-zero if this extent contains the other.
static vtkPixelExtent Shrink(const vtkPixelExtent &inputExt, int n)
Representation of a cartesian pixel plane and common operations on it.
void NodeToCell()
In-place conversion from cell based to node based extent, and vise-versa.
void GrowHigh(int q, int n)
Expand the extents by n.
static void Shift(int *ij, int n)
Shift by the given amount while respecting mode.
int * GetData()
Direct access to internal data.
void GrowLow(int q, int n)
Expand the extents by n.
vtkPixelExtent Split(int dir)
Divide the extent in half in the given direction.
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.
void GetStartIndex(int first[2]) const
Get the start/end index.
bool operator==(const vtkPixelExtent &other) const
Test for equivalence.
static vtkPixelExtent Shrink(const vtkPixelExtent &inputExt, const vtkPixelExtent &problemDomain, int n)
Remove ghost cells.
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
void GetEndIndex(int last[2]) const
Get the start/end index.
const int & operator[](int i) const
void SetData(const vtkPixelExtent &ext)
Set the extent.
bool operator<(const vtkPixelExtent &l, const vtkPixelExtent &r)
static vtkPixelExtent Grow(const vtkPixelExtent &inputExt, int n)
Add or remove ghost cells.
void CellToNode()
In-place conversion from cell based to node based extent, and vise-versa.
void operator&=(const vtkPixelExtent &other)
In place intersection.
void Size(T nCells[2]) const
Get the number in each direction.
static vtkPixelExtent GrowLow(const vtkPixelExtent &ext, int q, int n)
void Shrink(int n)
Shrink the extent by n.
vtkPixelExtent(T width, T height)
static vtkPixelExtent NodeToCell(const vtkPixelExtent &inputExt)
Convert from point extent to cell extent while respecting the dimensionality of the data.
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.
static void Merge(std::deque< vtkPixelExtent > &exts)
Merge compatible extents in the list.
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...
int & operator[](int i)
Element access.
static void Shift(int *ij, int *n)
Shift by the given amount while respecting mode.