quilt_knit.quilt.Connection_Interval_Tree module

Module containing the Connection Interval Tree class.

class Connection_Interval_Tree(source_swatch)[source]

Bases: object

A data structure representing an interval of connections between a swatch and its neighbors on a specific side (top, bottom, left, right).

source_swatch

The swatch that owns these connections.

Type:

Swatch

interval_tree

The interval tree representing the spacing of swatch connections.

Type:

IntervalTree

Parameters:

source_swatch (Swatch)

__init__(source_swatch)[source]
Parameters:

source_swatch (Swatch)

blocking_connections(connection)[source]

A connection blocks connections in this tree if they do not connect the same swatches and the intervals of the connections overlap but do not envelop the given connection.

Parameters:

connection (Swatch_Connection) – The other connection that may block connections in tree.

Returns:

The set of connections in this tree that are blocked by the given connection.

Return type:

set[Swatch_Connection]

connection_is_blocked(connection)[source]

A connection is blocked by this tree if the following criteria are met: * It involves the source swatch of this tree. * The connection overlaps, but does not envelop, an existing connection in the tree.

Parameters:

connection (Swatch_Connection) – The connection that may be blocked by connections in this tree.

Returns:

True if the given connection is blocked, False otherwise.

Return type:

bool

interval_sorted_connections()[source]
Returns:

A list of connections sorted by their interval connections to the source swatch.

Return type:

list[Swatch_Connection]

make_connection(connection)[source]

Add the given connection to this connection interval tree.

Parameters:

connection (Swatch_Connection) – The connection to add to the interval tree.

Return type:

None

Notes

This method does not verify that the connection should be added to the interval tree and does not override or overlap an existing connection.

remove_connection(prior_connection)[source]

Remove a given connection from the interval tree. :type prior_connection: Swatch_Connection :param prior_connection: The connection to remove from the interval tree. :type prior_connection: Swatch_Connection

Return type:

None

overlaps_existing_connection(connection)[source]
Parameters:

connection (Swatch_Connection) – The connection to check for overlap with an interval in the tree.

Returns:

True if the given connection overlaps with an interval in the tree, False otherwise.

Return type:

bool

overlapped_intervals(connection)[source]
Parameters:

connection (Swatch_Connection) – The connection to check for overlap with an interval in the tree.

Returns:

The set of intervals that overlap the given connection.

Return type:

set[Interval]

Notes

Interval overlaps are inclusive of the lower limit but exclusive of the upper limit. I.e., an existing interval will be included in the set if it has a point i such that begin <= i < end. The connection of each interval is stored as the interval’s data value (i.e., interval.data).

enveloped_intervals(connection)[source]
Parameters:

connection (Swatch_Connection) – The connection to check for enveloped intervals in the tree.

Returns:

The set of intervals that envelop the given connection.

Return type:

set[Interval]

enveloped_connections(connection)[source]
Parameters:

connection (Swatch_Connection) – The connection that may be enveloped by connections in this tree.

Returns:

The set of swatch connections that envelop the given connection.

Return type:

set[Swatch_Connection]

__hash__()[source]
Returns:

The hash value of the source swatch.

Return type:

int

__repr__()[source]
Returns:

A string representation of this connection.

Return type:

str

connections()[source]
Returns:

The set of connections in this interval tree.

Return type:

set[Swatch_Connection]