30 #ifndef vtkPixelExtent_h
31 #define vtkPixelExtent_h
33 #include "vtkCommonDataModelModule.h"
55 this->SetData(T(0), width - T(1), T(0), height - T(1));
66 const int&
operator[](
int i)
const {
return this->Data[i]; }
74 void SetData(
const T* ext);
77 void SetData(T ilo, T ihi, T jlo, T jhi);
84 const int*
GetData()
const {
return this->Data; }
89 unsigned int*
GetDataU() {
return reinterpret_cast<unsigned int*
>(this->Data); }
91 const unsigned int*
GetDataU()
const {
return reinterpret_cast<const unsigned int*
>(this->Data); }
97 void GetStartIndex(
int first[2])
const;
98 void GetStartIndex(
int first[2],
const int origin[2])
const;
99 void GetEndIndex(
int last[2])
const;
117 int Contains(
int i,
int j)
const;
128 template <
typename T>
129 void Size(T nCells[2])
const;
151 void Grow(
int q,
int n);
152 void GrowLow(
int q,
int n);
153 void GrowHigh(
int q,
int n);
161 void Shrink(
int q,
int n);
182 void Shift(
int q,
int n);
203 template <
typename T>
250 static void Shift(
int* ij,
int n);
251 static void Shift(
int* ij,
int* n);
259 static void Split(
int i,
int j,
const vtkPixelExtent& ext, std::deque<vtkPixelExtent>& newExts);
267 static void Subtract(
275 static void Merge(std::deque<vtkPixelExtent>& exts);
284 VTKCOMMONDATAMODEL_EXPORT
288 template <
typename T>
291 Data[0] =
static_cast<int>(ext[0]);
292 Data[1] =
static_cast<int>(ext[1]);
293 Data[2] =
static_cast<int>(ext[2]);
294 Data[3] =
static_cast<int>(ext[3]);
298 template <
typename T>
301 T ext[4] = { ilo, ihi, jlo, jhi };
312 template <
typename T>
315 data[0] =
static_cast<T
>(this->Data[0]);
316 data[1] =
static_cast<T
>(this->Data[1]);
317 data[2] =
static_cast<T
>(this->Data[2]);
318 data[3] =
static_cast<T
>(this->Data[3]);
324 this->SetData<int>(INT_MAX, INT_MIN, INT_MAX, INT_MIN);
334 template <
typename T>
341 template <
typename T>
344 this->
SetData(ilo, ihi, jlo, jhi);
352 this->Data[0] = other.Data[0];
353 this->Data[1] = other.Data[1];
354 this->Data[2] = other.Data[2];
355 this->Data[3] = other.Data[3];
367 template <
typename T>
370 nCells[0] = ext[1] - ext[0] + 1;
371 nCells[1] = ext[3] - ext[2] + 1;
377 return (ext[1] - ext[0] + 1) * (ext[3] - ext[2] + 1);
381 template <
typename T>
396 first[0] = this->Data[0];
397 first[1] = this->Data[2];
403 first[0] = this->Data[0] - origin[0];
404 first[1] = this->Data[2] - origin[1];
410 last[0] = this->Data[1];
411 last[1] = this->Data[3];
417 if (this->Data[0] > this->Data[1] || this->Data[2] > this->Data[3])
427 if ((this->Data[0] == other.Data[0]) && (this->Data[1] == other.Data[1]) &&
428 (this->Data[2] == other.Data[2]) && (this->Data[3] == other.Data[3]))
438 if ((this->Data[0] <= other.Data[0]) && (this->Data[1] >= other.Data[1]) &&
439 (this->Data[2] <= other.Data[2]) && (this->Data[3] >= other.Data[3]))
449 if ((this->Data[0] <= i) && (this->Data[1] >= i) && (this->Data[2] <= j) && (this->Data[3] >= j))
470 this->Data[0] =
std::max(this->Data[0], other.Data[0]);
471 this->Data[1] = std::min(this->Data[1], other.Data[1]);
472 this->Data[2] =
std::max(this->Data[2], other.Data[2]);
473 this->Data[3] = std::min(this->Data[3], other.Data[3]);
495 this->Data[0] = std::min(this->Data[0], other.Data[0]);
496 this->Data[1] =
std::max(this->Data[1], other.Data[1]);
497 this->Data[2] = std::min(this->Data[2], other.Data[2]);
498 this->Data[3] =
std::max(this->Data[3], other.Data[3]);
505 return other.
Empty();
523 this->Data[q + 1] += n;
529 this->Data[2 * q] -= n;
535 this->Data[2 * q + 1] += n;
552 this->Data[q + 1] -= n;
558 this->Data[0] += n[0];
559 this->Data[1] += n[0];
560 this->Data[2] += n[1];
561 this->Data[3] += n[1];
569 this->Data[q + 1] += n;
575 for (
int q = 0; q < 2; ++q)
581 this->Data[qq + 1] += n;
588 for (
int q = 0; q < 2; ++q)
591 int n = -this->Data[qq];
594 this->Data[qq + 1] += n;
604 int l = this->Data[q + 1] - this->Data[q] + 1;
612 this->Data[q + 1] = s - 1;
void GetStartIndex(int first[2]) const
Get the start/end index.
int Disjoint(vtkPixelExtent other) const
Return non-zero if the extent is disjoint from the other.
const unsigned int * GetDataU() const
vtkPixelExtent(T width, T height)
int Contains(const vtkPixelExtent &other) const
Return non-zero if this extent contains the other.
void GrowLow(int q, int n)
Expand the extents by n.
int * GetData()
Direct access to internal data.
const int & operator[](int i) const
bool operator<(const vtkPixelExtent &l, const vtkPixelExtent &r)
bool operator==(const vtkPixelExtent &other) const
Test for equivalence.
vtkPixelExtent & operator=(const vtkPixelExtent &other)
vtkPixelExtent Split(int dir)
Divide the extent in half in the given direction.
bool VTKCOMMONDATAMODEL_EXPORT operator==(vtkEdgeBase e1, vtkEdgeBase e2)
void operator|=(const vtkPixelExtent &other)
In place union.
VTKCOMMONDATAMODEL_EXPORT std::ostream & operator<<(std::ostream &os, const vtkPixelExtent &ext)
Stream insertion operator for formatted output of pixel extents.
void CellToNode()
In-place conversion from cell based to node based extent, and vise-versa.
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.
void GrowHigh(int q, int n)
Expand the extents by n.
size_t Size() const
Get the total number.
void NodeToCell()
In-place conversion from cell based to node based extent, and vise-versa.
Representation of a cartesian pixel plane and common operations on it.
void SetData(const vtkPixelExtent &ext)
Set the extent.
void operator&=(const vtkPixelExtent &other)
In place intersection.
void GetEndIndex(int last[2]) const
Get the start/end index.
int Empty() const
Return true if empty.
void Size(T nCells[2]) const
Get the number in each direction.
void Shrink(int n)
Shrink the extent by n.
const int * GetData() const
void Shift()
Shifts by low corner of this, moving to the origin.
int & operator[](int i)
Element access.
void Grow(int n)
Expand the extents by n.
unsigned int * GetDataU()