circlepack
pleat.io.circlepack ¶
File I/O for the CirclePack .p format.
CirclePackData
dataclass
¶
CirclePackData(
nodecount: int,
geometry: str | None,
alpha: int | None,
beta: int | None,
gamma: int | None,
flowers: dict[int, list[int]],
radii: ndarray | None,
centers: ndarray | None,
)
Structured contents of a CirclePack .p file.
All vertex indices are 0-indexed internally even though the file format
stores them 1-indexed. Use :func:parse_p_file to read and
:func:write_p_file to write this dataclass verbatim.
parse_p_file ¶
Parse a CirclePack .p file into a :class:CirclePackData dataclass.
Source code in pleat/io/circlepack.py
write_p_file ¶
Write a :class:CirclePackData verbatim to a CirclePack .p file.
Vertex labels and the per-vertex neighbor list order in data.flowers
are preserved exactly, so :func:parse_p_file ∘ :func:write_p_file
round-trips losslessly (modulo float precision).
Source code in pleat/io/circlepack.py
load_circlepack ¶
Load a CirclePack .p file into an :class:EuclideanPositionHEG.
Populates v['pos'] and v['radius'] on every vertex when the file
provides RADII (and CENTERS, where applicable). For hyperbolic packings
the file's RADII are interpreted as x-radii; the returned graph stores
the corresponding euclidean (Poincaré-disk) center and radius, matching
:func:pleat.circle_packing.pack_hyperbolic's output convention. If a
hyperbolic file omits CENTERS, the layout is computed via
:func:pleat.circle_packing._layout_hyperbolic.
The returned graph's geometry is set to :class:EuclideanGeometry or
:class:PoincareDiskModel based on the file's GEOMETRY line; unknown or
missing values default to :class:EuclideanGeometry.
Source code in pleat/io/circlepack.py
save_circlepack ¶
Save an :class:EuclideanPositionHEG to a CirclePack .p file.
Emits FLOWERS for the triangulation, plus RADII / CENTERS if every vertex
has radius / pos attributes, plus GEOMETRY based on G.geometry.
Hyperbolic packings (G.geometry is PoincareDiskModel) are emitted with
x-radii in the RADII section, matching CirclePack's convention.