Table of Contents

Class BorderBuilder

Namespace
CADability.Shapes
Assembly
CADability.dll

Klasse zum Erzeugen von Border Objekten.

public class BorderBuilder
Inheritance
BorderBuilder
Inherited Members

Constructors

BorderBuilder()

Creates an empty builder. Add the segments in order with AddSegment(ICurve2D) and call BuildBorder(bool) to create the Border.

public BorderBuilder()

Properties

EndDirection

The direction of the last added segment at its end point, useful for choosing the next segment at a vertex with several candidates. Must not be used before a segment was added.

public GeoVector2D EndDirection { get; }

Property Value

GeoVector2D

EndPoint

The end point of the last segment added, i.e. the point where the next segment must start. Must not be used before a segment was added.

public GeoPoint2D EndPoint { get; }

Property Value

GeoPoint2D

IsClosed

true if the end point of the last added segment is closer than Precision to the start point of the first segment. Always false while Precision has not been set.

public bool IsClosed { get; }

Property Value

bool

IsOriented

true if the segments added so far form a closed chain running counterclockwise, computed from the accumulated turning angle like CounterClockwise(ICurve2D[]); false for an open chain (see IsClosed) or a clockwise chain. BuildBorder(bool) orients the border counterclockwise in any case; this property tells in which direction the segments were added, which e.g. distinguishes an outline from a hole when shapes are built from a graph of curves.

public bool IsOriented { get; }

Property Value

bool

LastCurve

The segment added last (the original curve, not a copy). Must not be used before a segment was added.

public ICurve2D LastCurve { get; }

Property Value

ICurve2D

Precision

The maximum distance at which the start point of a new segment is considered to coincide with the end point of the previous one (AddSegment(ICurve2D)), and at which IsClosed regards the chain as closed. Negative values are stored as their absolute value. While it has not been set (the value is negative), AddSegment(ICurve2D) and BuildBorder(bool) use 1e-8 of the extent of the segments added so far and IsClosed is always false.

public double Precision { get; set; }

Property Value

double

StartPoint

The start point of the first segment added. Must not be used before a segment was added.

public GeoPoint2D StartPoint { get; }

Property Value

GeoPoint2D

Methods

AddSegment(ICurve2D)

Appends the given segment to the chain of segments collected so far. The segment is only accepted if its start point coincides with the end point of the previously added segment (within Precision, or a small fraction of the current extent if no precision was set); the first segment is always accepted. Use Connect(ICurve2D) if the segment may also be reversed to fit. CAUTION: BuildBorder(bool) may reverse this segment later on. If that must not happen to the original, add a clone.

public bool AddSegment(ICurve2D ToAdd)

Parameters

ToAdd ICurve2D

The segment to add

Returns

bool

true if the segment was appended, false if it does not connect to the previous segment

BuildBorder(bool)

Creates the Border from the segments added so far, in the order they were added. The border is closed when the end point of the last segment coincides with the start point of the first one, and is then oriented counterclockwise, which may reverse the segments.

public Border BuildBorder(bool forceClosed = false)

Parameters

forceClosed bool

true: consecutive segments are connected exactly before the border is built, by moving the start point of each segment onto the end point of the previous one (see Border(ICurve2D[], bool, bool))

Returns

Border

The border

Exceptions

BorderBuilderException

No segment has been added

Clear()

Removes all segments added so far and resets Precision, so the builder can be reused for another border.

public void Clear()

Connect(ICurve2D)

Appends a segment that need not connect exactly. A segment whose start point connects to the chain is appended as by AddSegment(ICurve2D). When its end point is closer to the end of the chain than its start point, the segment is reversed first (in place). When there is still a gap between the chain and the segment, a Line2D bridging the gap is inserted before it, so the chain stays connected whatever is passed in.

public void Connect(ICurve2D ToAdd)

Parameters

ToAdd ICurve2D

The segment to append