Geometry

vtr_geometry

This file include differents different geometry classes.

template<class T>
class Point

A point in 2D space.

This class represents a point in 2D space. Hence, it holds both x and y components of the point.

Public Functions

T x() const

x coordinate

T y() const

y coordinate

void set(T x_val, T y_val)

Set x and y values.

void set_x(T x_val)

set x value

void set_y(T y_val)

set y value

void swap()

Swap x and y values.

Friends

friend bool operator==(Point<T> lhs, Point<T> rhs)

== operator

friend bool operator!=(Point<T> lhs, Point<T> rhs)

!= operator

friend bool operator<(Point<T> lhs, Point<T> rhs)

< operator

template<class T>
class Rect

A 2D rectangle.

This class represents a 2D rectangle. It can be created with its 4 points or using the bottom left and the top rights ones only

Public Functions

Rect()

default constructor

Rect(T left_val, T bottom_val, T right_val, T top_val)

construct using 4 vertex

Rect(Point<T> bottom_left_val, Point<T> top_right_val)

construct using the bottom left and the top right vertex

template<typename U = T, typename std::enable_if<std::is_integral<U>::value>::type...>
Rect(Point<U> point)

Constructs a rectangle that only contains the given point.

Rect(p1).contains(p2) => p1 == p2 It is only enabled for integral types, because making this work for floating point types would be difficult and brittle. The following line only enables the constructor if std::is_integral<T>::value == true

T xmin() const

xmin coordinate

T xmax() const

xmax coordinate

T ymin() const

ymin coodrinate

T ymax() const

ymax coordinate

Point<T> bottom_left() const

Return the bottom left point.

Point<T> top_right() const

Return the top right point.

T width() const

Return the rectangle width.

T height() const

Return the rectangle height.

bool contains(Point<T> point) const

Returns true if the point is fully contained within the rectangle (excluding the top-right edges)

bool strictly_contains(Point<T> point) const

Returns true if the point is strictly contained within the region (excluding all edges)

bool coincident(Point<T> point) const

Returns true if the point is coincident with the rectangle (including the top-right edges)

bool contains(const Rect<T> &other) const

Returns true if other is contained within the rectangle (including all edges)

bool empty() const

Checks whether the rectangle is empty.

Returns true if no points are contained in the rectangle rect.empty() => not exists p. rect.contains(p) This also implies either the width or height is 0.

void set_xmin(T xmin_val)

set xmin to a point

void set_ymin(T ymin_val)

set ymin to a point

void set_xmax(T xmax_val)

set xmax to a point

void set_ymax(T ymax_val)

set ymax to a point

Rect<T> &expand_bounding_box(const Rect<T> &other)

Equivalent to *this = bounding_box(*this, other)

Friends

friend bool operator==(const Rect<T> &lhs, const Rect<T> &rhs)

== operator

friend bool operator!=(const Rect<T> &lhs, const Rect<T> &rhs)

!= operator

template<class T>
class Line

A 2D line.

It is constructed using a vector of the line points

Public Functions

Line(std::vector<Point<T>> line_points)

contructor

Rect<T> bounding_box() const

Returns the bounding box.

point_range points() const

Returns a range of constituent points.

template<class T>
class RectUnion

A union of 2d rectangles.

Public Functions

RectUnion(std::vector<Rect<T>> rects)

Construct from a set of rectangles.

Rect<T> bounding_box() const

Returns the bounding box of all rectangles in the union.

bool contains(Point<T> point) const

Returns true if the point is fully contained within the region (excluding top-right edges)

bool strictly_contains(Point<T> point) const

Returns true if the point is strictly contained within the region (excluding all edges)

bool coincident(Point<T> point) const

Returns true if the point is coincident with the region (including the top-right edges)

rect_range rects() const

Returns a range of all constituent rectangles.

Friends

friend bool operator==(const RectUnion<T> &lhs, const RectUnion<T> &rhs)

Checks whether two RectUnions have identical representations.

Note: does not check whether the representations they are equivalent

friend bool operator!=(const RectUnion<T> &lhs, const RectUnion<T> &rhs)

!= operator