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
|
Full Usage:
this.AsString
Returns: string
|
Format this Kontur into a string with its fill rule, count of paths and count of points.
|
|
The axis aligned bounding rectangle around all paths. Fails on an empty Kontur.
|
|
Tests if the point is inside this Kontur according to its fill rule. Points exactly on a path may give either result.
|
|
How the winding number decides what is inside this Kontur.
|
|
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.
|
Full Usage:
this.IsEmpty
Returns: bool
|
TRUE if this Kontur has no paths.
|
|
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.
|
Full Usage:
this.PathCount
Returns: int
|
The count of paths in this Kontur.
|
|
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.
|
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.
|
|
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.
|
Static members
| Static member |
Description
|
Full Usage:
Kontur.create (paths, ?fillRule)
Parameters:
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.
|
Full Usage:
Kontur.createSingleton (path, ?fillRule)
Parameters:
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.
|
|
|
Full Usage:
Kontur.exists predicate k
Parameters:
Polyline2D -> bool
k : Kontur
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.
|
Full Usage:
Kontur.filter predicate k
Parameters:
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.
|
Full Usage:
Kontur.forall predicate k
Parameters:
Polyline2D -> bool
k : Kontur
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.
|
|
The clockwise paths of the Kontur, the holes of a boolean result. See the member Holes.
|
Full Usage:
Kontur.iter action k
Parameters:
Polyline2D -> unit
k : Kontur
Modifiers: inline |
Calls the action for every path of the Kontur, in the order of Paths.
|
Full Usage:
Kontur.iteri action k
Parameters:
int -> Polyline2D -> unit
k : Kontur
Modifiers: inline |
Calls the action with the index and the path for every path of the Kontur, in the order of Paths.
|
Full Usage:
Kontur.map mapping k
Parameters:
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.
|
|
The counter clockwise paths of the Kontur, the outer paths of a boolean result. See the member Outers.
|
Euclid.Kontur