Class SimplePolygon (version 0.18)

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.

Class overview

Index

Method Overview

[static] SimplePolygon newDefault constructor: creates an empty (invalid) polygon
[static] SimplePolygon new( Point pts[ ] )Constructor given the points of the simple polygon
[static] SimplePolygon new( Box box )Constructor converting a box to a polygon
[const] bool ==( SimplePolygon )Equality test
[const] bool !=( SimplePolygon )Inequality test
points=( Point p[ ] )Set the points of the simple polygon
Point point( unsigned int p )Get a specific point of the contour@args p
unsigned int pointsGet the number of points
[const] yield Point each_pointIterate over the points that make up the simple polygon
yield Edge each_edgeIterate over the edges that make up the simple polygon
[const] bool inside( Point p )Test, if the given point is inside the polygon
compress( bool remove_reflected )Compress the simple polygon.
ref SimplePolygon move( Point p )Moves the simple polygon.
[const] SimplePolygon moved( Point p )Returns the moved simple polygon
[const] SimplePolygon transformed( Trans t )Transform the simple polygon.
[const] DSimplePolygon transformed_cplx( CplxTrans t )Transform the simple polygon.
[const] string to_sConvert to a string
[const] long long areaThe area of the polygon
[const] const ref Box bboxReturn the bounding box of the simple polygon
[static] SimplePolygon from_dpoly( DSimplePolygon double_poly )Construct an integer-coordinate polygon from a floating-point coordinate one
[const] SimplePolygon transformed_cplx( ICplxTrans t )Transform the simple polygon.
assign( SimplePolygon other )Assign the contents of another object to self
[const] SimplePolygon dupCreates a copy of self.
destroyExplicitly destroy the object
[const] bool destroyedTell, if the object was destroyed

[const] bool !=( SimplePolygon )

Description: Inequality test

[const] bool ==( SimplePolygon )

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.

assign( 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] const ref Box bbox

Description: Return the bounding box of the simple polygon

compress( bool remove_reflected )

Description: Compress the simple polygon.

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.

remove_reflected:See description of the functionality.

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: Tell, if the object was 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.

yield Edge each_edge

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

[const] yield Point each_point

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

[static] SimplePolygon from_dpoly( 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

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.

ref SimplePolygon move( Point p )

Description: Moves the simple polygon.

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

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

[const] SimplePolygon moved( Point p )

Description: Returns the moved simple polygon

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

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

[static] SimplePolygon new( Box box )
synonym: [static] SimplePolygon new_b( Box box )

Description: Constructor converting a box to a polygon

box:The box to convert to a polygon

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

Description: Constructor given the points of the simple polygon

pts:The points forming the simple polygon

[static] SimplePolygon new

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

Point point( unsigned int p )

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

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

p:The index of the point to get

unsigned int points

Description: Get the number of points

points=( Point p[ ] )

Description: Set the points of the simple polygon

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

[const] string to_s

Description: Convert to a string

[const] SimplePolygon transformed( Trans t )

Description: Transform the simple polygon.

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

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

[const] DSimplePolygon transformed_cplx( CplxTrans t )

Description: Transform the simple polygon.

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

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

[const] SimplePolygon transformed_cplx( ICplxTrans t )

Description: Transform the simple polygon.

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.

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