Skip to content

Commit

Permalink
loft :algorithm argument
Browse files Browse the repository at this point in the history
  • Loading branch information
cartesian-theatrics committed Apr 11, 2024
1 parent 61fb3d7 commit c155c9a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
11 changes: 6 additions & 5 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
:aliases
{:dev
{:extra-deps
{org.clojars.cartesiantheatrics/manifold3d$linux-x86_64 {:mvn/version "1.0.79"}}}
{org.clojars.cartesiantheatrics/manifold3d$linux-x86_64 {:mvn/version "1.0.81"}}}

:test {:extra-paths ["test/main"]
:extra-deps {lambdaisland/kaocha {:mvn/version "1.88.1376"}
org.clojure/clojure {:mvn/version "1.11.2"}}
:main-opts ["-m" "kaocha.runner"]}
:test
{:extra-paths ["test/main"]
:extra-deps {lambdaisland/kaocha {:mvn/version "1.88.1376"}
org.clojure/clojure {:mvn/version "1.11.2"}}
:main-opts ["-m" "kaocha.runner"]}

:deploy
{:extra-paths ["build"]
Expand Down
8 changes: 7 additions & 1 deletion src/main/plexus/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
(defop loft
"Loft between segments. All lofted cross-sections must have equal number of points. Optional
`:to` parameter specifies which frames to loft."
schema/any-map-schema)
schema/loft-schema)

(defop hull
"Makes a convex hull out of wrapped segments. Optional `:to` parameter specifies which
Expand Down Expand Up @@ -303,6 +303,12 @@
[& forms]
(impl/extrude forms))

(defn rebuild
"Rebuild an extrusion in the current context. Forms will re-evaluate their args. This can be used
in combination with dynamic binding to achieve specialization of extrusions."
[extrusion]
(extrude (:forms extrusion)))

(def ^{:doc (-> #'plexus.impl/extrusion? meta :doc) :arglists '([x])} extrusion? impl/extrusion?)
(def ^{:doc (-> #'plexus.impl/model? meta :doc) :arglists '([x])} model? impl/model?)
(def ^{:doc (-> #'plexus.impl/frame? meta :doc) :arglists '([x])} frame? impl/frame?)
Expand Down
7 changes: 5 additions & 2 deletions src/main/plexus/impl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
[plexus.triangles :as triangles]
[plexus.transforms :as tf]))

(declare extrude*)

(defrecord Extrusion [result-forms frames state angle-scalar forms transforms models main-model]
Object
(toString [_]
Expand Down Expand Up @@ -337,7 +339,8 @@
result-forms))

:plexus.impl/loft
(let [{:keys [to]} form
(let [{:keys [to algorithm]
:or {algorithm :eager-nearest-neighbor}} form
loft-forms (normalize-segment (:plexus.impl/list form))
loft-frames (or to current-frame-ids)
ret (extrude* state loft-forms frames)]
Expand All @@ -364,6 +367,7 @@
(m/loft
(cons
{:frame (-> first-segment :all-transforms (nth 0))
:algorithm algorithm
:cross-section (-> first-segment :cross-section)}
(mapcat
(fn [{:keys [cross-section all-transforms]}]
Expand Down Expand Up @@ -661,7 +665,6 @@
(throw e)
(let [form @current-form
{:keys [line column file]} (meta form)
_ (println "form:" form)
op (:op form)
error-string (format "Error while applying `%s` (line=%s, column=%s): %s" (name op)
line
Expand Down
4 changes: 4 additions & 0 deletions src/main/plexus/schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
[:cross-section {:optional true} :cross-section]
[:cs {:optional true} int?]])

(def loft-schema
[:map
[:algorithm {:optional true} keyword?]])

(def any-map-schema
[:map])

Expand Down

0 comments on commit c155c9a

Please sign in to comment.