quilt_knit.quilt.Connection_Interval_Tree module
Module containing the Connection Interval Tree class.
- class Connection_Interval_Tree(source_swatch)[source]
Bases:
objectA data structure representing an interval of connections between a swatch and its neighbors on a specific side (top, bottom, left, right).
- interval_tree
The interval tree representing the spacing of swatch connections.
- Type:
IntervalTree
- 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:
- 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:
- interval_sorted_connections()[source]
- Returns:
A list of connections sorted by their interval connections to the source swatch.
- Return type:
- 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:
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:
- 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:
- 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: