🐛 Fix incorrect type handling on path join nodes operation

This commit is contained in:
Andrey Antukh 2025-06-17 17:34:13 +02:00
parent c5b0206bf0
commit a772b442c8

View file

@ -628,27 +628,38 @@
(rest content)))))))) (rest content))))))))
(defn join-nodes (defn join-nodes
"Creates new segments between points that weren't previously" "Creates new segments between points that weren't previously.
Returns plain segments vector."
[content points] [content points]
(let [segments-set (into #{} (let [;; Materialize the content to a vector (plain format)
(map (juxt :start :end)) content
(get-segments-with-points content points)) (vec content)
create-line-command (fn [point other] segments-set
[(helpers/make-move-to point) (into #{}
(helpers/make-line-to other)]) (map (juxt :start :end))
(get-segments-with-points content points))
not-segment? (fn [point other] (and (not (contains? segments-set [point other])) create-line-segment
(not (contains? segments-set [other point])))) (fn [point other]
[(helpers/make-move-to point)
(helpers/make-line-to other)])
new-content (->> (d/map-perm create-line-command not-segment? points) not-segment?
(flatten) (fn [point other]
(into []))] (and (not (contains? segments-set [point other]))
(not (contains? segments-set [other point]))))
;; FIXME: implement map-perm in terms of transducer, will
;; improve performance and remove the need to use flatten
new-content
(->> (d/map-perm create-line-segment not-segment? points)
(flatten)
(into []))]
(into content new-content))) (into content new-content)))
(defn separate-nodes (defn separate-nodes
"Removes the segments between the points given" "Removes the segments between the points given"
[content points] [content points]