Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
36eab10
Experiment with impl of sketch API
jtran Aug 22, 2025
8715217
Add AST to state
jtran Aug 29, 2025
f4bd6f0
Unify NumericSuffix types
jtran Sep 17, 2025
46d4100
Add StandardPlanes
jtran Sep 19, 2025
9a06a30
WIP: do actual parsing
jtran Sep 17, 2025
7b7239c
WIP: Continue on add_line
jtran Sep 19, 2025
65f843e
VisitableMut without children Vec
jtran Sep 21, 2025
0b1c32d
Fix add_line to compile and use new traversal
jtran Oct 1, 2025
1897a62
Implement most of move_line_start
jtran Oct 1, 2025
9b8f8af
Factor out source_from_ast()
jtran Oct 2, 2025
9e9743e
Return real ObjectIds from the frontend API new_sketch
jtran Oct 4, 2025
6237724
Add add_line
jtran Oct 8, 2025
e420f49
Add move_line_start execution
jtran Oct 17, 2025
2e3a7a8
Change function signatures to more closely match the trait
jtran Oct 17, 2025
7bbbe44
Add exit_sketch()
jtran Oct 17, 2025
1c065ff
Remove unused functions
jtran Oct 17, 2025
c82bf48
Remove unused NumericSuffix functions
jtran Oct 17, 2025
96bd2a3
Implement the SketchApi trait
jtran Oct 17, 2025
f505d65
Fix tsc error from trying to serialize SourceRange as map key
jtran Oct 18, 2025
7953d2e
Change RustContext methods to be private
jtran Oct 18, 2025
84997af
Move API back into kcl-lib
jtran Oct 18, 2025
72ac3ee
Revert "Remove unused NumericSuffix functions"
jtran Oct 18, 2025
259ab0e
Revert "Unify NumericSuffix types"
jtran Oct 18, 2025
92379d6
Finish moving API back into kcl-lib
jtran Oct 20, 2025
d6e6e39
Fix clippy warnings
jtran Oct 20, 2025
c304932
Add wasm_lib functions
jtran Oct 20, 2025
1bc08df
Add test for line
jtran Oct 20, 2025
668a9a7
Fix wasm-lib compile error by working around Rust compiler bug
jtran Oct 21, 2025
a98131d
Rename scene module to api
jtran Oct 21, 2025
4cb7e00
Fix API settings to be ExecutorSettings
jtran Oct 21, 2025
c49aeb0
Temporary fix to coerce SketchVar to number
jtran Oct 21, 2025
d4106c2
Fix rust_constrainable
jtran Oct 21, 2025
931a0d1
Fix Segment type
jtran Oct 21, 2025
a878978
Change return type of line() to Segment
jtran Oct 21, 2025
cba809f
Fix sketch2::line() to use Rust implementation
jtran Oct 21, 2025
ae6be54
Fix dot notation error message
jtran Oct 21, 2025
90f16d3
Update error message since it's an object, not an array
jtran Oct 21, 2025
fad3fcb
Fix dot notation access of Segment
jtran Oct 21, 2025
85d12bf
Fix test to use bracket notation for x and y of a point
jtran Oct 22, 2025
0f45d4e
Fix SketchVar coercion to number
jtran Oct 22, 2025
e85d6e2
Update generated output after execution success
jtran Oct 22, 2025
d18613e
Add actual KCL source to SourceDelta type
jtran Oct 22, 2025
89a9ba7
Add tracking and returning scene objects
jtran Oct 22, 2025
ceae1b7
Add execution to exit_sketch()
jtran Oct 22, 2025
8247da7
Add PointCtor type to be more uniform across segment types
jtran Oct 22, 2025
8c09940
Add ExecOutcome as field of SceneGraphDelta
jtran Oct 22, 2025
10ecf90
Fix wasm-lib to use mock ExecutorContext
jtran Oct 22, 2025
4f05bd6
Change new_sketch() to use mock execution
jtran Oct 22, 2025
8a6b829
Fix ObjectIds and use sketch2 module path
jtran Oct 22, 2025
f5b62ed
Update comments
jtran Oct 22, 2025
6f5f017
Add constrained freedom to segment start and end points
jtran Oct 22, 2025
9c21d4d
Update output after adding segment freedom
jtran Oct 22, 2025
6790d07
Fix to not ignore lint
jtran Oct 22, 2025
8bb5f40
Move wasm-lib sketch functions to api module
jtran Oct 22, 2025
4f195ad
Stub out rust a little
Irev-Dev Oct 16, 2025
9f8ae19
Fix compile error due to changing return type in the trait
jtran Oct 22, 2025
79a7d45
pull through bindings and add SketchExecOutcome to context
Irev-Dev Oct 17, 2025
730f4c6
make cursor happy
Irev-Dev Oct 17, 2025
e1cabe1
Fix return of add_segment_stub() to be an object instead of a tuple
jtran Oct 22, 2025
db32e32
Revert building ts-rs bindings for kcl-api
jtran Oct 22, 2025
5c12d89
Fix to not use kcl-api crate
jtran Oct 22, 2025
8d186d5
Fix import type error
jtran Oct 22, 2025
b14c853
Add addSegment() method that calls the full implementation
jtran Oct 22, 2025
2f35874
Fix to preserve scene_objects to ExecOutcome with new_sketch()
jtran Oct 22, 2025
850b2f9
Use more concise conversion to SourceRange
jtran Oct 22, 2025
077df1b
Add test for edit_line()
jtran Oct 22, 2025
fd4ac02
Fix to create sketch object before its contents to have a stable ID
jtran Oct 22, 2025
ba7c71f
Fix to take into account cached objects for next object ID
jtran Oct 22, 2025
8702129
Change frontend to always use caching
jtran Oct 22, 2025
67136f1
Fix warnings from not using things depending on the artifact-graph ca…
jtran Oct 23, 2025
f8ed72c
Fix ts-rs types and avoid as any in TypeScript
jtran Oct 23, 2025
c5f6638
Fix to be able to call add_segment() from TypeScript
jtran Oct 24, 2025
734fd48
Add point() KCL function and point segment type
jtran Oct 24, 2025
b9169d0
Change to only warn if the sketch ID doesn't match on exit_sketch
jtran Oct 24, 2025
385b3a9
Add a hacky way to set the current program AST
jtran Oct 24, 2025
135d07a
Add support for variable declaration for the sketch block
jtran Oct 24, 2025
c1c0eb9
Fix addSegment() to not incorrectly JSON.parse() the WASM result
jtran Oct 24, 2025
2006c37
Fix serialization of SourceRef since ts-rs support for tuple types is…
jtran Oct 24, 2025
34be42c
Rename and move functions to be clearer
jtran Oct 24, 2025
9492ec8
Add test for adding a line, starting from an existing sketch block
jtran Oct 24, 2025
5b6fa3b
Add doing a full traversal rather than only looking at the top-level …
jtran Oct 24, 2025
b3be7f2
Add other API functions to TypeScript side and fix addSegment types
jtran Oct 24, 2025
b18078a
Bump kcl-ezpz from 0.1.3 to 0.1.4
jtran Oct 24, 2025
9aad628
Add KCL coincident() constraint function that supports points
jtran Oct 24, 2025
937587e
Part 1: Add frontend API for adding coincident constraint
jtran Oct 24, 2025
d8d1591
Add coincident() support for a known segment point and a var point2d,…
jtran Oct 24, 2025
bfe93f9
Factor out frontend state update
jtran Oct 25, 2025
bf304ed
Add implementation of SketchExecOutcome for add_segment()
jtran Oct 26, 2025
6c69e8c
Add support for editing points in edit_segment()
jtran Oct 26, 2025
4817f1c
Add SketchExecOutcome to return of edit_segment()
jtran Oct 26, 2025
afb3389
Merge main
jtran Oct 28, 2025
116a122
Fix TS definition of ApiPlane
jtran Oct 28, 2025
4645fbb
make persistence for multiple points work (a bit better)
Irev-Dev Oct 28, 2025
2d20fba
persistance bug
Irev-Dev Oct 30, 2025
634a9f1
round
Irev-Dev Oct 30, 2025
c105fec
Merge main
jtran Oct 30, 2025
6533b39
Fix new redundant clone lint warnings
jtran Oct 30, 2025
d263b76
Add add_coincident()
jtran Oct 27, 2025
45bf070
Fix dfs to traverse the else block of if-else
jtran Oct 31, 2025
b5cc3fe
use vars when adding points
Irev-Dev Oct 31, 2025
49d90e1
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Oct 31, 2025
a14b0fb
add drag and coincident point and click
Irev-Dev Oct 31, 2025
3388443
use var for editSegmentToo
Irev-Dev Oct 31, 2025
d496ee2
use newSketch rust util
Irev-Dev Oct 31, 2025
f097ad9
Fix to allow sketch on negative default planes and remove redundant p…
jtran Oct 31, 2025
9b4c0f3
Delete constructors that we're not ready for and may never use
jtran Oct 31, 2025
262e2ca
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 3, 2025
4caf681
use CSS2DObjects
Irev-Dev Nov 3, 2025
c3d6cd5
match figma designs
Irev-Dev Nov 3, 2025
2a9fe54
more match designs tweaks
Irev-Dev Nov 3, 2025
074c182
use design icons
Irev-Dev Nov 3, 2025
36bbdc4
Change edit segment API to allow editing multiple segments at once
jtran Oct 31, 2025
d4b7f87
Fix performance by using mock execution
jtran Nov 3, 2025
700e755
Fix ApiObjectKind TS type
jtran Nov 3, 2025
624d921
Add editing lines via their end points and fix to preserve constructors
jtran Nov 3, 2025
5a0ae2a
Add allowing experimental features when calling new_sketch()
jtran Nov 3, 2025
d808a86
add the start of line tool (buggy) and update after rust nesting change
Irev-Dev Nov 3, 2025
ea608da
Add vertical() constraint
jtran Nov 3, 2025
3afb93a
Add horizontal() constraint
jtran Nov 4, 2025
b1b26f4
Factor out common constraint code
jtran Nov 4, 2025
9d1dcbf
Remove unused SketchExecOutcome type and descendents
jtran Nov 4, 2025
87f8e69
edit segment with point
Irev-Dev Nov 4, 2025
1b85b2b
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 4, 2025
729f8ab
finish adding a segment
Irev-Dev Nov 4, 2025
85c771f
prep for line body draw
Irev-Dev Nov 4, 2025
6d2ca31
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 4, 2025
2fbe4c5
draw line body
Irev-Dev Nov 4, 2025
7e93d8c
Add support for adding coincident constraint on line end points
jtran Nov 4, 2025
9ba1569
Fix clippy lints
jtran Nov 4, 2025
57eecdf
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 4, 2025
afcd43d
Add constraints to scene objects
jtran Nov 4, 2025
eac1aec
make coincident line end points animate correctly
Irev-Dev Nov 5, 2025
cf07b14
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 5, 2025
e36d881
Add equalLength() constraint on lines
jtran Nov 5, 2025
4ec0692
hack set program on direct edit
Irev-Dev Nov 5, 2025
e0131fe
add selection for line bodies, plus absract updating segments, finall…
Irev-Dev Nov 5, 2025
21ee49f
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 5, 2025
3165a40
add horz vert
Irev-Dev Nov 5, 2025
0c45986
Change line.start and line.end to return the point objects instead of…
jtran Nov 5, 2025
4c8b53f
fix lint error
Irev-Dev Nov 5, 2025
4dcabe7
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 5, 2025
b6b5e09
some hacks to make direct editing of code somewhat possible
Irev-Dev Nov 5, 2025
dc0b868
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 5, 2025
c09e61f
Remove support for coincident with a non-point KCL array
jtran Nov 5, 2025
2c76214
fix bug with points being late to show in scene
Irev-Dev Nov 6, 2025
8eecddb
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 6, 2025
f83f2d4
update point styling
Irev-Dev Nov 6, 2025
c20bcbe
add segment hover
Irev-Dev Nov 6, 2025
a4fc295
Upgrade to kcl-ezpz 0.1.5
jtran Nov 6, 2025
792570f
Add support for parallel constraint
jtran Nov 6, 2025
72c0eea
cleane up on sketch mode exit
Irev-Dev Nov 7, 2025
2c0402e
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 7, 2025
d330cdb
add parrallel constraint
Irev-Dev Nov 7, 2025
3fbc0ec
get move working for selected Ids
Irev-Dev Nov 7, 2025
ab07dc1
clean up 'as's
Irev-Dev Nov 7, 2025
53b3002
refactor three.js onDrag abstraction to detect css2dObjects as well, …
Irev-Dev Nov 8, 2025
f967b53
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 8, 2025
509eecf
don't direct import singletons
Irev-Dev Nov 9, 2025
f3f8318
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 9, 2025
4503422
fix singleton dependencies
Irev-Dev Nov 9, 2025
1ce5e64
Merge main
jtran Nov 12, 2025
1eec26e
Update package-lock.json to match npm install
jtran Nov 12, 2025
1e82b69
Add delete segments
jtran Nov 10, 2025
43165ce
Add delete constraints by changing delete_segments to delete_objects
jtran Nov 10, 2025
9157a45
Add test for deleting multiple segments at once
jtran Nov 10, 2025
2f7cec7
Fix coincident type to show that it only works on points now
jtran Nov 12, 2025
87aa9ab
Add distance(p1, p2) == x constraint
jtran Nov 12, 2025
5e69c13
add area select
Irev-Dev Nov 13, 2025
1d977eb
area select clean up
Irev-Dev Nov 13, 2025
7768cf5
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 13, 2025
63ebdd9
add breaks to toolbar
Irev-Dev Nov 13, 2025
916468e
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 13, 2025
967e243
Add comments documenting sketch block execution
jtran Nov 13, 2025
5847871
Merge main
jtran Nov 14, 2025
043ae44
mostly good area select label
Irev-Dev Nov 16, 2025
4ccf2e9
initial delete for sketch implemented - fails for when constraints ar…
Irev-Dev Nov 17, 2025
13028a5
basic distance constraint
Irev-Dev Nov 17, 2025
84d42c9
remove bad vars
Irev-Dev Nov 17, 2025
15a90f1
Update generated output after main merge
jtran Nov 17, 2025
38feab9
Add feeding back solver solution to the source
jtran Nov 13, 2025
9a3a43e
Add sketchExecuteMock to call after editing segments
jtran Nov 14, 2025
870a4f3
Change hackSetProgram() to return the SceneGraph and ExecOutcome
jtran Nov 14, 2025
7deb00b
Add deleting segments cascades to also delete constraints that refere…
jtran Nov 17, 2025
b36e496
Delete redundant delete_constraint() API
jtran Nov 17, 2025
f903283
tweak
Irev-Dev Nov 18, 2025
e6413c3
Merge remote-tracking branch 'origin' into sketch-revamp
Irev-Dev Nov 18, 2025
0a82a9b
clean up uglyiness of css2dObjecs
Irev-Dev Nov 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ venv
.vscode-test
.biome/
.million
.cursor
2 changes: 0 additions & 2 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 46 additions & 6 deletions rust/kcl-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![allow(async_fn_in_trait)]

use kcl_error::SourceRange;
use kcl_error::{CompilationError, SourceRange};
use serde::{Deserialize, Serialize};

pub mod sketch;
Expand Down Expand Up @@ -105,6 +105,7 @@ pub struct Object {
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
pub enum ObjectKind {
Plane(Plane),
Sketch(crate::sketch::Sketch),
Segment(crate::sketch::Segment),
Constraint(crate::sketch::Constraint),
Expand All @@ -116,7 +117,40 @@ pub enum ObjectKind {
#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
pub enum Plane {
Object(ObjectId),
Default,
Default(StandardPlane),
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize, ts_rs::TS)]
pub enum StandardPlane {
#[serde(rename = "XY")]
XY,
#[serde(rename = "YZ")]
YZ,
#[serde(rename = "XZ")]
XZ,
}

impl std::fmt::Display for StandardPlane {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
StandardPlane::XY => write!(f, "XY"),
StandardPlane::YZ => write!(f, "YZ"),
StandardPlane::XZ => write!(f, "XZ"),
}
}
}

impl std::str::FromStr for StandardPlane {
type Err = CompilationError;

fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
match s {
"XY" => Ok(StandardPlane::XY),
"YZ" => Ok(StandardPlane::YZ),
"XZ" => Ok(StandardPlane::XZ),
_ => Err(CompilationError::err(SourceRange::default(), "invalid standard plane")),
}
}
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
Expand All @@ -125,14 +159,20 @@ pub enum SourceRef {
BackTrace(Vec<SourceRange>),
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
impl From<SourceRange> for SourceRef {
fn from(value: SourceRange) -> Self {
Self::Simple(value)
}
}

#[derive(Debug, Clone, Copy, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct Number {
value: f64,
units: NumericSuffix,
pub value: f64,
pub units: NumericSuffix,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export)]
pub enum Expr {
Number(Number),
Expand Down
32 changes: 16 additions & 16 deletions rust/kcl-api/src/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub struct SketchArgs {
pub on: Plane,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export, rename = "ApiPoint")]
pub struct Point {
pub position: Point2d<Number>,
Expand All @@ -94,15 +94,15 @@ pub struct Point {
pub constraints: Vec<ObjectId>,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export)]
pub enum Freedom {
Free,
Partial,
Fixed,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export, rename = "ApiSegment")]
pub enum Segment {
Point(Point),
Expand All @@ -111,7 +111,7 @@ pub enum Segment {
Circle(Circle),
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export)]
pub enum SegmentCtor {
Point(Point2d<Expr>),
Expand All @@ -124,14 +124,14 @@ pub enum SegmentCtor {
ThreePointCircle(ThreePointCircleCtor),
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export, rename = "ApiPoint2d")]
pub struct Point2d<U: std::fmt::Debug + Clone + ts_rs::TS> {
pub x: U,
pub y: U,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export, rename = "ApiLine")]
pub struct Line {
pub start: ObjectId,
Expand All @@ -146,28 +146,28 @@ pub struct Line {
pub ctor_applicable: bool,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct LineCtor {
pub start: Point2d<Expr>,
pub end: Point2d<Expr>,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct MidPointLineCtor {
pub midpoint: Point2d<Expr>,
pub start_or_end: StartOrEnd<Point2d<Expr>>,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export, rename = "ApiStartOrEnd")]
pub enum StartOrEnd<T> {
Start(T),
End(T),
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export, rename = "ApiArc")]
pub struct Arc {
pub start: ObjectId,
Expand All @@ -178,31 +178,31 @@ pub struct Arc {
pub ctor_applicable: bool,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct ArcCtor {
pub start: Point2d<Expr>,
pub end: Point2d<Expr>,
pub center: Point2d<Expr>,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct ThreePointArcCtor {
pub start: Point2d<Expr>,
pub end: Point2d<Expr>,
pub interior: Point2d<Expr>,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct TangentArcCtor {
pub start: Point2d<Expr>,
pub end: Point2d<Expr>,
pub tangent: StartOrEnd<ObjectId>,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export, rename = "ApiCircle")]
pub struct Circle {
pub start: ObjectId,
Expand All @@ -212,14 +212,14 @@ pub struct Circle {
pub ctor_applicable: bool,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct CircleCtor {
pub center: Point2d<Expr>,
pub radius: Expr,
}

#[derive(Debug, Clone, Deserialize, Serialize, ts_rs::TS)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct ThreePointCircleCtor {
pub p1: Point2d<Expr>,
Expand Down
1 change: 0 additions & 1 deletion rust/kcl-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ http = { workspace = true }
image = { version = "0.25.8", default-features = false, features = ["png"] }
indexmap = { workspace = true, features = ["serde", "rayon"] }
itertools = "0.14.0"
kcl-api = { version = "0.1", path = "../kcl-api" }
kcl-derive-docs = { version = "0.1", path = "../kcl-derive-docs" }
kcl-error = { version = "0.1", path = "../kcl-error" }
kcl-ezpz = { workspace = true }
Expand Down
12 changes: 11 additions & 1 deletion rust/kcl-lib/src/execution/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@ pub(crate) const IMPL: &str = "impl";
pub(crate) const IMPL_RUST: &str = "std_rust";
pub(crate) const IMPL_CONSTRAINT: &str = "std_rust_constraint";
pub(crate) const IMPL_CONSTRAINABLE: &str = "std_constrainable";
pub(crate) const IMPL_RUST_CONSTRAINABLE: &str = "std_rust_constrainable";
pub(crate) const IMPL_KCL: &str = "kcl";
pub(crate) const IMPL_PRIMITIVE: &str = "primitive";
pub(super) const IMPL_VALUES: [&str; 5] = [IMPL_RUST, IMPL_KCL, IMPL_PRIMITIVE, IMPL_CONSTRAINT, IMPL_CONSTRAINABLE];
pub(super) const IMPL_VALUES: [&str; 6] = [
IMPL_RUST,
IMPL_KCL,
IMPL_PRIMITIVE,
IMPL_CONSTRAINT,
IMPL_CONSTRAINABLE,
IMPL_RUST_CONSTRAINABLE,
];

pub(crate) const WARNINGS: &str = "warnings";
pub(crate) const WARN_ALLOW: &str = "allow";
Expand Down Expand Up @@ -110,6 +118,7 @@ pub enum Impl {
Kcl,
KclConstrainable,
Rust,
RustConstrainable,
RustConstraint,
Primitive,
}
Expand All @@ -122,6 +131,7 @@ impl FromStr for Impl {
IMPL_RUST => Ok(Self::Rust),
IMPL_CONSTRAINT => Ok(Self::RustConstraint),
IMPL_CONSTRAINABLE => Ok(Self::KclConstrainable),
IMPL_RUST_CONSTRAINABLE => Ok(Self::RustConstrainable),
IMPL_KCL => Ok(Self::Kcl),
IMPL_PRIMITIVE => Ok(Self::Primitive),
_ => Err(()),
Expand Down
6 changes: 6 additions & 0 deletions rust/kcl-lib/src/execution/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ impl GlobalState {
operations: self.exec_state.root_module_artifacts.operations,
#[cfg(feature = "artifact-graph")]
artifact_graph: self.exec_state.artifacts.graph,
#[cfg(feature = "artifact-graph")]
scene_objects: self.exec_state.root_module_artifacts.scene_objects,
#[cfg(feature = "artifact-graph")]
source_range_to_object: self.exec_state.root_module_artifacts.source_range_to_object,
#[cfg(feature = "artifact-graph")]
var_solutions: self.exec_state.root_module_artifacts.var_solutions,
errors: self.exec_state.errors,
default_planes: ctx.engine.get_default_planes().read().await.clone(),
}
Expand Down
23 changes: 23 additions & 0 deletions rust/kcl-lib/src/execution/cad_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ pub enum OpKclValue {
Face {
artifact_id: ArtifactId,
},
Segment {
artifact_id: ArtifactId,
},
Sketch {
value: Box<OpSketch>,
},
Expand Down Expand Up @@ -238,6 +241,10 @@ impl From<&KclValue> for OpKclValue {
value: value.initial_value,
ty: value.ty,
},
KclValue::SketchConstraint { .. } => {
debug_assert!(false, "Sketch constraint cannot be represented in operations");
Self::KclNone {}
}
KclValue::Tuple { value, .. } | KclValue::HomArray { value, .. } => {
let value = value.iter().map(Self::from).collect();
Self::Array { value }
Expand All @@ -262,6 +269,22 @@ impl From<&KclValue> for OpKclValue {
KclValue::Face { value } => Self::Face {
artifact_id: value.artifact_id,
},
KclValue::Segment { value } => match &value.repr {
crate::execution::geometry::SegmentRepr::Unsolved { .. } => {
// Arguments to constraint functions will be unsolved.
Self::KclNone {}
}
crate::execution::geometry::SegmentRepr::Solved { .. } => {
debug_assert!(
false,
"Solved segment not sent to the engine cannot be represented in operations"
);
Self::KclNone {}
}
crate::execution::geometry::SegmentRepr::InEngine { id, .. } => Self::Segment {
artifact_id: ArtifactId::new(*id),
},
},
KclValue::Sketch { value } => Self::Sketch {
value: Box::new(OpSketch {
artifact_id: value.artifact_id,
Expand Down
Loading
Loading