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

API reference - Class SimplePolygon

Notation used in Ruby API documentation

Description: A simple polygon class

A simple polygon consists of an outer hull only. The hull contour consists of several points. The point list is normalized such that the leftmost, lowest point is the first one. The orientation is normalized such that the orientation of the hull contour is clockwise.

It is in no way checked that the contours are not overlapping This must be ensured by the user of the object when filling the contours.

Public constructors

new SimplePolygonnewDefault constructor: creates an empty (invalid) polygon
new SimplePolygonnew(Point[] pts)Constructor given the points of the simple polygon
new SimplePolygonnew(const Box box)Constructor converting a box to a polygon

Public methods

[const]bool!=(const SimplePolygon arg1)Inequality test
[const]bool==(const SimplePolygon arg1)Equality test
[const]long longareaThe area of the polygon
[const]voidassign(const SimplePolygon other)Assign the contents of another object to self
[const]BoxbboxReturn the bounding box of the simple polygon
voidcompress(bool remove_reflected)Compress the simple polygon.
voidcreateEnsures the C++ object is created
voiddestroyExplicitly destroy the object
[const]booldestroyed?Returns a value indicating whether the object was already destroyed
[const]SimplePolygondupCreates a copy of self
[iter]Edgeeach_edgeIterate over the edges that make up the simple polygon
[const,iter]Pointeach_pointIterate over the points that make up the simple polygon
[const]boolinside?(Point p)Test, if the given point is inside the polygon
[const]boolis_const_object?Returns a value indicating whether the reference is a const reference
[const]Polygonminkowsky_sum(const Edge a,
bool b)
Compute the Minkowsky sum of a polygon and an edge
[const]Polygonminkowsky_sum(const SimplePolygon a,
bool b)
Compute the Minkowsky sum of a polygon and a polygon
[const]Polygonminkowsky_sum(const Box a,
bool b)
Compute the Minkowsky sum of a polygon and a box
[const]Polygonminkowsky_sum(Point[] a,
bool b)
Compute the Minkowsky sum of a polygon and a contour of points (a trace)
SimplePolygonmove(const Point p)Moves the simple polygon.
[const]SimplePolygonmoved(const Point p)Returns the moved simple polygon
unsigned intnum_pointsGet the number of points
Pointpoint(unsigned int arg1)Get a specific point of the contour@args p
voidpoints=(Point[] p)Set the points of the simple polygon
[const]Polygonround_corners(double rinner,
double router,
unsigned int n)
Round the corners of the polygon
[const]stringto_sConvert to a string
[const]SimplePolygontransformed(const Trans t)Transform the simple polygon.
[const]DSimplePolygontransformed_cplx(const CplxTrans t)Transform the simple polygon.
[const]SimplePolygontransformed_cplx(const ICplxTrans t)Transform the simple polygon.

Public static methods and constants

SimplePolygonfrom_dpoly(const DSimplePolygon double_poly)Construct an integer-coordinate polygon from a floating-point coordinate one

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

[const]boolinside(Point p)Use of this method is deprecated. Use inside? instead
[static]new SimplePolygonnew_b(const Box box)Use of this method is deprecated. Use new instead
[static]new SimplePolygonnew_p(Point[] pts)Use of this method is deprecated. Use new instead
unsigned intpointsUse of this method is deprecated. Use num_points instead

Detailed description

[const] bool !=(const SimplePolygon arg1)

Description: Inequality test

[const] bool ==(const SimplePolygon arg1)

Description: Equality test

[const] long long area

Description: The area of the polygon

The area is correct only if the polygon is not self-overlapping and the polygon is oriented clockwise.

[const] void assign(const SimplePolygon 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 simple polygon

void compress(bool remove_reflected)

Description: Compress the simple polygon.

remove_reflected:See description of the functionality.

This method removes redundant points from the polygon, such as points being on a line formed by two other points. If remove_reflected is true, points are also removed if the two adjacent edges form a spike.

This method was introduced in version 0.18.

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.

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] SimplePolygon dup

Description: Creates a copy of self

[iter] Edge each_edge

Description: Iterate over the edges that make up the simple polygon

[const,iter] Point each_point

Description: Iterate over the points that make up the simple polygon

[static] SimplePolygon from_dpoly(const DSimplePolygon double_poly)

Description: Construct an integer-coordinate polygon from a floating-point coordinate one

This method has been added in version 0.15.

[const] bool inside(Point p)

Description: Test, if the given point is inside the polygon

This method is deprecated. Use method 'inside?' instead

[const] bool inside?(Point p)

Description: Test, if the given point is inside the polygon

If the given point is inside the polygon, true is returned. This tests works well only if the polygon is not self-overlapping and oriented clockwise.

[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] Polygon minkowsky_sum(const Edge a,bool b)

Description: Compute the Minkowsky sum of a polygon and an edge

a:The first argument.
b:The second argument.
resolve_holes:If true, the output polygon will not contain holes, but holes are resolved by joining the holes with the hull.
Returns:The new polygon representing the Minkowsky sum of a and b.

This method was introduced in version 0.22.

[const] Polygon minkowsky_sum(const SimplePolygon a,bool b)

Description: Compute the Minkowsky sum of a polygon and a polygon

a:The first argument.
b:The second argument.
resolve_holes:If true, the output polygon will not contain holes, but holes are resolved by joining the holes with the hull.
Returns:The new polygon representing the Minkowsky sum of a and b.

This method was introduced in version 0.22.

[const] Polygon minkowsky_sum(const Box a,bool b)

Description: Compute the Minkowsky sum of a polygon and a box

a:The first argument.
b:The second argument.
resolve_holes:If true, the output polygon will not contain holes, but holes are resolved by joining the holes with the hull.
Returns:The new polygon representing the Minkowsky sum of a and b.

This method was introduced in version 0.22.

[const] Polygon minkowsky_sum(Point[] a,bool b)

Description: Compute the Minkowsky sum of a polygon and a contour of points (a trace)

a:The first argument.
b:The second argument (a series of points forming the trace).
resolve_holes:If true, the output polygon will not contain holes, but holes are resolved by joining the holes with the hull.
Returns:The new polygon representing the Minkowsky sum of a and b.

This method was introduced in version 0.22.

SimplePolygon move(const Point p)

Description: Moves the simple polygon.

p:The distance to move the simple polygon.
Returns:The moved simple polygon.

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

[const] SimplePolygon moved(const Point p)

Description: Returns the moved simple polygon

p:The distance to move the simple polygon.
Returns:The moved simple polygon.

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

[static] new SimplePolygon new

Description: Default constructor: creates an empty (invalid) polygon

[static] new SimplePolygon new(Point[] pts)

Description: Constructor given the points of the simple polygon

pts:The points forming the simple polygon

[static] new SimplePolygon new(const Box box)

Description: Constructor converting a box to a polygon

box:The box to convert to a polygon

[static] new SimplePolygon new_b(const Box box)

Description: Constructor converting a box to a polygon

box:The box to convert to a polygon

This method is deprecated. Use method 'new' instead

[static] new SimplePolygon new_p(Point[] pts)

Description: Constructor given the points of the simple polygon

pts:The points forming the simple polygon

This method is deprecated. Use method 'new' instead

unsigned int num_points

Description: Get the number of points

Point point(unsigned int arg1)

Description: Get a specific point of the contour@args p

p:The index of the point to get

If the index of the point is not a valid index, a default value is returned. This method was introduced in version 0.18.

unsigned int points

Description: Get the number of points

This method is deprecated. Use method 'num_points' instead

void points=(Point[] p)

Description: Set the points of the simple polygon

p:An array of points to assign to the simple polygon

[const] Polygon round_corners(double rinner,double router,unsigned int n)

Description: Round the corners of the polygon

rinner:The circle radius of inner corners (in database units).
router:The circle radius of outer corners (in database units).
n:The number of points per full circle.
Returns:The new polygon.

Replaces the corners of the polygon with circle segments.

This method was introduced in version 0.22.

[const] string to_s

Description: Convert to a string

[const] SimplePolygon transformed(const Trans t)

Description: Transform the simple polygon.

t:The transformation to apply.
Returns:The transformed simple polygon.

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

[const] DSimplePolygon transformed_cplx(const CplxTrans t)

Description: Transform the simple polygon.

t:The transformation to apply.
Returns:The transformed simple polygon.

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

[const] SimplePolygon transformed_cplx(const ICplxTrans t)

Description: Transform the simple polygon.

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

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

This method has been introduced in version 0.18.