API reference - Class DEdge

Notation used in Ruby API documentation

Module: db

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). Edges play a role in the database as parts of polygons and to describe a line through both points. The Edge object is also used inside the boolean processor (EdgeProcessor). Although supported, edges are rarely used as individual database objects.

See The Database API for more details about the database objects like the Edge class.

Public constructors

new DEdge ptrnew(const Edge edge)Creates a floating-point coordinate edge from an integer coordinate edge
new DEdge ptrnewDefault constructor: creates a degenerated edge 0,0 to 0,0
new DEdge ptrnew(double x1,
double y1,
double x2,
double y2)
Constructor with two coordinates given as single values
new DEdge ptrnew(const DPoint p1,
const DPoint p2)
Constructor with two points

Public methods

[const]bool!=(const DEdge e)Inequality test
[const]DEdge*(double scale_factor)Scale edge
[const]bool<(const DEdge e)Less operator
[const]bool==(const DEdge e)Equality test
void_createEnsures the C++ object is created
void_destroyExplicitly destroys the object
[const]bool_destroyed?Returns a value indicating whether the object was already destroyed
[const]bool_is_const_object?Returns a value indicating whether the reference is a const reference
void_manageMarks the object as managed by the script side.
void_unmanageMarks the object as no longer owned by the script side.
voidassign(const DEdge other)Assigns another object to self
[const]DBoxbboxReturn the bounding box of the edge.
[const]variantclipped(const DBox box)Returns the edge clipped at the given box
[const]variantclipped_line(const DBox box)Returns the line through the edge clipped at the given box
[const]boolcoincident?(const DEdge e)Coincidence check.
[const]boolcontains?(const DPoint p)Test whether a point is on an edge.
[const]boolcontains_excl?(const DPoint p)Test whether a point is on an edge excluding the endpoints.
[const]boolcrossed_by?(const DEdge e)Check, if an edge is cut by a line (given by an edge)
[const]DPointcrossing_point(const DEdge e)Returns the crossing point on two edges.
[const]variantcut_point(const DEdge e)Returns the intersection point of the lines through the two edges.
[const]DVectordGets the edge extension as a vector.
[const]doubledistance(const DPoint p)Distance between the edge and a point.
[const]doubledistance_abs(const DPoint p)Absolute distance between the edge and a point.
[const]new DEdge ptrdupCreates a copy of self
[const]doubledxThe horizontal extend of the edge.
[const]doubledx_absThe absolute value of the horizontal extend of the edge.
[const]doubledyThe vertical extend of the edge.
[const]doubledy_absThe absolute value of the vertical extend of the edge.
DEdgeenlarge(const DVector p)Enlarges the edge.
[const]DEdgeenlarged(const DVector p)Returns the enlarged edge (does not modify self)
DEdgeextend(double d)Extends the edge (modifies self)
[const]DEdgeextended(double d)Returns the extended edge (does not modify self)
[const]unsigned longhashComputes a hash value
[const]boolintersect?(const DEdge e)Intersection test.
[const]variantintersection_point(const DEdge e)Returns the intersection point of two edges.
[const]boolis_degenerate?Test for degenerated edge
[const]boolis_parallel?(const DEdge e)Test for being parallel
[const]doublelengthThe length of the edge
DEdgemove(const DVector p)Moves the edge.
DEdgemove(double dx,
double dy)
Moves the edge.
[const]DEdgemoved(const DVector p)Returns the moved edge (does not modify self)
[const]DEdgemoved(double dx,
double dy)
Returns the moved edge (does not modify self)
[const]doubleortho_lengthThe orthogonal length of the edge ("manhattan-length")
[const]DPointp1The first point.
voidp1=(const DPoint point)Sets the first point.
[const]DPointp2The second point.
voidp2=(const DPoint point)Sets the second point.
DEdgeshift(double d)Shifts the edge (modifies self)
[const]DEdgeshifted(double d)Returns the shifted edge (does not modify self)
[const]intside_of(const DPoint p)Indicates at which side the point is located relative to the edge.
[const]doublesq_lengthThe square of the length of the edge
DEdgeswap_pointsSwap the points of the edge
[const]DEdgeswapped_pointsReturns an edge in which both points are swapped
[const]Edgeto_itype(double dbu = 1)Converts the edge to an integer coordinate edge
[const]stringto_sReturns a string representing the edge
[const]Edgetransformed(const VCplxTrans t)Transforms the edge with the given complex transformation
[const]DEdgetransformed(const DTrans t)Transform the edge.
[const]DEdgetransformed(const DCplxTrans t)Transform the edge.
[const]doublex1Shortcut for p1.x
voidx1=(double coord)Sets p1.x
[const]doublex2Shortcut for p2.x
voidx2=(double coord)Sets p2.x
[const]doubley1Shortcut for p1.y
voidy1=(double coord)Sets p1.y
[const]doubley2Shortcut for p2.y
voidy2=(double coord)Sets p2.y

Public static methods and constants

new DEdge ptrfrom_s(string s)Creates an object from a string

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

voidcreateUse of this method is deprecated. Use _create instead
voiddestroyUse of this method is deprecated. Use _destroy instead
[const]booldestroyed?Use of this method is deprecated. Use _destroyed? instead
[static]new DEdge ptrfrom_iedge(const Edge edge)Use of this method is deprecated. Use new instead
[const]boolis_const_object?Use of this method is deprecated. Use _is_const_object? instead
[static]new DEdge ptrnew_pp(const DPoint p1,
const DPoint p2)
Use of this method is deprecated. Use new instead
[static]new DEdge ptrnew_xyxy(double x1,
double y1,
double x2,
double y2)
Use of this method is deprecated. Use new instead
[const]DEdgetransformed_cplx(const DCplxTrans t)Use of this method is deprecated. Use transformed instead

Detailed description

!=

Signature: [const] bool != (const DEdge e)

Description: Inequality test

e:The object to compare against

*

Signature: [const] DEdge * (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.

Python specific notes:
This method is also available as '__rmul__'

<

Signature: [const] bool < (const DEdge 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

==

Signature: [const] bool == (const DEdge e)

Description: Equality test

e:The object to compare against

_create

Signature: 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.

_destroy

Signature: void _destroy

Description: Explicitly destroys the object

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

_destroyed?

Signature: [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.

_is_const_object?

Signature: [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.

_manage

Signature: void _manage

Description: Marks the object as managed by the script side.

After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required.

Usually it's not required to call this method. It has been introduced in version 0.24.

_unmanage

Signature: void _unmanage

Description: Marks the object as no longer owned by the script side.

Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur.

Usually it's not required to call this method. It has been introduced in version 0.24.

assign

Signature: void assign (const DEdge other)

Description: Assigns another object to self

bbox

Signature: [const] DBox bbox

Description: Return the bounding box of the edge.

clipped

Signature: [const] variant clipped (const DBox box)

Description: Returns the edge clipped at the given box

box:The clip box.
Returns:The clipped edge or nil if the edge does not intersect with the box.

This method has been introduced in version 0.26.2.

clipped_line

Signature: [const] variant clipped_line (const DBox box)

Description: Returns the line through the edge clipped at the given box

box:The clip box.
Returns:The part of the line through the box or nil if the line does not intersect with the box.

In contrast to clipped, this method will consider the edge extended infinitely (a "line"). The returned edge will be the part of this line going through the box.

This method has been introduced in version 0.26.2.

coincident?

Signature: [const] bool coincident? (const DEdge 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.

contains?

Signature: [const] bool contains? (const DPoint 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.

contains_excl?

Signature: [const] bool contains_excl? (const DPoint 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.

create

Signature: void create

Description: Ensures the C++ object is created

Use of this method is deprecated. Use _create instead

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.

crossed_by?

Signature: [const] bool crossed_by? (const DEdge 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"

crossing_point

Signature: [const] DPoint crossing_point (const DEdge 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.

cut_point

Signature: [const] variant cut_point (const DEdge e)

Description: Returns the intersection point of the lines through the two edges.

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

This method delivers the intersection point between the lines through the two edges. If the lines are parallel and do not intersect, the result will be nil. In contrast to intersection_point, this method will regard the edges as infinitely extended and intersection is not confined to the edge span.

This method has been introduced in version 0.27.1.

d

Signature: [const] DVector d

Description: Gets the edge extension as a vector.

This method is equivalent to p2 - p1. This method has been introduced in version 0.26.2.

destroy

Signature: void destroy

Description: Explicitly destroys the object

Use of this method is deprecated. Use _destroy instead

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

destroyed?

Signature: [const] bool destroyed?

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

Use of this method is deprecated. Use _destroyed? instead

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.

distance

Signature: [const] double distance (const DPoint 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 "right" of the edge and positive if the point is to the "left". The distance is measured by projecting the point onto the line through the edge. If the edge is degenerated, the distance is not defined.

distance_abs

Signature: [const] double distance_abs (const DPoint 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.

dup

Signature: [const] new DEdge ptr dup

Description: Creates a copy of self

Python specific notes:
This method also implements '__copy__'

dx

Signature: [const] double dx

Description: The horizontal extend of the edge.

dx_abs

Signature: [const] double dx_abs

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

dy

Signature: [const] double dy

Description: The vertical extend of the edge.

dy_abs

Signature: [const] double dy_abs

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

enlarge

Signature: DEdge enlarge (const DVector 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. Enlargement means that the first point is shifted by -p, the second by p.

enlarged

Signature: [const] DEdge enlarged (const DVector p)

Description: Returns the enlarged edge (does not modify self)

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

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

extend

Signature: DEdge extend (double d)

Description: Extends the edge (modifies self)

d:The distance by which to shift the end points.
Returns:The extended edge (self).

Extends the edge by the given distance and returns the extended edge. The edge is not modified. Extending means that the first point is shifted by -d along the edge, the second by d. The length of the edge will increase by 2*d.

extended is a version that does not modify self but returns the extended edges.

This method has been introduced in version 0.23.

extended

Signature: [const] DEdge extended (double d)

Description: Returns the extended edge (does not modify self)

d:The distance by which to shift the end points.
Returns:The extended edge.

Extends the edge by the given distance and returns the extended edge. The edge is not modified. Extending means that the first point is shifted by -d along the edge, the second by d. The length of the edge will increase by 2*d.

extend is a version that modifies self (in-place).

This method has been introduced in version 0.23.

from_iedge

Signature: [static] new DEdge ptr from_iedge (const Edge edge)

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

Use of this method is deprecated. Use new instead

This constructor has been introduced in version 0.25 and replaces the previous static method 'from_iedge'.

Python specific notes:
This method is the default initializer of the object

from_s

Signature: [static] new DEdge ptr from_s (string s)

Description: Creates an object from a string

Creates the object from a string representation (as returned by to_s)

This method has been added in version 0.23.

hash

Signature: [const] unsigned long hash

Description: Computes a hash value

Returns a hash value for the given edge. This method enables edges as hash keys.

This method has been introduced in version 0.25.

Python specific notes:
This method is also available as 'hash(object)'

intersect?

Signature: [const] bool intersect? (const DEdge 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.

intersection_point

Signature: [const] variant intersection_point (const DEdge 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 will be nil.

This method has been introduced in version 0.19. From version 0.26.2, this method will return nil in case of non-intersection.

is_const_object?

Signature: [const] bool is_const_object?

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

Use of this method is deprecated. Use _is_const_object? instead

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

is_degenerate?

Signature: [const] bool is_degenerate?

Description: Test for degenerated edge

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

is_parallel?

Signature: [const] bool is_parallel? (const DEdge e)

Description: Test for being parallel

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

length

Signature: [const] double length

Description: The length of the edge

move

(1) Signature: DEdge move (const DVector 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.

(2) Signature: DEdge move (double dx, double dy)

Description: Moves the edge.

dx:The x distance to move the edge.
dy:The y 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.

This version has been added in version 0.23.

moved

(1) Signature: [const] DEdge moved (const DVector p)

Description: Returns the moved edge (does not modify self)

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.

(2) Signature: [const] DEdge moved (double dx, double dy)

Description: Returns the moved edge (does not modify self)

dx:The x distance to move the edge.
dy:The y 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.

This version has been added in version 0.23.

new

(1) Signature: [static] new DEdge ptr new (const Edge edge)

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

This constructor has been introduced in version 0.25 and replaces the previous static method 'from_iedge'.

Python specific notes:
This method is the default initializer of the object

(2) Signature: [static] new DEdge ptr new

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

Python specific notes:
This method is the default initializer of the object

(3) Signature: [static] new DEdge ptr new (double x1, double y1, double x2, double y2)

Description: Constructor with two coordinates given as single values

Two points are given to create a new edge.

Python specific notes:
This method is the default initializer of the object

(4) Signature: [static] new DEdge ptr new (const DPoint p1, const DPoint p2)

Description: Constructor with two points

Two points are given to create a new edge.

Python specific notes:
This method is the default initializer of the object

new_pp

Signature: [static] new DEdge ptr new_pp (const DPoint p1, const DPoint p2)

Description: Constructor with two points

Use of this method is deprecated. Use new instead

Two points are given to create a new edge.

Python specific notes:
This method is the default initializer of the object

new_xyxy

Signature: [static] new DEdge ptr new_xyxy (double x1, double y1, double x2, double y2)

Description: Constructor with two coordinates given as single values

Use of this method is deprecated. Use new instead

Two points are given to create a new edge.

Python specific notes:
This method is the default initializer of the object

ortho_length

Signature: [const] double ortho_length

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

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

p1

Signature: [const] DPoint p1

Description: The first point.

Python specific notes:
The object exposes a readable attribute 'p1'. This is the getter.

p1=

Signature: void p1= (const DPoint point)

Description: Sets the first point.

This method has been added in version 0.23.

Python specific notes:
The object exposes a writable attribute 'p1'. This is the setter.

p2

Signature: [const] DPoint p2

Description: The second point.

Python specific notes:
The object exposes a readable attribute 'p2'. This is the getter.

p2=

Signature: void p2= (const DPoint point)

Description: Sets the second point.

This method has been added in version 0.23.

Python specific notes:
The object exposes a writable attribute 'p2'. This is the setter.

shift

Signature: DEdge shift (double d)

Description: Shifts the edge (modifies self)

d:The distance by which to shift the edge.
Returns:The shifted edge (self).

Shifts the edge by the given distance and returns the shifted edge. The edge is not modified. Shifting by a positive value will produce an edge which is shifted by d to the left. Shifting by a negative value will produce an edge which is shifted by d to the right.

shifted is a version that does not modify self but returns the extended edges.

This method has been introduced in version 0.23.

shifted

Signature: [const] DEdge shifted (double d)

Description: Returns the shifted edge (does not modify self)

d:The distance by which to shift the edge.
Returns:The shifted edge.

Shifts the edge by the given distance and returns the shifted edge. The edge is not modified. Shifting by a positive value will produce an edge which is shifted by d to the left. Shifting by a negative value will produce an edge which is shifted by d to the right.

shift is a version that modifies self (in-place).

This method has been introduced in version 0.23.

side_of

Signature: [const] int side_of (const DPoint 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.

sq_length

Signature: [const] double sq_length

Description: The square of the length of the edge

swap_points

Signature: DEdge swap_points

Description: Swap the points of the edge

This version modifies self. A version that does not modify self is swapped_points. Swapping the points basically reverses the direction of the edge.

This method has been introduced in version 0.23.

swapped_points

Signature: [const] DEdge swapped_points

Description: Returns an edge in which both points are swapped

Swapping the points basically reverses the direction of the edge.

This method has been introduced in version 0.23.

to_itype

Signature: [const] Edge to_itype (double dbu = 1)

Description: Converts the edge to an integer coordinate edge

The database unit can be specified to translate the floating-point coordinate edge in micron units to an integer-coordinate edge in database units. The edges coordinates will be divided by the database unit.

This method has been introduced in version 0.25.

to_s

Signature: [const] string to_s

Description: Returns a string representing the edge

Python specific notes:
This method is also available as 'str(object)'

transformed

(1) Signature: [const] Edge transformed (const VCplxTrans t)

Description: Transforms the edge with the given complex transformation

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

This method has been introduced in version 0.25.

(2) Signature: [const] DEdge transformed (const DTrans 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.

(3) Signature: [const] DEdge transformed (const DCplxTrans 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.

transformed_cplx

Signature: [const] DEdge transformed_cplx (const DCplxTrans t)

Description: Transform the edge.

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

Use of this method is deprecated. Use transformed instead

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

x1

Signature: [const] double x1

Description: Shortcut for p1.x

Python specific notes:
The object exposes a readable attribute 'x1'. This is the getter.

x1=

Signature: void x1= (double coord)

Description: Sets p1.x

This method has been added in version 0.23.

Python specific notes:
The object exposes a writable attribute 'x1'. This is the setter.

x2

Signature: [const] double x2

Description: Shortcut for p2.x

Python specific notes:
The object exposes a readable attribute 'x2'. This is the getter.

x2=

Signature: void x2= (double coord)

Description: Sets p2.x

This method has been added in version 0.23.

Python specific notes:
The object exposes a writable attribute 'x2'. This is the setter.

y1

Signature: [const] double y1

Description: Shortcut for p1.y

Python specific notes:
The object exposes a readable attribute 'y1'. This is the getter.

y1=

Signature: void y1= (double coord)

Description: Sets p1.y

This method has been added in version 0.23.

Python specific notes:
The object exposes a writable attribute 'y1'. This is the setter.

y2

Signature: [const] double y2

Description: Shortcut for p2.y

Python specific notes:
The object exposes a readable attribute 'y2'. This is the getter.

y2=

Signature: void y2= (double coord)

Description: Sets p2.y

This method has been added in version 0.23.

Python specific notes:
The object exposes a writable attribute 'y2'. This is the setter.