#include <recti/merge_obj.hpp>
template<typename T1 = int, typename T2 = T1>
MergeObj class
Merging Object (for deferred-merge embedding (DME) algorithm)
Template parameters | |
---|---|
T1 | int or Interval |
T2 | int or Interval |
The code is defining a class template called MergeObj
that represents a merging segment. The merging segment can include a single point, segment, or region. The template has two type parameters T1
and T2
, which default to int
if not specified. The class inherits from the Point
class, which represents a point in a 2D coordinate system. The MergeObj
class provides various operations and functions for manipulating and comparing merging segments, such as adding and subtracting vectors, checking for overlap and intersection with other merging segments, calculating the minimum distance between merging segments, and merging two merging segments. The class also provides comparison operators and a stream insertion operator for convenient usage. The purpose of the MergeObj
class is to support the deferred-merge embedding (DME) algorithm, as referenced in the code comments.
Reference:
- Ting-Hai Chao, Yu-Chin Hsu, Jan-Ming Ho and A. B. Kahng, "Zero skew clock routing with minimum wirelength," in IEEE Transactions on Circuits and Systems II: Analog and Digital Signal Processing, vol. 39, no. 11, pp. 799-814, Nov. 1992, doi: 10.1109/82.204128.
Public static functions
Constructors, destructors, conversion operators
Comparison operators
definie ==, !=, <, >, <=, >=.
-
template<typename U1, typename U2>auto operator==(const MergeObj<U1, U2>& rhs) const -> bool -> auto constexpr
- Compares two
MergeObj
objects for equality. -
template<typename U1, typename U2>auto operator!=(const MergeObj<U1, U2>& rhs) const -> bool -> auto constexpr
- Not equal to.
-
template<typename U>auto operator+=(const Vector2<U>& rhs) -> MergeObj & -> auto constexpr
- Add a vector (translation) to this
MergeObj
. -
template<typename U>auto operator-=(const Vector2<U>& rhs) -> MergeObj & -> auto constexpr
- Subtract a vector (translation)
-
template<typename U1, typename U2>auto overlaps(const MergeObj<U1, U2>& other) const -> bool -> auto constexpr
- Check if two
MergeObj
objects overlap. -
template<typename U1, typename U2>auto intersect_with(const MergeObj<U1, U2>& other) const -> auto constexpr
- Compute the intersection of two
MergeObj
objects. -
template<typename U1, typename U2>auto min_dist_with(const MergeObj<U1, U2>& other) const -> auto constexpr
- Compute the minimum distance between the x and y coordinates of two
MergeObj
objects. -
template<typename U1, typename U2>auto merge_with(const MergeObj<U1, U2>& other) const -> auto constexpr
- Compute the intersection of two
MergeObj
objects by enlarging them and finding the overlap. -
template<typename U>auto operator+(MergeObj lhs, const Vector2<U>& rhs) -> MergeObj -> friend auto constexpr
- Add a vector (translation) to a
MergeObj
. -
template<typename U>auto operator-(MergeObj lhs, const Vector2<U>& rhs) -> MergeObj -> friend auto constexpr
- Subtract a vector (translation) from a
MergeObj
. -
template<typename R>auto enlarge(const MergeObj& lhs, const R& alpha) -> friend auto constexpr
- Enlarge a
MergeObj
object by a given scale factor. -
template<class Stream>auto operator<<(Stream& out, const MergeObj& merge_obj) -> Stream & -> auto
- Overload the stream insertion operator
<<
to output aMergeObj
object.
Function documentation
template<typename T1, typename T2>
static auto recti:: MergeObj<T1, T2>:: construct(T1&& xcoord,
T2&& ycoord) -> MergeObj constexpr
Construct a new MergeObj object from the given x and y coordinates.
Parameters | |
---|---|
xcoord in | The x coordinate value. |
ycoord in | The y coordinate value. |
Returns | A new MergeObj object constructed from the given coordinates. |
This static member function constructs a new MergeObj
object by combining the given xcoord
and ycoord
parameters in a specific way. The resulting MergeObj
object represents a merging segment that can include a single point, segment, or region.
template<typename T1, typename T2>
recti:: MergeObj<T1, T2>:: MergeObj(T1&& xcoord,
T2&& ycoord) constexpr noexcept
Construct a new MergeObj object.
Parameters | |
---|---|
xcoord in | The x coordinate value. |
ycoord in | The y coordinate value. |
This code defines a constructor for the MergeObj
class template. The constructor takes two parameters xcoord
and ycoord
, which are of type T1
and T2
respectively. The constructor is marked as constexpr
and noexcept
, indicating that it can be evaluated at compile-time and it does not throw any exceptions.
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: MergeObj<T1, T2>:: operator==(const MergeObj<U1, U2>& rhs) const -> bool constexpr
Compares two MergeObj
objects for equality.
Template parameters | |
---|---|
U1 | The type of the x-coordinate of the right-hand side MergeObj . |
U2 | The type of the y-coordinate of the right-hand side MergeObj . |
Parameters | |
rhs in | The MergeObj object to compare against. |
Returns | true if the two MergeObj objects are equal, false otherwise. |
This operator overload compares two MergeObj
objects for equality. It returns true
if the underlying Point<T1, T2>
objects are equal, and false
otherwise.
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: MergeObj<T1, T2>:: operator!=(const MergeObj<U1, U2>& rhs) const -> bool constexpr
Not equal to.
Template parameters | |
---|---|
U1 | The type of the x-coordinate of the right-hand side MergeObj . |
U2 | The type of the y-coordinate of the right-hand side MergeObj . |
Parameters | |
rhs in | The MergeObj object to compare against. |
Returns | true if the two MergeObj objects are not equal, false otherwise. |
Compares two MergeObj
objects for inequality.
This operator overload compares two MergeObj
objects for inequality. It returns true
if the underlying Point<T1, T2>
objects are not equal, and false
otherwise.
template<typename T1, typename T2>
template<typename U>
auto recti:: MergeObj<T1, T2>:: operator+=(const Vector2<U>& rhs) -> MergeObj & constexpr
Add a vector (translation) to this MergeObj
.
Template parameters | |
---|---|
U | The type of the components of the Vector2<U> to add. |
Parameters | |
rhs in | The Vector2<U> to add to this MergeObj . |
Returns | A reference to this MergeObj after the addition. |
This operator overload adds a Vector2<U>
to this MergeObj
object, modifying the x and y coordinates accordingly. The x coordinate is updated by adding the sum of the x and y components of the Vector2<U>
, while the y coordinate is updated by adding the difference of the x and y components.
template<typename T1, typename T2>
template<typename U>
auto recti:: MergeObj<T1, T2>:: operator-=(const Vector2<U>& rhs) -> MergeObj & constexpr
Subtract a vector (translation)
Template parameters | |
---|---|
U | The type of the components of the Vector2<U> to subtract. |
Parameters | |
rhs in | The Vector2<U> to subtract from this MergeObj . |
Returns | A reference to this MergeObj after the subtraction. |
This operator overload subtracts a Vector2<U>
from this MergeObj
object, modifying the x and y coordinates accordingly. The x coordinate is updated by subtracting the sum of the x and y components of the Vector2<U>
, while the y coordinate is updated by subtracting the difference of the x and y components.
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: MergeObj<T1, T2>:: overlaps(const MergeObj<U1, U2>& other) const -> bool constexpr
Check if two MergeObj
objects overlap.
Template parameters | |
---|---|
U1 | The type of the x and y coordinates of the current MergeObj object. |
U2 | The type of the x and y coordinates of the MergeObj object other . |
Parameters | |
other | The MergeObj object to check for overlap. |
Returns | true if the two MergeObj objects overlap, false otherwise. |
This function checks if the x and y coordinates of the current MergeObj
object overlap with the x and y coordinates of the provided MergeObj
object other
. The overlap is determined by checking if the ranges of the x and y coordinates intersect.
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: MergeObj<T1, T2>:: intersect_with(const MergeObj<U1, U2>& other) const constexpr
Compute the intersection of two MergeObj
objects.
Template parameters | |
---|---|
U1 | The type of the x and y coordinates of the current MergeObj object. |
U2 | The type of the x and y coordinates of the MergeObj object other . |
Parameters | |
other in | The MergeObj object to intersect with the current MergeObj object. |
Returns | A new MergeObj object representing the intersection of the two input MergeObj objects. |
This function computes the intersection of the current MergeObj
object with the provided MergeObj
object other
. The intersection is calculated by finding the intersection of the x and y coordinate ranges of the two MergeObj
objects. The resulting MergeObj
object represents the overlapping region between the two input MergeObj
objects.
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: MergeObj<T1, T2>:: min_dist_with(const MergeObj<U1, U2>& other) const constexpr
Compute the minimum distance between the x and y coordinates of two MergeObj
objects.
Template parameters | |
---|---|
U1 | The type of the x and y coordinates of the current MergeObj object. |
U2 | The type of the x and y coordinates of the MergeObj object other . |
Parameters | |
other in | The MergeObj object to compute the maximum distance with. |
Returns | The maximum distance between the two MergeObj objects. |
This function calculates the maximum distance between the x and y coordinates of the current MergeObj
object and the provided MergeObj
object other
. The distance is computed by taking the maximum of the distances between the x coordinates and the distances between the y coordinates of the two MergeObj
objects.
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: MergeObj<T1, T2>:: merge_with(const MergeObj<U1, U2>& other) const constexpr
Compute the intersection of two MergeObj
objects by enlarging them and finding the overlap.
Template parameters | |
---|---|
U1 | The type of the x and y coordinates of the current MergeObj object. |
U2 | The type of the x and y coordinates of the MergeObj object other . |
Parameters | |
other in | The MergeObj object to compute the intersection with. |
Returns | The intersection of the two MergeObj objects. |
This function first calculates the minimum distance between the x and y coordinates of the current MergeObj
object and the provided MergeObj
object other
. It then uses this distance to enlarge both MergeObj
objects, with the current object being enlarged by half the distance and the other
object being enlarged by the remaining half. Finally, it computes the intersection of the two enlarged MergeObj
objects and returns the result.
template<typename T1, typename T2>
template<typename U>
friend auto recti:: MergeObj<T1, T2>:: operator+(MergeObj lhs,
const Vector2<U>& rhs) -> MergeObj constexpr
Add a vector (translation) to a MergeObj
.
Template parameters | |
---|---|
U | The type of the components of the Vector2<U> to add. |
Parameters | |
lhs | The MergeObj to add the vector to. |
rhs | The Vector2<U> to add to the MergeObj . |
Returns | A new MergeObj with the vector added. |
This operator overload adds a Vector2<U>
to a MergeObj
object, modifying the x and y coordinates accordingly. The x coordinate is updated by adding the sum of the x and y components of the Vector2<U>
, while the y coordinate is updated by adding the difference of the x and y components.
template<typename T1, typename T2>
template<typename U>
friend auto recti:: MergeObj<T1, T2>:: operator-(MergeObj lhs,
const Vector2<U>& rhs) -> MergeObj constexpr
Subtract a vector (translation) from a MergeObj
.
Template parameters | |
---|---|
U | The type of the components of the Vector2<U> to subtract. |
Parameters | |
lhs | The MergeObj to subtract the vector from. |
rhs | The Vector2<U> to subtract from the MergeObj . |
Returns | A new MergeObj with the vector subtracted. |
This operator overload subtracts a Vector2<U>
from a MergeObj
object, modifying the x and y coordinates accordingly. The x coordinate is updated by subtracting the sum of the x and y components of the Vector2<U>
, while the y coordinate is updated by subtracting the difference of the x and y components.
template<typename T1, typename T2>
template<typename R>
friend auto recti:: MergeObj<T1, T2>:: enlarge(const MergeObj& lhs,
const R& alpha) constexpr
Enlarge a MergeObj
object by a given scale factor.
Template parameters | |
---|---|
R | The type of the scale factor alpha . |
Parameters | |
lhs in | The MergeObj object to be enlarged. |
alpha in | The scale factor to enlarge the MergeObj object by. |
Returns | A new MergeObj object with enlarged x and y coordinates. |
This function creates a new MergeObj
object by enlarging the x and y coordinates of the input MergeObj
object lhs
by the given scale factor alpha
. The resulting MergeObj
object will have larger x and y coordinate ranges compared to the input MergeObj
object.
template<typename T1, typename T2>
template<class Stream>
auto recti:: MergeObj<T1, T2>:: operator<<(Stream& out,
const MergeObj& merge_obj) -> Stream &
Overload the stream insertion operator <<
to output a MergeObj
object.
Template parameters | |
---|---|
Stream | The type of the output stream. |
Parameters | |
out out | The output stream to write the MergeObj object to. |
merge_obj in | The MergeObj object to be written to the output stream. |
Returns | The modified output stream. |
This function overloads the stream insertion operator <<
to output a MergeObj
object in the format "/{xcoord}, {ycoord}/"
, where {xcoord}
and {ycoord}
are the x and y coordinates of the MergeObj
object, respectively.