30 #ifndef vtkPixelExtent_h 31 #define vtkPixelExtent_h 34 #include "vtkCommonDataModelModule.h" 54 { this->SetData(T(0), width-T(1), T(0), height-T(1)); }
64 const int &
operator[](
int i)
const {
return this->Data[i]; }
72 void SetData(
const T *ext);
75 void SetData(T ilo, T ihi, T jlo, T jhi);
82 const int *
GetData()
const {
return this->Data; }
85 void GetData(T
data[4])
const;
88 {
return reinterpret_cast<unsigned int*
>(this->Data); }
91 {
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;
129 void Size(T nCells[2])
const;
154 void Grow(
int q,
int n);
155 void GrowLow(
int q,
int n);
156 void GrowHigh(
int q,
int n);
164 void Shrink(
int q,
int n);
185 void Shift(
int q,
int n);
271 static void Shift(
int *ij,
int n);
272 static void Shift(
int *ij,
int *n);
285 std::deque<vtkPixelExtent> &newExts);
293 static void Subtract(
296 std::deque<vtkPixelExtent> &newExts);
303 static void Merge(std::deque<vtkPixelExtent> &exts);
312 VTKCOMMONDATAMODEL_EXPORT
319 Data[0] =
static_cast<int>(ext[0]);
320 Data[1] =
static_cast<int>(ext[1]);
321 Data[2] =
static_cast<int>(ext[2]);
322 Data[3] =
static_cast<int>(ext[3]);
329 T ext[4] = {ilo, ihi, jlo, jhi};
337 this->SetData(other.
GetData());
344 data[0] =
static_cast<T
>(this->Data[0]);
345 data[1] =
static_cast<T
>(this->Data[1]);
346 data[2] =
static_cast<T
>(this->Data[2]);
347 data[3] =
static_cast<T
>(this->Data[3]);
354 this->SetData<int>(INT_MAX, INT_MIN, INT_MAX, INT_MIN);
379 this->SetData(ilo, ihi, jlo, jhi);
388 this->Data[0] = other.Data[0];
389 this->Data[1] = other.Data[1];
390 this->Data[2] = other.Data[2];
391 this->Data[3] = other.Data[3];
407 nCells[0] = ext[1] - ext[0] + 1;
408 nCells[1] = ext[3] - ext[2] + 1;
415 return (ext[1] - ext[0] + 1) * (ext[3] - ext[2] + 1);
436 first[0] = this->Data[0];
437 first[1] = this->Data[2];
444 first[0] = this->Data[0] - origin[0];
445 first[1] = this->Data[2] - origin[1];
452 last[0] = this->Data[1];
453 last[1] = this->Data[3];
460 if ( this->Data[0] > this->Data[1]
461 || this->Data[2] > this->Data[3])
472 if ( (this->Data[0] == other.Data[0])
473 && (this->Data[1] == other.Data[1])
474 && (this->Data[2] == other.Data[2])
475 && (this->Data[3] == other.Data[3]) )
486 if ( (this->Data[0] <= other.Data[0])
487 && (this->Data[1] >= other.Data[1])
488 && (this->Data[2] <= other.Data[2])
489 && (this->Data[3] >= other.Data[3]) )
500 if ( (this->Data[0] <= i)
501 && (this->Data[1] >= i)
502 && (this->Data[2] <= j)
503 && (this->Data[3] >= j) )
526 this->Data[0] =
std::max(this->Data[0], other.Data[0]);
527 this->Data[1] = std::min(this->Data[1], other.Data[1]);
528 this->Data[2] =
std::max(this->Data[2], other.Data[2]);
529 this->Data[3] = std::min(this->Data[3], other.Data[3]);
548 this->SetData(other.
GetData());
552 this->Data[0] = std::min(this->Data[0], other.Data[0]);
553 this->Data[1] =
std::max(this->Data[1], other.Data[1]);
554 this->Data[2] = std::min(this->Data[2], other.Data[2]);
555 this->Data[3] =
std::max(this->Data[3], other.Data[3]);
563 return other.
Empty();
583 this->Data[q+1] += n;
590 this->Data[2*q] -= n;
597 this->Data[2*q+1] += n;
616 this->Data[q+1] -= n;
623 this->Data[0] += n[0];
624 this->Data[1] += n[0];
625 this->Data[2] += n[1];
626 this->Data[3] += n[1];
635 this->Data[q+1] += n;
642 for (
int q=0; q<2; ++q)
647 this->Data[qq ] += n;
648 this->Data[qq+1] += n;
656 for (
int q=0; q<2; ++q)
659 int n =- this->Data[qq];
661 this->Data[qq ] += n;
662 this->Data[qq+1] += n;
673 int l = this->Data[q+1] - this->Data[q] + 1;
681 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.
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.
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.
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
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()