Skip to content

Commit 23cb39c

Browse files
refactor(parametricbuilder): rename conns to conn in PositionGroupSpec and update constructors
1 parent 4095d43 commit 23cb39c

1 file changed

Lines changed: 10 additions & 69 deletions

File tree

src/parametricbuilder/groupspec.jl

Lines changed: 10 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct PositionGroupSpec <: AbstractPositionSpec
1717
n::Int # number of cables in the group
1818
anchor::Tuple{Float64, Float64} # (x0,y0)
1919
d::Tuple{Any, Any} # (valuespec, pctspec)
20-
conns::Vector{Dict{String, Int}} # per-leg connection maps
20+
conn::Vector{Dict{String, Int}} # per-leg connection maps
2121
end
2222

2323
# ─────────────────────────────────────────────────────────────────────────────
@@ -34,13 +34,13 @@ The spacing `d` follows the usual `(valuespec, pctspec)` grammar; it will be
3434
expanded lazily and clamped at runtime to avoid overlaps.
3535
"""
3636
function trifoil(; x0::Real = 0.0, y0::Real, d, phases)
37-
conns = make_phase_maps(phases, 3)
37+
conn = make_phase_maps(phases, 3)
3838
return PositionGroupSpec(
3939
:trifoil,
4040
3,
4141
(float(x0), float(y0)),
4242
_spec(d),
43-
conns,
43+
conn,
4444
)
4545
end
4646

@@ -54,13 +54,13 @@ Horizontal flat formation: first cable at `(x0, y0)`, remaining `n-1` cables at
5454
"""
5555
function hflat(; x0::Real = 0.0, y0::Real = 0.0, d, n::Integer = 3, phases)
5656
n < 1 && error("hflat requires n ≥ 1")
57-
conns = make_phase_maps(phases, n)
57+
conn = make_phase_maps(phases, n)
5858
return PositionGroupSpec(
5959
:hflat,
6060
n,
6161
(float(x0), float(y0)),
6262
_spec(d),
63-
conns,
63+
conn,
6464
)
6565
end
6666

@@ -74,13 +74,13 @@ Vertical flat formation: first cable at `(x0, y0)`, remaining `n-1` cables at
7474
"""
7575
function vflat(; x0::Real = 0.0, y0::Real = 0.0, d, n::Integer = 3, phases)
7676
n < 1 && error("vflat requires n ≥ 1")
77-
conns = make_phase_maps(phases, n)
77+
conn = make_phase_maps(phases, n)
7878
return PositionGroupSpec(
7979
:vflat,
8080
n,
8181
(float(x0), float(y0)),
8282
_spec(d),
83-
conns,
83+
conn,
8484
)
8585
end
8686

@@ -115,14 +115,14 @@ function _get_valid_spacings(g::PositionGroupSpec, rout)
115115

116116
# CASE 1: all invalid → pure AUTO: min_spacing with all pcts
117117
if isempty(valid)
118-
@warn "Spacing spec produced only overlapping layouts; clamping to minimum with % uncertainty grid." min_spacing=min_spacing
118+
@debug "Spacing spec produced only overlapping layouts; clamping to minimum with % uncertainty grid." min_spacing=min_spacing
119119
return collect(_make_range(min_spacing; pct = g.d[2]))
120120
end
121121

122122
# CASE 2: some valid, some discarded → inject ONE batch at min_spacing,
123123
# but only for spacing+uncertainty combos that are not already present.
124124
if discarded > 0
125-
@warn "Dropped $discarded spacing samples below minimum center-to-center distance; including one batch at the minimum feasible spacing." min_spacing=min_spacing
125+
@debug "Dropped $discarded spacing samples below minimum center-to-center distance; including one batch at the minimum feasible spacing." min_spacing=min_spacing
126126

127127
autos_all = collect(_make_range(min_spacing; pct = g.d[2]))
128128

@@ -177,7 +177,7 @@ function _materialize(g::PositionGroupSpec, des::CableDesign)
177177
end :
178178
error("Unknown position group arrangement $(g.arrangement)")
179179

180-
return [(x, y, g.conns[i]) for (i, (x, y)) in enumerate(coords)]
180+
return [(x, y, g.conn[i]) for (i, (x, y)) in enumerate(coords)]
181181
end
182182

183183
return (_make_layout(g, d) for d in spacings)
@@ -212,62 +212,3 @@ function _expand_position(position_defs::Vector{AbstractPositionSpec}, des::Cabl
212212

213213
return (reduce(vcat, combo) for combo in product(spaces...))
214214
end
215-
216-
# # ─────────────────────────────────────────────────────────────────────────────
217-
# # Phase mapping: (:core => 1) or (:core => (1,2,3)), etc.
218-
# # ─────────────────────────────────────────────────────────────────────────────
219-
# function _phase_maps(phases, n::Int)
220-
# items = phases === nothing ? () : _normalize_phase_map(phases)
221-
# out = [Dict{String, Int}() for _ in 1:n]
222-
223-
# for it in items
224-
# key, val =
225-
# it isa Pair ? (first(it), last(it)) :
226-
# (it isa Tuple && length(it) == 2) ? (it[1], it[2]) :
227-
# error("Invalid phases entry: $it")
228-
229-
# name = string(key)
230-
231-
# if val isa Integer
232-
# # scalar → replicate to all legs
233-
# for k in 1:n
234-
# out[k][name] = Int(val)
235-
# end
236-
# elseif val isa Tuple && length(val) == n && all(x -> x isa Integer, val)
237-
# # tuple → per-leg phases
238-
# for k in 1:n
239-
# out[k][name] = Int(val[k])
240-
# end
241-
# else
242-
# error(
243-
# "Invalid phase mapping for $name: $val. Expected Int or length-$n tuple of Ints.",
244-
# )
245-
# end
246-
# end
247-
248-
# return out
249-
# end
250-
251-
# # ─────────────────────────────────────────────────────────────────────────────
252-
# # Public sugar constructors
253-
# # ─────────────────────────────────────────────────────────────────────────────
254-
255-
# """
256-
# trifoil(; x0 = 0.0, y0, d, phases)
257-
258-
# Lazily describes a 3-cable trifoil formation. The anchor `(x0,y0)` is passed to
259-
# `DataModel.trifoil_formation(x0,y0,d)` when the group is materialized.
260-
261-
# The spacing `d` follows the usual `(valuespec, pctspec)` grammar; it will be
262-
# expanded lazily and clamped at runtime to avoid overlaps.
263-
# """
264-
# function trifoil(; x0::Real = 0.0, y0::Real, d, phases)
265-
# conns = _phase_maps(phases, 3)
266-
# return PositionGroupSpec(
267-
# :trifoil,
268-
# 3,
269-
# (float(x0), float(y0)),
270-
# _spec(d),
271-
# conns,
272-
# )
273-
# end

0 commit comments

Comments
 (0)