Compute_grid.Grid_track_countsSourceTrack count management and coordinate system conversions for CSS Grid layout.
This module maintains counts of tracks in the implicit and explicit grids and provides conversions between two coordinate systems used internally:
Invariant: The total track count equals negative_implicit + explicit + positive_implicit.
The module also handles conversion to GridTrackVec indices, where even indices represent lines and odd indices represent tracks.
make ~negative_implicit ~explicit ~positive_implicit creates track counts from raw numbers.
len t returns the total number of tracks across implicit and explicit grids.
negative_implicit t returns the number of tracks in the negative implicit grid.
positive_implicit t returns the number of tracks in the positive implicit grid.
implicit_start_line t returns the OriginZero line at the start of the implicit grid. Always negative or zero.
implicit_end_line t returns the OriginZero line at the end of the implicit grid. Always positive or zero.
oz_line_to_next_track t line converts an OriginZero grid line to the index of the track immediately following it in the CellOccupancyMatrix.
oz_line_range_to_track_range t range converts a line range in OriginZero coordinates to an exclusive track index range in the CellOccupancyMatrix.
track_to_prev_oz_line t index converts a CellOccupancyMatrix track index to the OriginZero line immediately preceding it.
track_range_to_oz_line_range t range converts an exclusive track index range from the CellOccupancyMatrix to a line range in OriginZero coordinates.
oz_line_to_track t line converts an OriginZero grid line to a GridTrackVec index (even indices). Returns None if the line is outside the implicit grid. The result is doubled to account for interleaved lines and tracks in the GridTrackVec representation.