KLayout Manual: Main Index » Class Index » API reference - Class Edge

API reference - Class Edge

Notation used in Ruby API documentation

Description: An edge class

An edge is a connection between points, usually participating in a larger context such as a polygon. An edge has a defined direction (from p1 to p2).

Public constructors

new EdgenewDefault constructor: creates a degenerated edge 0,0 to 0,0
new Edgenew(int x1,
int y1,
int x2,
int y2)
Constructor with two coordinates given as single values
new Edgenew(const Point p1,
const Point p2)
Constructor with two points

Public methods

[const]bool!=(const Edge e)Inequality test
[const]Edge*(double scale_factor)Scale edge
[const]bool<(const Edge e)Less operator
[const]bool==(const Edge e)Equality test
[const]voidassign(const Edge other)Assign the contents of another object to self
[const]BoxbboxReturn the bounding box of the edge.
[const]boolcoincident?(const Edge e)Coincidence check.
[const]boolcontains?(const Point p)Test whether a point is on an edge.
[const]boolcontains_excl?(const Point p)Test whether a point is on an edge excluding the endpoints.
voidcreateEnsures the C++ object is created
[const]boolcrossed_by?(const Edge e)Check, if an edge is cut by a line (given by an edge)
[const]Pointcrossing_point(const Edge e)Returns the crossing point on two edges.
voiddestroyExplicitly destroy the object
[const]booldestroyed?Returns a value indicating whether the object was already destroyed
[const]intdistance(const Point p)Distance between the edge and a point.
[const]unsigned intdistance_abs(const Point p)Absolute distance between the edge and a point.
[const]EdgedupCreates a copy of self
[const]intdxThe horizontal extend of the edge.
[const]unsigned intdx_absThe absolute value of the horizontal extend of the edge.
[const]intdyThe vertical extend of the edge.
[const]unsigned intdy_absThe vertical extend of the edge.
Edgeenlarge(const Point p)Enlarges the edge.
[const]Edgeenlarged(const Point p)Returns the enlarged edge
[const]boolintersect?(const Edge e)Intersection test.
[const]Pointintersection_point(const Edge e)Returns the intersection point of two edges.
[const]boolis_const_object?Returns a value indicating whether the reference is a const reference
[const]boolis_degenerate?Test for degenerated edge
[const]boolis_parallel?(const Edge e)Test for being parallel
[const]unsigned intlengthThe length of the edge
Edgemove(const Point p)Moves the edge.
[const]Edgemoved(const Point p)Returns the moved edge
[const]unsigned intortho_lengthThe orthogonal length of the edge ("manhattan-length")
[const]Pointp1The first point.
[const]Pointp2The second point.
[const]intside_of(const Point p)Indicates at which side the point is located relative to the edge.
[const]long longsq_lengthThe square of the length of the edge
voidswap_pointsSwap the points of the edge
[const]stringto_sConvert to a string
[const]Edgetransformed(const Trans t)Transform the edge.
[const]Edgetransformed_cplx(const ICplxTrans t)Transform the edge.
[const]DEdgetransformed_cplx(const CplxTrans t)Transform the edge.
[const]intx1Shortcut for p1.x
[const]intx2Shortcut for p2.x
[const]inty1Shortcut for p1.y
[const]inty2Shortcut for p2.y

Public static methods and constants

Edgefrom_dedge(const DEdge double_edge)Construct an integer coordinate edge from a floating-point coordinate edge

Deprecated methods (protected, public, static, non-static and constructors)

[static]new Edgenew_pp(const Point p1,
const Point p2)
Use of this method is deprecated. Use new instead
[static]new Edgenew_xyxy(int x1,
int y1,
int x2,
int y2)
Use of this method is deprecated. Use new instead

Detailed description

[const] bool !=(const Edge e)

Description: Inequality test

e:The object to compare against

[const] Edge *(double scale_factor)

Description: Scale edge

scale_factor:The scaling factor
Returns:The scaled edge

The * operator scales self with the given factor.

This method has been introduced in version 0.22.

[const] bool <(const Edge e)

Description: Less operator

e:The object to compare against
Returns:True, if the edge is 'less' as the other edge with respect to first and second point

[const] bool ==(const Edge e)

Description: Equality test

e:The object to compare against

[const] void assign(const Edge other)

Description: Assign the contents of another object to self

This method assigns the contents of another object to self. This is a deep copy that does not only copy the reference but the actual content.

[const] Box bbox

Description: Return the bounding box of the edge.

[const] bool coincident?(const Edge e)

Description: Coincidence check.

e:the edge to test with
Returns:True if the edges are coincident.

Checks whether a edge is coincident with another edge. Coincidence is defined by being parallel and that at least one point of one edge is on the other edge.

[const] bool contains?(const Point p)

Description: Test whether a point is on an edge.

p:The point to test with the edge.
Returns:True if the point is on the edge.

A point is on a edge if it is on (or at least closer than a grid point to) the edge.

[const] bool contains_excl?(const Point p)

Description: Test whether a point is on an edge excluding the endpoints.

p:The point to test with the edge.
Returns:True if the point is on the edge but not equal p1 or p2.

A point is on a edge if it is on (or at least closer than a grid point to) the edge.

void create

Description: Ensures the C++ object is created

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

[const] bool crossed_by?(const Edge e)

Description: Check, if an edge is cut by a line (given by an edge)

e:The edge representing the line that the edge must be crossing.

This method returns true if p1 is in one semispace while p2 is in the other or one of them is on the line through the edge "e"

[const] Point crossing_point(const Edge e)

Description: Returns the crossing point on two edges.

e:The edge representing the line that self must be crossing.
Returns:The point where self crosses the line given by "e".

This method delivers the point where the given edge (self) crosses the line given by the edge in argument "e". If self does not cross this line, the result is undefined. See crossed_by? for a description of the crossing predicate.

This method has been introduced in version 0.19.

void destroy

Description: Explicitly destroy the object

Explicitly destroy the object on C++ side if it was owned by the Ruby interpreter. Subsequent access to this object will throw an exception. If the object is not owned by Ruby, this method will do nothing.

[const] bool destroyed?

Description: Returns a value indicating whether the object was already destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

[const] int distance(const Point p)

Description: Distance between the edge and a point.

p:The point to test.
Returns:The distance

Returns the distance between the edge and the point. The distance is signed which is negative if the point is to the "left" of the edge and positive if the point is to the "right". The distance is measured by projecting the point onto the line through the edge. If the edge is degenerated, the distance is not defined.

[const] unsigned int distance_abs(const Point p)

Description: Absolute distance between the edge and a point.

p:The point to test.
Returns:The distance

Returns the distance between the edge and the point.

[const] Edge dup

Description: Creates a copy of self

[const] int dx

Description: The horizontal extend of the edge.

[const] unsigned int dx_abs

Description: The absolute value of the horizontal extend of the edge.

[const] int dy

Description: The vertical extend of the edge.

[const] unsigned int dy_abs

Description: The vertical extend of the edge.

Edge enlarge(const Point p)

Description: Enlarges the edge.

p:The distance to move the edge points.
Returns:The enlarged edge.

Enlarges the edge by the given distance and returns the enlarged edge. The edge is overwritten.

[const] Edge enlarged(const Point p)

Description: Returns the enlarged edge

p:The distance to move the edge.
Returns:The moved edge.

Enlarges the edge by the given offset and returns the moved edge. The edge is not modified. Enlargement means that the first point is shifted by -p, the second by p.

[static] Edge from_dedge(const DEdge double_edge)

Description: Construct an integer coordinate edge from a floating-point coordinate edge

Create a integer coordinate edge from a floating-point coordinate edge

[const] bool intersect?(const Edge e)

Description: Intersection test.

e:The edge to test.

Returns true if the edges intersect. Two edges intersect if they share at least one point. If the edges coincide, they also intersect. For degenerated edges, the intersection is mapped to point containment tests.

[const] Point intersection_point(const Edge e)

Description: Returns the intersection point of two edges.

e:The edge to test.
Returns:The point where the edges intersect.

This method delivers the intersection point. If the edges do not intersect, the result is undefined.

This method has been introduced in version 0.19.

[const] bool is_const_object?

Description: Returns a value indicating whether the reference is a const reference

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

[const] bool is_degenerate?

Description: Test for degenerated edge

An edge is degenerate, if both end and start point are identical.

[const] bool is_parallel?(const Edge e)

Description: Test for being parallel

e:The edge to test against
Returns:True if both edges are parallel

[const] unsigned int length

Description: The length of the edge

Edge move(const Point p)

Description: Moves the edge.

p:The distance to move the edge.
Returns:The moved edge.

Moves the edge by the given offset and returns the moved edge. The edge is overwritten.

[const] Edge moved(const Point p)

Description: Returns the moved edge

p:The distance to move the edge.
Returns:The moved edge.

Moves the edge by the given offset and returns the moved edge. The edge is not modified.

[static] new Edge new

Description: Default constructor: creates a degenerated edge 0,0 to 0,0

[static] new Edge new(int x1,int y1,int x2,int y2)

Description: Constructor with two coordinates given as single values

Two points are given to create a new edge.

[static] new Edge new(const Point p1,const Point p2)

Description: Constructor with two points

Two points are given to create a new edge.

[static] new Edge new_pp(const Point p1,const Point p2)

Description: Constructor with two points

This method is deprecated. Use method 'new' instead

[static] new Edge new_xyxy(int x1,int y1,int x2,int y2)

Description: Constructor with two coordinates given as single values

This method is deprecated. Use method 'new' instead

[const] unsigned int ortho_length

Description: The orthogonal length of the edge ("manhattan-length")

Returns:The orthogonal length (abs(dx)+abs(dy))

[const] Point p1

Description: The first point.

[const] Point p2

Description: The second point.

[const] int side_of(const Point p)

Description: Indicates at which side the point is located relative to the edge.

p:The point to test.
Returns:The side value

Returns 1 if the point is "left" of the edge, 0 if on and -1 if the point is "right" of the edge.

[const] long long sq_length

Description: The square of the length of the edge

void swap_points

Description: Swap the points of the edge

[const] string to_s

Description: Convert to a string

[const] Edge transformed(const Trans t)

Description: Transform the edge.

t:The transformation to apply.
Returns:The transformed edge.

Transforms the edge with the given transformation. Does not modify the edge but returns the transformed edge.

[const] Edge transformed_cplx(const ICplxTrans t)

Description: Transform the edge.

t:The transformation to apply.
Returns:The transformed edge (in this case an integer coordinate edge).

Transforms the edge with the given complex transformation. Does not modify the edge but returns the transformed edge.

This method has been introduced in version 0.18.

[const] DEdge transformed_cplx(const CplxTrans t)

Description: Transform the edge.

t:The transformation to apply.
Returns:The transformed edge.

Transforms the edge with the given complex transformation. Does not modify the edge but returns the transformed edge.

[const] int x1

Description: Shortcut for p1.x

[const] int x2

Description: Shortcut for p2.x

[const] int y1

Description: Shortcut for p1.y

[const] int y2

Description: Shortcut for p2.y