40 vtkRect(
const T& x,
const T& y,
const T& width,
const T& height)
44 this->
Data[2] = width;
45 this->
Data[3] = height;
57 void Set(
const T& x,
const T& y,
const T& width,
const T& height)
61 this->
Data[2] = width;
62 this->
Data[3] = height;
74 const T&
GetX()
const {
return this->
Data[0]; }
84 const T&
GetY()
const {
return this->
Data[1]; }
157 if (point[0] < this->
GetX())
159 T dx = this->
GetX() - point[0];
160 this->
SetX(point[0]);
163 else if (point[0] > this->
GetX())
166 T dx = point[0] - this->
GetX();
171 if (point[1] < this->
GetY())
173 T dy = this->
GetY() - point[1];
174 this->
SetY(point[1]);
177 else if (point[1] > this->
GetY())
180 T dy = point[1] - this->
GetY();
191 T point[2] = { x, y };
202 if (rect.
GetX() < this->GetX())
208 else if (rect.
GetX() > this->GetX())
221 if (rect.
GetY() < this->GetY())
227 else if (rect.
GetY() > this->GetY())
248 bool intersects =
true;
250 if (rect.
GetX() < this->GetX())
253 intersects &= (dx < rect.
GetWidth());
255 else if (rect.
GetX() > this->
GetX())
258 intersects &= (dx < this->
GetWidth());
266 else if (rect.
GetY() > this->
GetY())
302 this->
Data[0] = left;
303 this->
Data[1] = bottom;
304 this->
Data[2] = (right - left);
305 this->
Data[3] = (top - bottom);
326 :
vtkRect<int>(x, y, width, height)
339 vtkRectf(
float x,
float y,
float width,
float height)
340 :
vtkRect<float>(x, y, width, height)
353 vtkRectd(
double x,
double y,
double width,
double height)
354 :
vtkRect<double>(x, y, width, height)
static T Max(const T &a, const T &b)
Returns the maximum of the two arguments provided.
static T Min(const T &a, const T &b)
Returns the minimum of the two arguments provided.
templated base type for storage of 2D rectangles.
vtkVector2< T > GetBottomLeft() const
Get the bottom left corner of the rect as a vtkVector.
vtkVector< T, 2 > GetBottomRight() const
Get the bottom right corner of the rect as a vtkVector.
void SetY(const T &y)
Set the y component of the rectangle bottom corner, i.e.
void AddPoint(T x, T y)
Expand this rect to contain the point passed in.
const T & GetBottom() const
Get the bottom boundary of the rectangle along the Y direction.
void SetX(const T &x)
Set the x component of the rectangle bottom corner, i.e.
void Set(const T &x, const T &y, const T &width, const T &height)
Set the x, y components of the rectangle, and the width/height.
T GetRight() const
Get the right boundary of the rectangle along the X direction.
vtkVector< T, 2 > GetTopLeft() const
Get the top left corner of the rect as a vtkVector.
void SetHeight(const T &height)
Set the height of the rectangle, i.e.
bool IntersectsWith(const vtkRect< T > &rect) const
Returns true if the rect argument overlaps this rect.
void MoveTo(T x, T y)
Move the rectangle, moving the bottom-left corner to the given position.
void AddRect(const vtkRect< T > &rect)
Expand this rect to contain the rect passed in.
const T & GetLeft() const
Get the left boundary of the rectangle along the X direction.
const T & GetX() const
Get the x component of the rectangle bottom corner, i.e.
T GetTop() const
Get the top boundary of the rectangle along the Y direction.
vtkRect(const T &x, const T &y, const T &width, const T &height)
const T & GetHeight() const
Get the height of the rectangle, i.e.
const T & GetWidth() const
Get the width of the rectangle, i.e.
vtkVector2d GetCenter() const
Returns the center of the rect as a vtkVector2d.
const T & GetY() const
Get the y component of the rectangle bottom corner, i.e.
vtkVector< T, 2 > GetTopRight() const
Get the bottom left corner of the rect as a vtkVector.
void AddPoint(const T point[2])
Expand this rect to contain the point passed in.
void SetWidth(const T &width)
Set the width of the rectanle, i.e.
bool Intersect(const vtkRect< T > &other)
Intersect with other rectangle.
vtkRectd(const double *init)
vtkRectd(double x, double y, double width, double height)
vtkRectf(const float *init)
vtkRectf(float x, float y, float width, float height)
vtkRecti(int x, int y, int width, int height)
vtkRecti(const int *init)
T Data[Size]
The only thing stored in memory!
templated base type for storage of vectors.