CVB.Net 14.0
Rect Struct Reference

Cvb Rectangle structure. More...

Inherits IAreaOfInterest.

Public Member Functions

 Rect (int left, int top, int right, int bottom)
 Constructor for Cvb rectangles. More...
 
 Rect (Point2D location, Size2D size)
 Constructor for Cvb rectangles. More...
 
bool Contains (Point2D pt)
 Check if a point is located inside this Rect. More...
 
bool Contains (Point2Dd pt)
 Check if a point is located inside this Rect. More...
 
bool Contains (Point2Dd pt, double epsilon)
 Check if a point is located inside this Rect. More...
 
bool Contains (int x, int y)
 Determines if the specified point is contained with this Rect. More...
 
override bool Equals (object obj)
 Tests whether obj is a Rect structure with the same/ location and size as this Rect structure. More...
 
override int GetHashCode ()
 Returns the hash code for this Rect. More...
 
override string ToString ()
 String conversion. More...
 
bool IntersectsWith (Rect rect)
 Test if this rectangle intersects with rect . More...
 
void Intersect (Rect rect)
 Replaces this rectangle with the intersection of itself and the specified rectangle. More...
 

Static Public Member Functions

static Rect TruncateCeiling (RectD rect)
 Converts the given rect to a Rect structure by truncating Left and Top and rounding Right and Bottom to the next higher integer number. More...
 
static Rect Ceiling (RectD rect)
 Converts the given rect to a Rect structure by rounding the values of the RectD structure to the next higher integer number. More...
 
static Rect Round (RectD rect)
 Converts the given rect to a Rect structure by rounding the values of the RectD structure mathematically. More...
 
static Rect Truncate (RectD rect)
 Converts the given rect to a Rect structure by rounding the values of the RectD structure to the next lower integer number. More...
 
static Rect Intersect (Rect a, Rect b)
 Returns a Rect structure that represents the intersection of the two input rectangles. If there is no intersection, an empty Rect is returned. More...
 
static Rect Union (Rect a, Rect b)
 Gets a Rect structure that contains the union of two Rect structures. More...
 
static Rect FromLTRB (int left, int top, int right, int bottom)
 Creates a Rect structure with the specified edge locations. More...
 
static Rect CropExtent (Rect ext, Point2D pos, Size2D imageSize)
 Assuming that a Rect structure contains the extent of something relative to a position inside an image, this function crops the Rect so that the whole content is inside the image. More...
 
static bool operator!= (Rect lhs, Rect rhs)
 Comparison operator for Rect structures. More...
 
static bool operator== (Rect lhs, Rect rhs)
 Comparison operator for Rect structures. More...
 
static operator Rect (RectD rect)
 Explicit conversion operator (truncates the values). More...
 

Static Public Attributes

static readonly Rect Empty = new Rect(0, 0, -1, -1)
 Null-element.
 

Properties

int Left [get, set]
 First column of the rectangle.
 
int Top [get, set]
 First row of the rectangle.
 
int Right [get, set]
 Rightmost column of the rectangle (still inside the rectangle).
 
int Bottom [get, set]
 Bottom row of the rectangle (still inside the rectangle).
 
int Width [get, set]
 Width of the rectangle.
 
int Height [get, set]
 Height of the rectangle.
 
Point2D Location [get, set]
 Location of the top left corner of the rectangle.
 
bool IsEmpty [get]
 True if width and height are both zero, false otherwise.
 
Size2D Size [get, set]
 Size of the rectangle.
 
CoordinateSystemType CoordinateSystem [get]
 Indicates the coordinate system in which this object is being measured (when used as an area of interest).
 
double Area [get]
 Area of the rectangle.
 
- Properties inherited from IAreaOfInterest
CoordinateSystemType CoordinateSystem [get]
 Implementers of this interface should specify here inside which coordinate system their Area of interest is to operate.
 
double Area [get]
 Size (in pixels) of the Area of interest
 

Detailed Description

Cvb Rectangle structure.

Unlike System.Drawing.Rectangle, which upholds the convention that Right and Bottom are not part of the rectangle (in other words: Width = Left - Right and Height = Bottom - Top), Common Vision Blox always uses rectangles (or rectangular shaped areas of interest represented by integer parameters left, top, right and bottom) in such a way that right and bottom are still part of the area to be investigated (i.e. Width = Right - Left + 1 and Height = Bottom - Top

  • 1).

To model this difference correctly we decided to give CVB.Net a rectangle of its own which behaves according to the conventions used in Common Vision Blox.

Constructor & Destructor Documentation

◆ Rect() [1/2]

Rect ( int  left,
int  top,
int  right,
int  bottom 
)

Constructor for Cvb rectangles.

Parameters
leftLeftmost column of the rectangle
topTopmost column of the rectangle
rightRightmost column of the rectangle
bottomBottom columns of the rectangle

◆ Rect() [2/2]

Rect ( Point2D  location,
Size2D  size 
)

Constructor for Cvb rectangles.

Parameters
locationLocation of the rectangle
sizeSize of the rectangle

Member Function Documentation

◆ Ceiling()

static Rect Ceiling ( RectD  rect)
static

Converts the given rect to a Rect structure by rounding the values of the RectD structure to the next higher integer number.

Parameters
rectRect to perform ceiling operation on.
Returns
New rounded Rect.

◆ Contains() [1/4]

bool Contains ( int  x,
int  y 
)

Determines if the specified point is contained with this Rect.

Parameters
xX-coordinate of the point to test
yY-coordinate of the point to test
Returns
true of the point defined through the parameters x and y is inside this Rect; false otherwise.

◆ Contains() [2/4]

bool Contains ( Point2D  pt)

Check if a point is located inside this Rect.

Parameters
ptPoint to be checked
Returns
true if pt is inside this Rect, false otherwise.

◆ Contains() [3/4]

bool Contains ( Point2Dd  pt)

Check if a point is located inside this Rect.

Parameters
ptPoint to be checked
Returns
true if pt is inside this Rect, false otherwise.

◆ Contains() [4/4]

bool Contains ( Point2Dd  pt,
double  epsilon 
)

Check if a point is located inside this Rect.

Parameters
ptPoint to be checked
epsilonEpsilon for comparison
Returns
true if pt is inside this Rect, false otherwise.

◆ CropExtent()

static Rect CropExtent ( Rect  ext,
Point2D  pos,
Size2D  imageSize 
)
static

Assuming that a Rect structure contains the extent of something relative to a position inside an image, this function crops the Rect so that the whole content is inside the image.

Parameters
extRect to be cropped.
posPosition in the image relative to which the extent is to be applied.
imageSizeAvailable size (i.e. upper limit for cropping).
Returns
Cropped Rect.

◆ Equals()

override bool Equals ( object  obj)

Tests whether obj is a Rect structure with the same/ location and size as this Rect structure.

Parameters
objObject to compare this one with.
Returns
true if obj is a Rect and has the same border values; false otherwise.

◆ FromLTRB()

static Rect FromLTRB ( int  left,
int  top,
int  right,
int  bottom 
)
static

Creates a Rect structure with the specified edge locations.

Parameters
leftThe x-coordinate of the upper left corner of this Rect structure
topThe y-coordinate of the upper left corner of this Rect structure
rightThe x-coordinate of the lower right corner of this Rect structure
bottomThe y-coordinate of the lower right corner of this Rect structure
Returns
The new Rect that this method creates.

◆ GetHashCode()

override int GetHashCode ( )

Returns the hash code for this Rect.

Returns
Hash code for this Rect.

◆ Intersect() [1/2]

static Rect Intersect ( Rect  a,
Rect  b 
)
static

Returns a Rect structure that represents the intersection of the two input rectangles. If there is no intersection, an empty Rect is returned.

Parameters
aRect to intersect
bRect to intersect
Returns
A Rect that represents the intersection of a and b

◆ Intersect() [2/2]

void Intersect ( Rect  rect)

Replaces this rectangle with the intersection of itself and the specified rectangle.

Parameters
rectThe rectangle with which to intersect

◆ IntersectsWith()

bool IntersectsWith ( Rect  rect)

Test if this rectangle intersects with rect .

Parameters
rectThe rectangle to test
Returns
true if there is any intersection, false otherwise

◆ operator Rect()

static operator Rect ( RectD  rect)
explicitstatic

Explicit conversion operator (truncates the values).

Parameters
rectRect to be converted.
Returns
New truncated Rect.

◆ operator!=()

static bool operator!= ( Rect  lhs,
Rect  rhs 
)
static

Comparison operator for Rect structures.

Parameters
lhsLeft hand side operand.
rhsRight hand side operand.
Returns
true if lhs != rhs , false otherwise.

◆ operator==()

static bool operator== ( Rect  lhs,
Rect  rhs 
)
static

Comparison operator for Rect structures.

Parameters
lhsLeft hand side operand
rhsRight hand side operand
Returns
true if lhs != rhs , false otherwise.

◆ Round()

static Rect Round ( RectD  rect)
static

Converts the given rect to a Rect structure by rounding the values of the RectD structure mathematically.

Parameters
rectRect to perform ceiling operation on.
Returns
New rounded Rect.

◆ ToString()

override string ToString ( )

String conversion.

Returns
string representation of this Rect

◆ Truncate()

static Rect Truncate ( RectD  rect)
static

Converts the given rect to a Rect structure by rounding the values of the RectD structure to the next lower integer number.

Parameters
rectRect to perform ceiling operation on.
Returns
New rounded Rect.

◆ TruncateCeiling()

static Rect TruncateCeiling ( RectD  rect)
static

Converts the given rect to a Rect structure by truncating Left and Top and rounding Right and Bottom to the next higher integer number.

Parameters
rectRect to perform the operation on.
Returns
New rounded Rect.

◆ Union()

static Rect Union ( Rect  a,
Rect  b 
)
static

Gets a Rect structure that contains the union of two Rect structures.

Parameters
aA rectangle to union
bA rectangle to union
Returns
a Rect that bounds the union of the two Rect structures