Logo Euclid.Kontur

Kontur Type

A Kontur (German for contour) is a region of the plane defined by one or more closed Polyline2Ds and a fill rule.
 Paths may self intersect, overlap each other, or be nested. The fill rule decides what is inside.
 The fill rule belongs to the Kontur, not to the boolean operation, unlike in Clipper.
 Subject and clip get separate winding numbers on every edge, and each fill rule is applied to
 its own winding number before the boolean combines them. So two different fill rules never
 conflict, they are two independent decisions.
 What this buys is one pass instead of two: an EvenOdd glyph unioned with a NonZero CAD outline
 works in one operation. With a fill rule per operation the glyph would have to be simplified
 first, then unioned.
 Kontur values returned by a boolean operation are always simple: no self intersections, no overlaps,
 outer paths counter clockwise, holes clockwise, and their fill rule is Positive. Such a result
 reads the same under NonZero, Positive and EvenOdd, so the rule of a result never has to be changed.
 A Kontur does not copy the Polyline2Ds it is given. They are still mutable, so they must not be changed
 in a way that opens them while the Kontur is in use.

Instance members

Instance member Description

this.AsString

Full Usage: this.AsString

Returns: string

Format this Kontur into a string with its fill rule, count of paths and count of points.

Returns: string

this.BoundingRectangle

Full Usage: this.BoundingRectangle

Returns: BRect

The axis aligned bounding rectangle around all paths. Fails on an empty Kontur.

Returns: BRect

this.Contains

Full Usage: this.Contains

Parameters:
Returns: bool

Tests if the point is inside this Kontur according to its fill rule. Points exactly on a path may give either result.

pt : Pt
Returns: bool

this.FillRule

Full Usage: this.FillRule

Returns: FillRule

How the winding number decides what is inside this Kontur.

Returns: FillRule

this.Holes

Full Usage: this.Holes

Returns: ResizeArray<Polyline2D>

The clockwise paths of this Kontur, those with a negative signed area, in the order of Paths. For a Kontur returned by a boolean operation these are its holes. Each lies inside one of the Outers, but not necessarily after it in Paths. For other Kontur values the orientation alone does not tell outer paths from holes, simplify them first. A new list on every call, the Polyline2Ds are not copied.

Returns: ResizeArray<Polyline2D>

this.IsEmpty

Full Usage: this.IsEmpty

Returns: bool

TRUE if this Kontur has no paths.

Returns: bool

this.Outers

Full Usage: this.Outers

Returns: ResizeArray<Polyline2D>

The counter clockwise paths of this Kontur, those with a positive signed area, in the order of Paths. For a Kontur returned by a boolean operation these are its outer paths, and there can be any number of them. For other Kontur values the orientation alone does not tell outer paths from holes, under NonZero a clockwise path on its own is filled too. Simplify such a Kontur first. A new list on every call, the Polyline2Ds are not copied.

Returns: ResizeArray<Polyline2D>

this.PathCount

Full Usage: this.PathCount

Returns: int

The count of paths in this Kontur.

Returns: int

this.Paths

Full Usage: this.Paths

Returns: ResizeArray<Polyline2D>

The closed paths of this Kontur. Each path stores its first point twice, as first and as last point. The paths of a boolean result come in no particular order: there may be several outer paths, and a hole may come before the outer path around it. Use Outers and Holes to tell them apart. This is the live internal list, do not add open paths to it.

Returns: ResizeArray<Polyline2D>

this.SignedArea

Full Usage: this.SignedArea

Returns: float

The sum of the signed areas of all paths. Counter clockwise paths count positive. This is the area of the Kontur only if the paths do not overlap and holes are oriented opposite to their outer path, which is the case for every Kontur returned by a boolean operation.

Returns: float

this.WindingNumber

Full Usage: this.WindingNumber

Parameters:
Returns: int

Counts how often the paths of this Kontur wind around the point. The sum of Polyline2D.WindingNumber over all paths. Points exactly on a path may give either side's result.

pt : Pt
Returns: int

Static members

Static member Description

Kontur.create (paths, ?fillRule)

Full Usage: Kontur.create (paths, ?fillRule)

Parameters:
    paths : Polyline2D seq - The closed Polyline2Ds. Each must have its first point repeated as last point and at least three distinct points.
    ?fillRule : FillRule - Optional, FillRule.NonZero by default. How the winding number decides what is inside. See the docs of FillRule for why the rule belongs to the Kontur.

Returns: Kontur A new Kontur.

Creates a Kontur from closed paths and a fill rule. The paths are not copied, the Kontur refers to the given Polyline2Ds.

paths : Polyline2D seq

The closed Polyline2Ds. Each must have its first point repeated as last point and at least three distinct points.

?fillRule : FillRule

Optional, FillRule.NonZero by default. How the winding number decides what is inside. See the docs of FillRule for why the rule belongs to the Kontur.

Returns: Kontur

A new Kontur.

Kontur.createSingleton (path, ?fillRule)

Full Usage: Kontur.createSingleton (path, ?fillRule)

Parameters:
    path : Polyline2D - The closed Polyline2D. It must have its first point repeated as last point and at least three distinct points.
    ?fillRule : FillRule - Optional, FillRule.NonZero by default. How the winding number decides what is inside.

Returns: Kontur A new Kontur with one path.

Creates a Kontur from one closed path.

path : Polyline2D

The closed Polyline2D. It must have its first point repeated as last point and at least three distinct points.

?fillRule : FillRule

Optional, FillRule.NonZero by default. How the winding number decides what is inside.

Returns: Kontur

A new Kontur with one path.

Kontur.empty fillRule

Full Usage: Kontur.empty fillRule

Parameters:
Returns: Kontur

Creates an empty Kontur without any paths.

fillRule : FillRule
Returns: Kontur

Kontur.exists predicate k

Full Usage: Kontur.exists predicate k

Parameters:
Returns: bool
Modifiers: inline

TRUE if the predicate returns TRUE for at least one path of the Kontur. Stops at the first such path. FALSE for an empty Kontur.

predicate : Polyline2D -> bool
k : Kontur
Returns: bool

Kontur.filter predicate k

Full Usage: Kontur.filter predicate k

Parameters:
    predicate : Polyline2D -> bool - Gets one path of the Kontur and returns TRUE to keep it.
    k : Kontur - The Kontur to filter.

Returns: Kontur A new Kontur with the kept paths in the order of Paths.

A new Kontur with only the paths for which the predicate returns TRUE, under the same fill rule. The Polyline2Ds are not copied. Dropping an outer path of a boolean result but not its holes leaves those holes on their own: under FillRule.Positive they fill nothing, but they still count in PathCount and SignedArea.

predicate : Polyline2D -> bool

Gets one path of the Kontur and returns TRUE to keep it.

k : Kontur

The Kontur to filter.

Returns: Kontur

A new Kontur with the kept paths in the order of Paths.

Kontur.forall predicate k

Full Usage: Kontur.forall predicate k

Parameters:
Returns: bool
Modifiers: inline

TRUE if the predicate returns TRUE for every path of the Kontur. Stops at the first path where it does not. TRUE for an empty Kontur.

predicate : Polyline2D -> bool
k : Kontur
Returns: bool

Kontur.holes k

Full Usage: Kontur.holes k

Parameters:
Returns: ResizeArray<Polyline2D>

The clockwise paths of the Kontur, the holes of a boolean result. See the member Holes.

k : Kontur
Returns: ResizeArray<Polyline2D>

Kontur.iter action k

Full Usage: Kontur.iter action k

Parameters:
Modifiers: inline

Calls the action for every path of the Kontur, in the order of Paths.

action : Polyline2D -> unit
k : Kontur

Kontur.iteri action k

Full Usage: Kontur.iteri action k

Parameters:
Modifiers: inline

Calls the action with the index and the path for every path of the Kontur, in the order of Paths.

action : int -> Polyline2D -> unit
k : Kontur

Kontur.map mapping k

Full Usage: Kontur.map mapping k

Parameters:
    mapping : Polyline2D -> Polyline2D - Gets one path of the Kontur and returns the closed path that replaces it, for example a moved copy.
    k : Kontur - The Kontur to map.

Returns: Kontur A new Kontur with one path per path of k.

A new Kontur of the paths the mapping returns for each path, under the same fill rule. Fails if the mapping returns a path that is not closed or has fewer than three distinct points. A mapping that mirrors the paths also reverses their orientation. Then under FillRule.Positive the outer paths of a boolean result wind the wrong way and nothing is inside any more, unless the mapping reverses them too.

mapping : Polyline2D -> Polyline2D

Gets one path of the Kontur and returns the closed path that replaces it, for example a moved copy.

k : Kontur

The Kontur to map.

Returns: Kontur

A new Kontur with one path per path of k.

Kontur.outers k

Full Usage: Kontur.outers k

Parameters:
Returns: ResizeArray<Polyline2D>

The counter clockwise paths of the Kontur, the outer paths of a boolean result. See the member Outers.

k : Kontur
Returns: ResizeArray<Polyline2D>

Type something to start searching.