Euclid Namespace
| Type/Module | Description |
|
When Euclid is opened this module will be auto-opened. It only contains extension members for type Polyline2D: the boolean operations of the Kontur module directly on closed Polyline2Ds, without creating a Kontur first. In Union, Intersection, Difference, Xor and UnionMany every Polyline2D is one region under the NonZero fill rule, so its orientation does not matter and a self intersecting Polyline2D is filled wherever it winds around. Simplify is different: it keeps only the regions a Polyline2D winds around in its main direction, the sign of its signed area, and drops the loops that wind the other way, like the inverted loops of an offset. All results are simple closed contours: no self intersections, no overlaps, outer contours counter clockwise, holes clockwise. A fresh engine is created per call. For many operations in a row, for other fill rules or for regions of several paths use Kontur and KonturEngine. |
|
|
Functions on the Euclid.Kontur.ClipType enum. |
|
|
On Euclid.Kontur. The kind of boolean operation between a subject and a clip Kontur. |
|
One of the two input segments that cross at a new vertex of a boolean result, as handed to the crossing function of KonturEngine.ExecuteWithData. Start and End are the values the caller gave to the two end points of the segment, Parameter is where the crossing lies between them. |
|
|
Functions on the Euclid.Kontur.FillRule enum. |
|
|
On Euclid.Kontur. Determines how the winding number of a point decides whether the point is inside a Kontur./// The winding number counts how often the paths of a Kontur wind around a point, counter clockwise turns count +1, clockwise turns count -1. 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. |
|
|
Boolean operations on Kontur values with a fresh engine per call and the default tolerance of 1e-6. For many operations in a row create one KonturEngine and reuse it, that avoids all allocations but the results. |
|
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. |
|
A Kontur together with one value of type 'T for every point of every path, for tracking where the vertices of a boolean result come from. Data.[p].[i] belongs to Kontur.Paths.[p].Points.[i]. Like its Polyline2D, each array has the closing point too: its last item belongs to the repeated first point. The engine reads only the first item for that point, and writes the same value to both ends of a result array. The values can be anything: an index into the caller's own tables, a height, a color, a reference to an object. KonturEngine.ExecuteWithData hands the value of every input point on to the result vertex it becomes, and calls a function of the caller for every new vertex where two segments cross. Like a Kontur, a KonturData does not copy the arrays it is given. |
|
Runs boolean operations on Kontur values. Holds all scratch buffers of the algorithm, so that repeated operations on one engine do not allocate anything but the result Polyline2Ds. Not thread safe, use one engine per thread. The tolerance is absolute, in the units of the coordinates: points closer than the tolerance are the same point, a point closer than the tolerance to a segment lies on it. See DESIGN.md section 2. |
Euclid.Kontur