Logo Euclid

Topology2D Type

A type containing only static member functions for 2D topological operations.

Static members

Static member Description

Topology2D.join (getLine, splitDistance, xs)

Full Usage: Topology2D.join (getLine, splitDistance, xs)

Parameters:
    getLine : 'T -> Line2D - A function that computes a Line2D from an element of type 'T. The Line2D is used as an abstraction to hold start and end of arbitrary object. For the line end point it finds the next closest line start point. And for the line start point it finds the next closest line end point.
    splitDistance : float - A float value representing the maximum distance between points to be considered part of the same loop or polyline. If the distance between two points is greater than this value, a new loop or polyline will be started.
    xs : ResizeArray<'T> - A ResizeArray of elements of type 'T to be grouped into loops or polylines.

Returns: ResizeArray<ResizeArray<'T>> A ResizeArray of ResizeArrays of 'T, where each inner ResizeArray represents a group of consecutive elements that are part of the same loop or polyline. The groups are determined based on the distance between the end point of one element and the start point of the next element, as computed by the 'getLine' function and compared to the 'splitDistance'.
Type parameters: 'T

Returns the groups of consecutive elements, loops or polylines. They are split where the distance between the end point of one element and the start point of the next element is greater than 'splitDistance'. For each element it will compute a line given the 'getLine' function. The Line2D is used as an abstraction to hold start and end of arbitrary object. It searches forward and backward from the first element to connect elements into loops or polylines. For the line end point it finds the next closest line start point. And for the line start point it finds the next closest line end point. If the distance between two points is greater than the 'splitDistance' an new loop is started.

getLine : 'T -> Line2D

A function that computes a Line2D from an element of type 'T. The Line2D is used as an abstraction to hold start and end of arbitrary object. For the line end point it finds the next closest line start point. And for the line start point it finds the next closest line end point.

splitDistance : float

A float value representing the maximum distance between points to be considered part of the same loop or polyline. If the distance between two points is greater than this value, a new loop or polyline will be started.

xs : ResizeArray<'T>

A ResizeArray of elements of type 'T to be grouped into loops or polylines.

Returns: ResizeArray<ResizeArray<'T>>

A ResizeArray of ResizeArrays of 'T, where each inner ResizeArray represents a group of consecutive elements that are part of the same loop or polyline. The groups are determined based on the distance between the end point of one element and the start point of the next element, as computed by the 'getLine' function and compared to the 'splitDistance'.

Topology2D.joinReversing (getLine, splitDistance, xs)

Full Usage: Topology2D.joinReversing (getLine, splitDistance, xs)

Parameters:
    getLine : 'T -> Line2D - A function that takes an element of type 'T and returns a Line2D representing its start and end points.
    splitDistance : float - A float value representing the maximum distance between points to be considered part of the same loop or polyline.
    xs : ResizeArray<'T> - A ResizeArray of elements of type 'T to be grouped into loops or polylines.

Returns: ResizeArray<ResizeArray<'T * bool>> A ResizeArray of ResizeArrays of tupels: 'T * Boolean, the Boolean values indicating if the element was reversed. The Boolean value is true if the element was reversed, and false if it was not
Type parameters: 'T

Returns the groups of consecutive elements, loops or polylines. They are split where the distance between the end point of one element and the start or end point of the next element is greater than 'splitDistance'. For each element it will compute a line given the 'getLine' function. The Line2D is used as an abstraction to hold start and end of arbitrary object. Then for each line start and end point it finds the next closest line end or start point. Start and end points can match with both start and end points. If the distance between two points is greater than the 'splitDistance' it will be considered as a new group.

getLine : 'T -> Line2D

A function that takes an element of type 'T and returns a Line2D representing its start and end points.

splitDistance : float

A float value representing the maximum distance between points to be considered part of the same loop or polyline.

xs : ResizeArray<'T>

A ResizeArray of elements of type 'T to be grouped into loops or polylines.

Returns: ResizeArray<ResizeArray<'T * bool>>

A ResizeArray of ResizeArrays of tupels: 'T * Boolean, the Boolean values indicating if the element was reversed. The Boolean value is true if the element was reversed, and false if it was not

Topology2D.sortToLoop (getLine, ts)

Full Usage: Topology2D.sortToLoop (getLine, ts)

Parameters:
    getLine : 'T -> Line2D - A function that computes a Line2D from an element of type 'T. The Line2D is used as an abstraction to hold start and end of arbitrary object. For each line end point it finds the next closest line start point.
    ts : ResizeArray<'T> - A ResizeArray of elements of type 'T' to be sorted in place.

Type parameters: 'T

Sorts elements in place to be in a circular structure. This does NOT recognize if there are actually several loops. Use Topology2D.join for this instead.

getLine : 'T -> Line2D

A function that computes a Line2D from an element of type 'T. The Line2D is used as an abstraction to hold start and end of arbitrary object. For each line end point it finds the next closest line start point.

ts : ResizeArray<'T>

A ResizeArray of elements of type 'T' to be sorted in place.

Topology2D.sortToLoopCached (getLine, ts)

Full Usage: Topology2D.sortToLoopCached (getLine, ts)

Parameters:
    getLine : 'T -> Line2D - A function that computes a Line2D from an element of type 'T. The Line2D is used as an abstraction to hold start and end of arbitrary object. For each line end point it finds the next closest line start point.
    ts : ResizeArray<'T> - A ResizeArray of elements of type 'T' to be sorted in place.

Returns: float[] The input array 'ts' is modified in place to be sorted in a circular structure. But also returns a sorted flat array of the 2d lines used internally [FromX; FromY; ToX; ToY].
Type parameters: 'T

Sorts elements in place to be in a circular structure. Does the same thing as sortToLoop but caches the line coordinates in a float array to avoid repeated getLine calls inside the inner loop. This runs slightly faster when getLine is expensive. (The benefit only shows in .NET not in Fable JS) This does NOT recognize if there are actually several loops. Use Topology2D.join for this instead.

getLine : 'T -> Line2D

A function that computes a Line2D from an element of type 'T. The Line2D is used as an abstraction to hold start and end of arbitrary object. For each line end point it finds the next closest line start point.

ts : ResizeArray<'T>

A ResizeArray of elements of type 'T' to be sorted in place.

Returns: float[]

The input array 'ts' is modified in place to be sorted in a circular structure. But also returns a sorted flat array of the 2d lines used internally [FromX; FromY; ToX; ToY].

Topology2D.sortToLoopWithReversing (getLine, reverseInPlace, ts)

Full Usage: Topology2D.sortToLoopWithReversing (getLine, reverseInPlace, ts)

Parameters:
    getLine : 'T -> Line2D - A function that computes a Line2D from an element of type 'T. The Line2D is used as an abstraction to hold start and end of arbitrary object. For each line end it finds the next closest start point or end point.
    reverseInPlace : int -> 'T -> unit - A function that reverses an element in place given its index and the element itself. This function might just update an item at the given index in the array, or it might modify the element in place if 'T is a reference type.
    ts : ResizeArray<'T> - A ResizeArray of elements of type 'T' to be sorted in place.

Type parameters: 'T

Sorts elements in place to be in a circular structure. For each line end it finds the next closest start point or end point. This does NOT recognize if there are actually several loops. Use Topology2D.joinReversing for this instead.

getLine : 'T -> Line2D

A function that computes a Line2D from an element of type 'T. The Line2D is used as an abstraction to hold start and end of arbitrary object. For each line end it finds the next closest start point or end point.

reverseInPlace : int -> 'T -> unit

A function that reverses an element in place given its index and the element itself. This function might just update an item at the given index in the array, or it might modify the element in place if 'T is a reference type.

ts : ResizeArray<'T>

A ResizeArray of elements of type 'T' to be sorted in place.

Topology2D.sortToLoopWithReversingCached (getLine, reverseInPlace, ts)

Full Usage: Topology2D.sortToLoopWithReversingCached (getLine, reverseInPlace, ts)

Parameters:
    getLine : 'T -> Line2D - A function that computes a Line2D from an element of type 'T. The Line2D is used as an abstraction to hold start and end of arbitrary object. For each line end it finds the next closest start point or end point.
    reverseInPlace : int -> 'T -> unit - A function that reverses an element in place given its index and the element itself. This function might just update an item at the given index in the array, or it might modify the element in place if 'T is a reference type.
    ts : ResizeArray<'T> - A ResizeArray of elements of type 'T' to be sorted in place.

Returns: float[] The input array 'ts' is modified in place to be sorted in a circular structure. But also returns a sorted flat array of the 2d lines used internally [FromX; FromY; ToX; ToY]. Entries whose element was reversed have their FromX/FromY and ToX/ToY swapped to reflect the new orientation.
Type parameters: 'T

Sorts elements in place to be in a circular structure. Does the same thing as sortToLoopWithReversing but caches the line coordinates in a float array to avoid repeated getLine calls inside the inner loop. This runs slightly faster when getLine is expensive. (The benefit only shows in .NET not in Fable JS) For each line end it finds the next closest start point or end point. This does NOT recognize if there are actually several loops. Use Topology2D.joinReversing for this instead.

getLine : 'T -> Line2D

A function that computes a Line2D from an element of type 'T. The Line2D is used as an abstraction to hold start and end of arbitrary object. For each line end it finds the next closest start point or end point.

reverseInPlace : int -> 'T -> unit

A function that reverses an element in place given its index and the element itself. This function might just update an item at the given index in the array, or it might modify the element in place if 'T is a reference type.

ts : ResizeArray<'T>

A ResizeArray of elements of type 'T' to be sorted in place.

Returns: float[]

The input array 'ts' is modified in place to be sorted in a circular structure. But also returns a sorted flat array of the 2d lines used internally [FromX; FromY; ToX; ToY]. Entries whose element was reversed have their FromX/FromY and ToX/ToY swapped to reflect the new orientation.

Type something to start searching.