27 #ifndef vtkPixelExtent_h 28 #define vtkPixelExtent_h 31 #include "vtkCommonDataModelModule.h" 51 { this->SetData(T(0), width-T(1), T(0), height-T(1)); }
61 const int &
operator[](
int i)
const {
return this->Data[i]; }
69 void SetData(
const T *ext);
72 void SetData(T ilo, T ihi, T jlo, T jhi);
79 const int *
GetData()
const {
return this->Data; }
82 void GetData(T
data[4])
const;
85 {
return reinterpret_cast<unsigned int*
>(this->Data); }
88 {
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;
126 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);
268 static void Shift(
int *ij,
int n);
269 static void Shift(
int *ij,
int *n);
282 std::deque<vtkPixelExtent> &newExts);
290 static void Subtract(
293 std::deque<vtkPixelExtent> &newExts);
300 static void Merge(std::deque<vtkPixelExtent> &exts);
309 VTKCOMMONDATAMODEL_EXPORT
316 Data[0] =
static_cast<int>(ext[0]);
317 Data[1] =
static_cast<int>(ext[1]);
318 Data[2] =
static_cast<int>(ext[2]);
319 Data[3] =
static_cast<int>(ext[3]);
326 T ext[4] = {ilo, ihi, jlo, jhi};
334 this->SetData(other.
GetData());
341 data[0] =
static_cast<T
>(this->Data[0]);
342 data[1] =
static_cast<T
>(this->Data[1]);
343 data[2] =
static_cast<T
>(this->Data[2]);
344 data[3] =
static_cast<T
>(this->Data[3]);
351 this->SetData<int>(INT_MAX, INT_MIN, INT_MAX, INT_MIN);
376 this->SetData(ilo, ihi, jlo, jhi);
385 this->Data[0] = other.Data[0];
386 this->Data[1] = other.Data[1];
387 this->Data[2] = other.Data[2];
388 this->Data[3] = other.Data[3];
404 nCells[0] = ext[1] - ext[0] + 1;
405 nCells[1] = ext[3] - ext[2] + 1;
412 return (ext[1] - ext[0] + 1) * (ext[3] - ext[2] + 1);
433 first[0] = this->Data[0];
434 first[1] = this->Data[2];
441 first[0] = this->Data[0] - origin[0];
442 first[1] = this->Data[2] - origin[1];
449 last[0] = this->Data[1];
450 last[1] = this->Data[3];
457 if ( this->Data[0] > this->Data[1]
458 || this->Data[2] > this->Data[3])
469 if ( (this->Data[0] == other.Data[0])
470 && (this->Data[1] == other.Data[1])
471 && (this->Data[2] == other.Data[2])
472 && (this->Data[3] == other.Data[3]) )
483 if ( (this->Data[0] <= other.Data[0])
484 && (this->Data[1] >= other.Data[1])
485 && (this->Data[2] <= other.Data[2])
486 && (this->Data[3] >= other.Data[3]) )
497 if ( (this->Data[0] <= i)
498 && (this->Data[1] >= i)
499 && (this->Data[2] <= j)
500 && (this->Data[3] >= j) )
523 this->Data[0] =
std::max(this->Data[0], other.Data[0]);
524 this->Data[1] = std::min(this->Data[1], other.Data[1]);
525 this->Data[2] =
std::max(this->Data[2], other.Data[2]);
526 this->Data[3] = std::min(this->Data[3], other.Data[3]);
545 this->SetData(other.
GetData());
549 this->Data[0] = std::min(this->Data[0], other.Data[0]);
550 this->Data[1] =
std::max(this->Data[1], other.Data[1]);
551 this->Data[2] = std::min(this->Data[2], other.Data[2]);
552 this->Data[3] =
std::max(this->Data[3], other.Data[3]);
560 return other.
Empty();
580 this->Data[q+1] += n;
587 this->Data[2*q] -= n;
594 this->Data[2*q+1] += n;
613 this->Data[q+1] -= n;
620 this->Data[0] += n[0];
621 this->Data[1] += n[0];
622 this->Data[2] += n[1];
623 this->Data[3] += n[1];
632 this->Data[q+1] += n;
639 for (
int q=0; q<2; ++q)
644 this->Data[qq ] += n;
645 this->Data[qq+1] += n;
653 for (
int q=0; q<2; ++q)
656 int n =- this->Data[qq];
658 this->Data[qq ] += n;
659 this->Data[qq+1] += n;
670 int l = this->Data[q+1] - this->Data[q] + 1;
678 this->Data[q+1] = s - 1;
const int * GetData() const
vtkPixelExtent(T width, T height)
void GrowLow(int q, int n)
Expand the extents by n.
void GetEndIndex(int last[2]) const
Get the start/end index.
int * GetData()
Direct access to internal data.
void Size(T nCells[2]) const
Get the number in each direction.
size_t Size() const
Get the total number.
bool operator<(const vtkPixelExtent &l, const vtkPixelExtent &r)
vtkPixelExtent & operator=(const vtkPixelExtent &other)
int Contains(const vtkPixelExtent &other) const
Return non-zero if this extent conatins the other.
const int & operator[](int i) const
vtkPixelExtent Split(int dir)
Divide the extent in half in the given direction.
const unsigned int * GetDataU() const
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.
int Disjoint(vtkPixelExtent other) const
Return non-zero if the extent is disjoint from the other.
void CellToNode()
In-place conversion from cell based to node based extent, and vise-versa.
void GrowHigh(int q, int n)
Expand the extents by n.
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.
bool operator==(const vtkPixelExtent &other) const
Test for equivalence.
void SetData(const vtkPixelExtent &ext)
Set the extent.
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
int Empty() const
Return true if empty.
void Shrink(int n)
Shrink the extent by n.
void GetStartIndex(int first[2]) const
Get the start/end index.
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.
void operator &=(const vtkPixelExtent &other)
In place intersection.
unsigned int * GetDataU()