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; }
84 void GetData(T
data[4])
const;
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>
247 static void Shift(
int* ij,
int n);
248 static void Shift(
int* ij,
int* n);
256 static void Split(
int i,
int j,
const vtkPixelExtent& ext, std::deque<vtkPixelExtent>& newExts);
264 static void Subtract(
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;