Compare commits
12 Commits
achalmers/
...
kurt-contr
Author | SHA1 | Date | |
---|---|---|---|
5474b3409e | |||
29ae16fbf0 | |||
fba62dab98 | |||
38ee257996 | |||
a85a534d6b | |||
6ddbb7a31d | |||
051bb0589e | |||
47c29b2681 | |||
23f51d73ee | |||
f752a496de | |||
6545fb6db0 | |||
e63eb18d65 |
55
docs/kcl-std/functions/std-sketch-rectangle.md
Normal file
@ -72,6 +72,7 @@ layout: manual
|
||||
* [`profileStart`](/docs/kcl-std/functions/std-sketch-profileStart)
|
||||
* [`profileStartX`](/docs/kcl-std/functions/std-sketch-profileStartX)
|
||||
* [`profileStartY`](/docs/kcl-std/functions/std-sketch-profileStartY)
|
||||
* [`rectangle`](/docs/kcl-std/functions/std-sketch-rectangle)
|
||||
* [`revolve`](/docs/kcl-std/functions/std-sketch-revolve)
|
||||
* [`segAng`](/docs/kcl-std/functions/std-sketch-segAng)
|
||||
* [`segEnd`](/docs/kcl-std/functions/std-sketch-segEnd)
|
||||
|
@ -37,6 +37,7 @@ This module contains functions for creating and manipulating sketches, and makin
|
||||
* [`profileStart`](/docs/kcl-std/functions/std-sketch-profileStart)
|
||||
* [`profileStartX`](/docs/kcl-std/functions/std-sketch-profileStartX)
|
||||
* [`profileStartY`](/docs/kcl-std/functions/std-sketch-profileStartY)
|
||||
* [`rectangle`](/docs/kcl-std/functions/std-sketch-rectangle)
|
||||
* [`revolve`](/docs/kcl-std/functions/std-sketch-revolve)
|
||||
* [`segAng`](/docs/kcl-std/functions/std-sketch-segAng)
|
||||
* [`segEnd`](/docs/kcl-std/functions/std-sketch-segEnd)
|
||||
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
18
package-lock.json
generated
@ -43,6 +43,7 @@
|
||||
"bson": "^6.10.3",
|
||||
"chokidar": "^4.0.3",
|
||||
"codemirror": "^6.0.1",
|
||||
"culori": "^4.0.2",
|
||||
"decamelize": "^6.0.0",
|
||||
"diff": "^7.0.0",
|
||||
"electron-updater": "^6.6.2",
|
||||
@ -92,6 +93,7 @@
|
||||
"@playwright/test": "^1.52.0",
|
||||
"@testing-library/jest-dom": "^5.17.0",
|
||||
"@testing-library/react": "^15.0.7",
|
||||
"@types/culori": "^4.0.0",
|
||||
"@types/diff": "^7.0.2",
|
||||
"@types/electron": "^1.6.10",
|
||||
"@types/hammerjs": "^2.0.46",
|
||||
@ -7392,6 +7394,13 @@
|
||||
"integrity": "sha512-nl09VhutdjINdWyXxHWN/w9zlNCfr60JUqJbd24YXUuCwgeL0TpFSdElCwb6cxfB6ybE19Gjj4g0jsgkXxKv1Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/culori": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/culori/-/culori-4.0.0.tgz",
|
||||
"integrity": "sha512-aFljQwjb++sl6TAyEXeHTiK/fk9epZOQ+nMmadjnAvzZFIvNoQ0x8XQYfcOaRTBwmDUPUlghhZCJ66MTcqQAsg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/debug": {
|
||||
"version": "4.1.12",
|
||||
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz",
|
||||
@ -11823,6 +11832,15 @@
|
||||
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/culori": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/culori/-/culori-4.0.2.tgz",
|
||||
"integrity": "sha512-1+BhOB8ahCn4O0cep0Sh2l9KCOfOdY+BXJnKMHFFzDEouSr/el18QwXEMRlOj9UY5nCeA8UN3a/82rUWRBeyBw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/damerau-levenshtein": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz",
|
||||
|
@ -45,6 +45,7 @@
|
||||
"bson": "^6.10.3",
|
||||
"chokidar": "^4.0.3",
|
||||
"codemirror": "^6.0.1",
|
||||
"culori": "^4.0.2",
|
||||
"decamelize": "^6.0.0",
|
||||
"diff": "^7.0.0",
|
||||
"electron-updater": "^6.6.2",
|
||||
@ -170,6 +171,7 @@
|
||||
"@playwright/test": "^1.52.0",
|
||||
"@testing-library/jest-dom": "^5.17.0",
|
||||
"@testing-library/react": "^15.0.7",
|
||||
"@types/culori": "^4.0.0",
|
||||
"@types/diff": "^7.0.2",
|
||||
"@types/electron": "^1.6.10",
|
||||
"@types/hammerjs": "^2.0.46",
|
||||
|
20
rust/Cargo.lock
generated
@ -1814,7 +1814,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-bumper"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@ -1825,7 +1825,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-derive-docs"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1834,7 +1834,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-directory-test-macro"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"proc-macro2",
|
||||
@ -1844,7 +1844,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-language-server"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@ -1865,7 +1865,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-language-server-release"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@ -1885,7 +1885,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-lib"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"approx 0.5.1",
|
||||
@ -1962,7 +1962,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-python-bindings"
|
||||
version = "0.3.83"
|
||||
version = "0.3.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"kcl-lib",
|
||||
@ -1977,7 +1977,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-test-server"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hyper 0.14.32",
|
||||
@ -1990,7 +1990,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-to-core"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -2004,7 +2004,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kcl-wasm-lib"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bson",
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
[package]
|
||||
name = "kcl-bumper"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
repository = "https://github.com/KittyCAD/modeling-api"
|
||||
rust-version = "1.76"
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-derive-docs"
|
||||
description = "A tool for generating documentation from Rust derive macros"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -100,6 +100,8 @@ pub const TEST_NAMES: &[&str] = &[
|
||||
"std-sketch-planeOf-0",
|
||||
"std-sketch-circle-0",
|
||||
"std-sketch-circle-1",
|
||||
"std-sketch-rectangle-0",
|
||||
"std-sketch-rectangle-1",
|
||||
"std-sketch-patternTransform2d-0",
|
||||
"std-sketch-revolve-0",
|
||||
"std-sketch-revolve-1",
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-directory-test-macro"
|
||||
description = "A tool for generating tests from a directory of kcl files"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "kcl-language-server-release"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
authors = ["KittyCAD Inc <kcl@kittycad.io>"]
|
||||
publish = false
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "kcl-language-server"
|
||||
description = "A language server for KCL."
|
||||
authors = ["KittyCAD Inc <kcl@kittycad.io>"]
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-lib"
|
||||
description = "KittyCAD Language implementation and tools"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -864,6 +864,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.execute(exec_state, ctx).await,
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.get_result(exec_state, ctx).await,
|
||||
BinaryPart::MemberExpression(member_expression) => member_expression.get_result(exec_state, ctx).await,
|
||||
BinaryPart::ArrayExpression(e) => e.execute(exec_state, ctx).await,
|
||||
BinaryPart::ArrayRangeExpression(e) => e.execute(exec_state, ctx).await,
|
||||
BinaryPart::ObjectExpression(e) => e.execute(exec_state, ctx).await,
|
||||
BinaryPart::IfExpression(e) => e.get_result(exec_state, ctx).await,
|
||||
BinaryPart::AscribedExpression(e) => e.get_result(exec_state, ctx).await,
|
||||
}
|
||||
@ -1046,6 +1049,16 @@ impl Node<MemberExpression> {
|
||||
(KclValue::Solid { value }, Property::String(prop), false) if prop == "sketch" => Ok(KclValue::Sketch {
|
||||
value: Box::new(value.sketch),
|
||||
}),
|
||||
(geometry @ KclValue::Solid { .. }, Property::String(prop), false) if prop == "tags" => {
|
||||
// This is a common mistake.
|
||||
Err(KclError::new_semantic(KclErrorDetails::new(
|
||||
format!(
|
||||
"Property `{prop}` not found on {}. You can get a solid's tags through its sketch, as in, `exampleSolid.sketch.tags`.",
|
||||
geometry.human_friendly_type()
|
||||
),
|
||||
vec![self.clone().into()],
|
||||
)))
|
||||
}
|
||||
(KclValue::Sketch { value: sk }, Property::String(prop), false) if prop == "tags" => Ok(KclValue::Object {
|
||||
meta: vec![Metadata {
|
||||
source_range: SourceRange::from(self.clone()),
|
||||
@ -1056,6 +1069,12 @@ impl Node<MemberExpression> {
|
||||
.map(|(k, tag)| (k.to_owned(), KclValue::TagIdentifier(Box::new(tag.to_owned()))))
|
||||
.collect(),
|
||||
}),
|
||||
(geometry @ (KclValue::Sketch { .. } | KclValue::Solid { .. }), Property::String(property), false) => {
|
||||
Err(KclError::new_semantic(KclErrorDetails::new(
|
||||
format!("Property `{property}` not found on {}", geometry.human_friendly_type()),
|
||||
vec![self.clone().into()],
|
||||
)))
|
||||
}
|
||||
(being_indexed, _, _) => Err(KclError::new_semantic(KclErrorDetails::new(
|
||||
format!(
|
||||
"Only arrays can be indexed, but you're trying to index {}",
|
||||
|
@ -1031,7 +1031,7 @@ pub struct GeoMeta {
|
||||
#[ts(export)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum Path {
|
||||
/// A path that goes to a point.
|
||||
/// A straight line which ends at the given point.
|
||||
ToPoint {
|
||||
#[serde(flatten)]
|
||||
base: BasePath,
|
||||
|
@ -149,6 +149,9 @@ impl BinaryPart {
|
||||
BinaryPart::UnaryExpression(unary_expression) => {
|
||||
unary_expression.get_hover_value_for_position(pos, code, opts)
|
||||
}
|
||||
BinaryPart::ArrayExpression(e) => e.get_hover_value_for_position(pos, code, opts),
|
||||
BinaryPart::ArrayRangeExpression(e) => e.get_hover_value_for_position(pos, code, opts),
|
||||
BinaryPart::ObjectExpression(e) => e.get_hover_value_for_position(pos, code, opts),
|
||||
BinaryPart::IfExpression(e) => e.get_hover_value_for_position(pos, code, opts),
|
||||
BinaryPart::AscribedExpression(e) => e.expr.get_hover_value_for_position(pos, code, opts),
|
||||
BinaryPart::MemberExpression(member_expression) => {
|
||||
|
@ -161,6 +161,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(ce) => ce.compute_digest(),
|
||||
BinaryPart::UnaryExpression(ue) => ue.compute_digest(),
|
||||
BinaryPart::MemberExpression(me) => me.compute_digest(),
|
||||
BinaryPart::ArrayExpression(e) => e.compute_digest(),
|
||||
BinaryPart::ArrayRangeExpression(e) => e.compute_digest(),
|
||||
BinaryPart::ObjectExpression(e) => e.compute_digest(),
|
||||
BinaryPart::IfExpression(e) => e.compute_digest(),
|
||||
BinaryPart::AscribedExpression(e) => e.compute_digest(),
|
||||
}
|
||||
|
@ -51,6 +51,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.module_id,
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.module_id,
|
||||
BinaryPart::MemberExpression(member_expression) => member_expression.module_id,
|
||||
BinaryPart::ArrayExpression(e) => e.module_id,
|
||||
BinaryPart::ArrayRangeExpression(e) => e.module_id,
|
||||
BinaryPart::ObjectExpression(e) => e.module_id,
|
||||
BinaryPart::IfExpression(e) => e.module_id,
|
||||
BinaryPart::AscribedExpression(e) => e.module_id,
|
||||
}
|
||||
|
@ -1214,6 +1214,9 @@ impl From<&BinaryPart> for Expr {
|
||||
BinaryPart::CallExpressionKw(call_expression) => Expr::CallExpressionKw(call_expression.clone()),
|
||||
BinaryPart::UnaryExpression(unary_expression) => Expr::UnaryExpression(unary_expression.clone()),
|
||||
BinaryPart::MemberExpression(member_expression) => Expr::MemberExpression(member_expression.clone()),
|
||||
BinaryPart::ArrayExpression(e) => Expr::ArrayExpression(e.clone()),
|
||||
BinaryPart::ArrayRangeExpression(e) => Expr::ArrayRangeExpression(e.clone()),
|
||||
BinaryPart::ObjectExpression(e) => Expr::ObjectExpression(e.clone()),
|
||||
BinaryPart::IfExpression(e) => Expr::IfExpression(e.clone()),
|
||||
BinaryPart::AscribedExpression(e) => Expr::AscribedExpression(e.clone()),
|
||||
}
|
||||
@ -1281,6 +1284,9 @@ pub enum BinaryPart {
|
||||
CallExpressionKw(BoxNode<CallExpressionKw>),
|
||||
UnaryExpression(BoxNode<UnaryExpression>),
|
||||
MemberExpression(BoxNode<MemberExpression>),
|
||||
ArrayExpression(BoxNode<ArrayExpression>),
|
||||
ArrayRangeExpression(BoxNode<ArrayRangeExpression>),
|
||||
ObjectExpression(BoxNode<ObjectExpression>),
|
||||
IfExpression(BoxNode<IfExpression>),
|
||||
AscribedExpression(BoxNode<AscribedExpression>),
|
||||
}
|
||||
@ -1307,6 +1313,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.get_constraint_level(),
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.get_constraint_level(),
|
||||
BinaryPart::MemberExpression(member_expression) => member_expression.get_constraint_level(),
|
||||
BinaryPart::ArrayExpression(e) => e.get_constraint_level(),
|
||||
BinaryPart::ArrayRangeExpression(e) => e.get_constraint_level(),
|
||||
BinaryPart::ObjectExpression(e) => e.get_constraint_level(),
|
||||
BinaryPart::IfExpression(e) => e.get_constraint_level(),
|
||||
BinaryPart::AscribedExpression(e) => e.expr.get_constraint_level(),
|
||||
}
|
||||
@ -1320,6 +1329,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.replace_value(source_range, new_value),
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.replace_value(source_range, new_value),
|
||||
BinaryPart::MemberExpression(_) => {}
|
||||
BinaryPart::ArrayExpression(e) => e.replace_value(source_range, new_value),
|
||||
BinaryPart::ArrayRangeExpression(e) => e.replace_value(source_range, new_value),
|
||||
BinaryPart::ObjectExpression(e) => e.replace_value(source_range, new_value),
|
||||
BinaryPart::IfExpression(e) => e.replace_value(source_range, new_value),
|
||||
BinaryPart::AscribedExpression(e) => e.expr.replace_value(source_range, new_value),
|
||||
}
|
||||
@ -1333,6 +1345,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.start,
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.start,
|
||||
BinaryPart::MemberExpression(member_expression) => member_expression.start,
|
||||
BinaryPart::ArrayExpression(e) => e.start,
|
||||
BinaryPart::ArrayRangeExpression(e) => e.start,
|
||||
BinaryPart::ObjectExpression(e) => e.start,
|
||||
BinaryPart::IfExpression(e) => e.start,
|
||||
BinaryPart::AscribedExpression(e) => e.start,
|
||||
}
|
||||
@ -1346,6 +1361,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.end,
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.end,
|
||||
BinaryPart::MemberExpression(member_expression) => member_expression.end,
|
||||
BinaryPart::ArrayExpression(e) => e.end,
|
||||
BinaryPart::ArrayRangeExpression(e) => e.end,
|
||||
BinaryPart::ObjectExpression(e) => e.end,
|
||||
BinaryPart::IfExpression(e) => e.end,
|
||||
BinaryPart::AscribedExpression(e) => e.end,
|
||||
}
|
||||
@ -1360,6 +1378,9 @@ impl BinaryPart {
|
||||
BinaryPart::CallExpressionKw(call_expression) => call_expression.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::UnaryExpression(unary_expression) => unary_expression.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::MemberExpression(member_expression) => member_expression.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::ArrayExpression(e) => e.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::ArrayRangeExpression(e) => e.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::ObjectExpression(e) => e.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::IfExpression(if_expression) => if_expression.rename_identifiers(old_name, new_name),
|
||||
BinaryPart::AscribedExpression(e) => e.expr.rename_identifiers(old_name, new_name),
|
||||
}
|
||||
|
@ -624,9 +624,6 @@ fn operand(i: &mut TokenSlice) -> ModalResult<BinaryPart> {
|
||||
Expr::FunctionExpression(_)
|
||||
| Expr::PipeExpression(_)
|
||||
| Expr::PipeSubstitution(_)
|
||||
| Expr::ArrayExpression(_)
|
||||
| Expr::ArrayRangeExpression(_)
|
||||
| Expr::ObjectExpression(_)
|
||||
| Expr::LabelledExpression(..) => return Err(CompilationError::fatal(source_range, TODO_783)),
|
||||
Expr::None(_) => {
|
||||
return Err(CompilationError::fatal(
|
||||
@ -652,6 +649,9 @@ fn operand(i: &mut TokenSlice) -> ModalResult<BinaryPart> {
|
||||
Expr::BinaryExpression(x) => BinaryPart::BinaryExpression(x),
|
||||
Expr::CallExpressionKw(x) => BinaryPart::CallExpressionKw(x),
|
||||
Expr::MemberExpression(x) => BinaryPart::MemberExpression(x),
|
||||
Expr::ArrayExpression(x) => BinaryPart::ArrayExpression(x),
|
||||
Expr::ArrayRangeExpression(x) => BinaryPart::ArrayRangeExpression(x),
|
||||
Expr::ObjectExpression(x) => BinaryPart::ObjectExpression(x),
|
||||
Expr::IfExpression(x) => BinaryPart::IfExpression(x),
|
||||
Expr::AscribedExpression(x) => BinaryPart::AscribedExpression(x),
|
||||
};
|
||||
@ -2115,6 +2115,8 @@ fn possible_operands(i: &mut TokenSlice) -> ModalResult<Expr> {
|
||||
literal.map(Expr::Literal),
|
||||
fn_call_kw.map(Box::new).map(Expr::CallExpressionKw),
|
||||
name.map(Box::new).map(Expr::Name),
|
||||
array,
|
||||
object.map(Box::new).map(Expr::ObjectExpression),
|
||||
binary_expr_in_parens.map(Box::new).map(Expr::BinaryExpression),
|
||||
unnecessarily_bracketed,
|
||||
))
|
||||
@ -3398,6 +3400,27 @@ mod tests {
|
||||
operand.parse(tokens).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_binary_operator_on_array() {
|
||||
let tokens = crate::parsing::token::lex("[0] + 1", ModuleId::default()).unwrap();
|
||||
let tokens = tokens.as_slice();
|
||||
binary_expression.parse(tokens).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_binary_operator_on_object() {
|
||||
let tokens = crate::parsing::token::lex("{ a = 1 } + 2", ModuleId::default()).unwrap();
|
||||
let tokens = tokens.as_slice();
|
||||
binary_expression.parse(tokens).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_call_array_operator() {
|
||||
let tokens = crate::parsing::token::lex("f([0] + 1)", ModuleId::default()).unwrap();
|
||||
let tokens = tokens.as_slice();
|
||||
fn_call_kw.parse(tokens).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weird_program_just_a_pipe() {
|
||||
let tokens = crate::parsing::token::lex("|", ModuleId::default()).unwrap();
|
||||
|
@ -779,6 +779,27 @@ mod add_lots {
|
||||
super::execute(TEST_NAME, false).await
|
||||
}
|
||||
}
|
||||
mod add_arrays {
|
||||
const TEST_NAME: &str = "add_arrays";
|
||||
|
||||
/// Test parsing KCL.
|
||||
#[test]
|
||||
fn parse() {
|
||||
super::parse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn unparse() {
|
||||
super::unparse(TEST_NAME).await
|
||||
}
|
||||
|
||||
/// Test that KCL is executed correctly.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_execute() {
|
||||
super::execute(TEST_NAME, false).await
|
||||
}
|
||||
}
|
||||
mod argument_error {
|
||||
//! The argument error points to the problematic argument in the call site,
|
||||
//! not the function definition that the variable points to.
|
||||
@ -887,6 +908,27 @@ mod invalid_index_fractional {
|
||||
super::execute(TEST_NAME, false).await
|
||||
}
|
||||
}
|
||||
mod property_access_not_found_on_solid {
|
||||
const TEST_NAME: &str = "property_access_not_found_on_solid";
|
||||
|
||||
/// Test parsing KCL.
|
||||
#[test]
|
||||
fn parse() {
|
||||
super::parse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn unparse() {
|
||||
super::unparse(TEST_NAME).await
|
||||
}
|
||||
|
||||
/// Test that KCL is executed correctly.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_execute() {
|
||||
super::execute(TEST_NAME, true).await
|
||||
}
|
||||
}
|
||||
mod invalid_member_object {
|
||||
const TEST_NAME: &str = "invalid_member_object";
|
||||
|
||||
@ -3632,6 +3674,48 @@ mod non_english_identifiers {
|
||||
super::execute(TEST_NAME, true).await
|
||||
}
|
||||
}
|
||||
mod rect {
|
||||
const TEST_NAME: &str = "rect";
|
||||
|
||||
/// Test parsing KCL.
|
||||
#[test]
|
||||
fn parse() {
|
||||
super::parse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn unparse() {
|
||||
super::unparse(TEST_NAME).await
|
||||
}
|
||||
|
||||
/// Test that KCL is executed correctly.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_execute() {
|
||||
super::execute(TEST_NAME, true).await
|
||||
}
|
||||
}
|
||||
mod rect_helper {
|
||||
const TEST_NAME: &str = "rect_helper";
|
||||
|
||||
/// Test parsing KCL.
|
||||
#[test]
|
||||
fn parse() {
|
||||
super::parse(TEST_NAME)
|
||||
}
|
||||
|
||||
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn unparse() {
|
||||
super::unparse(TEST_NAME).await
|
||||
}
|
||||
|
||||
/// Test that KCL is executed correctly.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_execute() {
|
||||
super::execute(TEST_NAME, true).await
|
||||
}
|
||||
}
|
||||
mod plane_of {
|
||||
const TEST_NAME: &str = "plane_of";
|
||||
|
||||
|
@ -256,6 +256,10 @@ pub(crate) fn std_fn(path: &str, fn_name: &str) -> (crate::std::StdFn, StdFnProp
|
||||
|e, a| Box::pin(crate::std::shapes::circle(e, a)),
|
||||
StdFnProps::default("std::sketch::circle"),
|
||||
),
|
||||
("sketch", "rectangle") => (
|
||||
|e, a| Box::pin(crate::std::shapes::rectangle(e, a)),
|
||||
StdFnProps::default("std::sketch::rectangle"),
|
||||
),
|
||||
("sketch", "planeOf") => (
|
||||
|e, a| Box::pin(crate::std::planes::plane_of(e, a)),
|
||||
StdFnProps::default("std::sketch::planeOf"),
|
||||
|
@ -38,6 +38,119 @@ pub enum SketchOrSurface {
|
||||
Sketch(Box<Sketch>),
|
||||
}
|
||||
|
||||
/// Sketch a rectangle.
|
||||
pub async fn rectangle(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let sketch_or_surface =
|
||||
args.get_unlabeled_kw_arg("sketchOrSurface", &RuntimeType::sketch_or_surface(), exec_state)?;
|
||||
let center = args.get_kw_arg_opt("center", &RuntimeType::point2d(), exec_state)?;
|
||||
let corner = args.get_kw_arg_opt("corner", &RuntimeType::point2d(), exec_state)?;
|
||||
let width: TyF64 = args.get_kw_arg("width", &RuntimeType::length(), exec_state)?;
|
||||
let height: TyF64 = args.get_kw_arg("height", &RuntimeType::length(), exec_state)?;
|
||||
|
||||
inner_rectangle(sketch_or_surface, center, corner, width, height, exec_state, args)
|
||||
.await
|
||||
.map(Box::new)
|
||||
.map(|value| KclValue::Sketch { value })
|
||||
}
|
||||
|
||||
async fn inner_rectangle(
|
||||
sketch_or_surface: SketchOrSurface,
|
||||
center: Option<[TyF64; 2]>,
|
||||
corner: Option<[TyF64; 2]>,
|
||||
width: TyF64,
|
||||
height: TyF64,
|
||||
exec_state: &mut ExecState,
|
||||
args: Args,
|
||||
) -> Result<Sketch, KclError> {
|
||||
let sketch_surface = match sketch_or_surface {
|
||||
SketchOrSurface::SketchSurface(surface) => surface,
|
||||
SketchOrSurface::Sketch(s) => s.on,
|
||||
};
|
||||
|
||||
// Find the corner in the negative quadrant
|
||||
let (ty, corner) = match (center, corner) {
|
||||
(Some(center), None) => (
|
||||
center[0].ty,
|
||||
[center[0].n - width.n / 2.0, center[1].n - height.n / 2.0],
|
||||
),
|
||||
(None, Some(corner)) => (corner[0].ty, [corner[0].n, corner[1].n]),
|
||||
(None, None) => {
|
||||
return Err(KclError::new_semantic(KclErrorDetails::new(
|
||||
"You must supply either `corner` or `center` arguments, but not both".to_string(),
|
||||
vec![args.source_range],
|
||||
)));
|
||||
}
|
||||
(Some(_), Some(_)) => {
|
||||
return Err(KclError::new_semantic(KclErrorDetails::new(
|
||||
"You must supply either `corner` or `center` arguments, but not both".to_string(),
|
||||
vec![args.source_range],
|
||||
)));
|
||||
}
|
||||
};
|
||||
let units = ty.expect_length();
|
||||
let corner_t = [TyF64::new(corner[0], ty), TyF64::new(corner[1], ty)];
|
||||
|
||||
// Start the sketch then draw the 4 lines.
|
||||
let sketch =
|
||||
crate::std::sketch::inner_start_profile(sketch_surface, corner_t, None, exec_state, args.clone()).await?;
|
||||
let sketch_id = sketch.id;
|
||||
let deltas = [[width.n, 0.0], [0.0, height.n], [-width.n, 0.0], [0.0, -height.n]];
|
||||
let ids = [
|
||||
exec_state.next_uuid(),
|
||||
exec_state.next_uuid(),
|
||||
exec_state.next_uuid(),
|
||||
exec_state.next_uuid(),
|
||||
];
|
||||
for (id, delta) in ids.iter().copied().zip(deltas) {
|
||||
exec_state
|
||||
.batch_modeling_cmd(
|
||||
ModelingCmdMeta::from_args_id(&args, id),
|
||||
ModelingCmd::from(mcmd::ExtendPath {
|
||||
path: sketch.id.into(),
|
||||
segment: PathSegment::Line {
|
||||
end: KPoint2d::from(untyped_point_to_mm(delta, units))
|
||||
.with_z(0.0)
|
||||
.map(LengthUnit),
|
||||
relative: true,
|
||||
},
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
exec_state
|
||||
.batch_modeling_cmd(
|
||||
ModelingCmdMeta::from_args_id(&args, sketch_id),
|
||||
ModelingCmd::from(mcmd::ClosePath { path_id: sketch.id }),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Update the sketch in KCL memory.
|
||||
let mut new_sketch = sketch.clone();
|
||||
fn add(a: [f64; 2], b: [f64; 2]) -> [f64; 2] {
|
||||
[a[0] + b[0], a[1] + b[1]]
|
||||
}
|
||||
let a = (corner, add(corner, deltas[0]));
|
||||
let b = (a.1, add(a.1, deltas[1]));
|
||||
let c = (b.1, add(b.1, deltas[2]));
|
||||
let d = (c.1, add(c.1, deltas[3]));
|
||||
for (id, (from, to)) in ids.into_iter().zip([a, b, c, d]) {
|
||||
let current_path = Path::ToPoint {
|
||||
base: BasePath {
|
||||
from,
|
||||
to,
|
||||
tag: None,
|
||||
units,
|
||||
geo_meta: GeoMeta {
|
||||
id,
|
||||
metadata: args.source_range.into(),
|
||||
},
|
||||
},
|
||||
};
|
||||
new_sketch.paths.push(current_path);
|
||||
}
|
||||
Ok(new_sketch)
|
||||
}
|
||||
|
||||
/// Sketch a circle.
|
||||
pub async fn circle(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
||||
let sketch_or_surface =
|
||||
|
@ -363,6 +363,9 @@ impl BinaryPart {
|
||||
BinaryPart::MemberExpression(member_expression) => {
|
||||
member_expression.recast(options, indentation_level, ctxt)
|
||||
}
|
||||
BinaryPart::ArrayExpression(e) => e.recast(options, indentation_level, ctxt),
|
||||
BinaryPart::ArrayRangeExpression(e) => e.recast(options, indentation_level, ctxt),
|
||||
BinaryPart::ObjectExpression(e) => e.recast(options, indentation_level, ctxt),
|
||||
BinaryPart::IfExpression(e) => e.recast(options, indentation_level, ExprContext::Other),
|
||||
BinaryPart::AscribedExpression(e) => e.recast(options, indentation_level, ExprContext::Other),
|
||||
}
|
||||
@ -745,6 +748,9 @@ impl UnaryExpression {
|
||||
BinaryPart::Literal(_)
|
||||
| BinaryPart::Name(_)
|
||||
| BinaryPart::MemberExpression(_)
|
||||
| BinaryPart::ArrayExpression(_)
|
||||
| BinaryPart::ArrayRangeExpression(_)
|
||||
| BinaryPart::ObjectExpression(_)
|
||||
| BinaryPart::IfExpression(_)
|
||||
| BinaryPart::AscribedExpression(_)
|
||||
| BinaryPart::CallExpressionKw(_) => {
|
||||
|
@ -220,6 +220,9 @@ impl<'tree> From<&'tree types::BinaryPart> for Node<'tree> {
|
||||
types::BinaryPart::CallExpressionKw(ce) => ce.as_ref().into(),
|
||||
types::BinaryPart::UnaryExpression(ue) => ue.as_ref().into(),
|
||||
types::BinaryPart::MemberExpression(me) => me.as_ref().into(),
|
||||
types::BinaryPart::ArrayExpression(e) => e.as_ref().into(),
|
||||
types::BinaryPart::ArrayRangeExpression(e) => e.as_ref().into(),
|
||||
types::BinaryPart::ObjectExpression(e) => e.as_ref().into(),
|
||||
types::BinaryPart::IfExpression(e) => e.as_ref().into(),
|
||||
types::BinaryPart::AscribedExpression(e) => e.as_ref().into(),
|
||||
}
|
||||
|
@ -234,6 +234,39 @@ export fn startProfile(
|
||||
tag?: TagDecl,
|
||||
): Sketch {}
|
||||
|
||||
/// Sketch a rectangle.
|
||||
///
|
||||
/// ```
|
||||
/// exampleSketch = startSketchOn(-XZ)
|
||||
/// |> rectangle(center = [0, 0], width = 10, height = 5)
|
||||
// |> extrude(length = 2)
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
/// exampleSketch = startSketchOn(-XZ)
|
||||
/// |> rectangle(corner = [0, 0], width = 10, height = 5)
|
||||
// |> extrude(length = 2)
|
||||
/// ```
|
||||
@(impl = std_rust)
|
||||
export fn rectangle(
|
||||
/// Sketch to extend, or plane or surface to sketch on.
|
||||
@sketchOrSurface: Sketch | Plane | Face,
|
||||
/// Rectangle's width along X axis.
|
||||
width: number(Length),
|
||||
/// Rectangle's height along Y axis.
|
||||
height: number(Length),
|
||||
/// The center of the rectangle.
|
||||
/// Incompatible with `corner`.
|
||||
@(snippetArray = ["0", "0"])
|
||||
center?: Point2d,
|
||||
/// The corner of the rectangle.
|
||||
/// Incompatible with `center`.
|
||||
/// This will be the corner which is most negative on
|
||||
/// both X and Y axes.
|
||||
@(snippetArray = ["0", "0"])
|
||||
corner?: Point2d,
|
||||
): Sketch {}
|
||||
|
||||
/// Construct a 2-dimensional circle, of the specified radius, centered at
|
||||
/// the provided (x, y) origin point.
|
||||
///
|
||||
|
18
rust/kcl-lib/tests/add_arrays/artifact_commands.snap
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact commands add_arrays.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/add_arrays/input.kcl": [],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [],
|
||||
"std::prelude": [],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact graph flowchart add_arrays.kcl
|
||||
extension: md
|
||||
snapshot_kind: binary
|
||||
---
|
@ -0,0 +1,3 @@
|
||||
```mermaid
|
||||
flowchart LR
|
||||
```
|
106
rust/kcl-lib/tests/add_arrays/ast.snap
Normal file
@ -0,0 +1,106 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of parsing add_arrays.kcl
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
"body": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "answer",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"left": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "0",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 0.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "1",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 1.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
"moduleId": 0,
|
||||
"operator": "+",
|
||||
"right": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "2",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 2.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
},
|
||||
"start": 0,
|
||||
"type": "BinaryExpression",
|
||||
"type": "BinaryExpression"
|
||||
},
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 0,
|
||||
"kind": "const",
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0
|
||||
}
|
||||
}
|
12
rust/kcl-lib/tests/add_arrays/execution_error.snap
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Error from executing add_arrays.kcl
|
||||
---
|
||||
KCL Semantic error
|
||||
|
||||
× semantic: Expected a number, but found an array of `number`, `number`
|
||||
╭────
|
||||
1 │ answer = [0, 1] + [2]
|
||||
· ───┬──
|
||||
· ╰── tests/add_arrays/input.kcl
|
||||
╰────
|
1
rust/kcl-lib/tests/add_arrays/input.kcl
Normal file
@ -0,0 +1 @@
|
||||
answer = [0, 1] + [2]
|
96
rust/kcl-lib/tests/add_arrays/ops.snap
Normal file
@ -0,0 +1,96 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Operations executed add_arrays.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/add_arrays/input.kcl": [],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "PI",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 3.141592653589793,
|
||||
"ty": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "E",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 2.718281828459045,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "TAU",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 6.283185307179586,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::prelude": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "START",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "start"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "END",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "end"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
5
rust/kcl-lib/tests/add_arrays/unparsed.snap
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of unparsing add_arrays.kcl
|
||||
---
|
||||
answer = [0, 1] + [2]
|
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 24 KiB |
@ -0,0 +1,206 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact commands property_access_not_found_on_solid.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/property_access_not_found_on_solid/input.kcl": [
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "make_plane",
|
||||
"origin": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"x_axis": {
|
||||
"x": 1.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"y_axis": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"size": 60.0,
|
||||
"clobber": false,
|
||||
"hide": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "enable_sketch_mode",
|
||||
"entity_id": "[uuid]",
|
||||
"ortho": false,
|
||||
"animated": false,
|
||||
"adjust_camera": false,
|
||||
"planar_normal": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 1.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "start_path"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "move_path_pen",
|
||||
"path": "[uuid]",
|
||||
"to": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "sketch_mode_disable"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 10.0,
|
||||
"y": 10.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": -20.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 10.0,
|
||||
"y": -10.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "close_path",
|
||||
"path_id": "[uuid]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "enable_sketch_mode",
|
||||
"entity_id": "[uuid]",
|
||||
"ortho": false,
|
||||
"animated": false,
|
||||
"adjust_camera": false,
|
||||
"planar_normal": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 1.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extrude",
|
||||
"target": "[uuid]",
|
||||
"distance": 5.0,
|
||||
"faces": null,
|
||||
"opposite": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "sketch_mode_disable"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "object_bring_to_front",
|
||||
"object_id": "[uuid]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "solid3d_get_extrusion_face_info",
|
||||
"object_id": "[uuid]",
|
||||
"edge_id": "[uuid]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "solid3d_get_adjacency_info",
|
||||
"object_id": "[uuid]",
|
||||
"edge_id": "[uuid]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [],
|
||||
"std::prelude": [],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact graph flowchart property_access_not_found_on_solid.kcl
|
||||
extension: md
|
||||
snapshot_kind: binary
|
||||
---
|
@ -0,0 +1,78 @@
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph path2 [Path]
|
||||
2["Path<br>[52, 77, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 1 }]
|
||||
3["Segment<br>[85, 119, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 2 }]
|
||||
4["Segment<br>[127, 147, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 3 }]
|
||||
5["Segment<br>[155, 176, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 4 }]
|
||||
6["Segment<br>[184, 191, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 5 }]
|
||||
7[Solid2d]
|
||||
end
|
||||
1["Plane<br>[27, 44, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 0 }]
|
||||
8["Sweep Extrusion<br>[199, 235, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, FunctionExpressionBody, FunctionExpressionBodyItem { index: 0 }, ReturnStatementArg, PipeBodyItem { index: 6 }]
|
||||
9[Wall]
|
||||
%% face_code_ref=Missing NodePath
|
||||
10[Wall]
|
||||
%% face_code_ref=Missing NodePath
|
||||
11[Wall]
|
||||
%% face_code_ref=Missing NodePath
|
||||
12["Cap Start"]
|
||||
%% face_code_ref=Missing NodePath
|
||||
13["Cap End"]
|
||||
%% face_code_ref=Missing NodePath
|
||||
14["SweepEdge Opposite"]
|
||||
15["SweepEdge Adjacent"]
|
||||
16["SweepEdge Opposite"]
|
||||
17["SweepEdge Adjacent"]
|
||||
18["SweepEdge Opposite"]
|
||||
19["SweepEdge Adjacent"]
|
||||
1 --- 2
|
||||
2 --- 3
|
||||
2 --- 4
|
||||
2 --- 5
|
||||
2 --- 6
|
||||
2 --- 7
|
||||
2 ---- 8
|
||||
3 --- 9
|
||||
3 x--> 12
|
||||
3 --- 14
|
||||
3 --- 15
|
||||
4 --- 10
|
||||
4 x--> 12
|
||||
4 --- 16
|
||||
4 --- 17
|
||||
5 --- 11
|
||||
5 x--> 12
|
||||
5 --- 18
|
||||
5 --- 19
|
||||
8 --- 9
|
||||
8 --- 10
|
||||
8 --- 11
|
||||
8 --- 12
|
||||
8 --- 13
|
||||
8 --- 14
|
||||
8 --- 15
|
||||
8 --- 16
|
||||
8 --- 17
|
||||
8 --- 18
|
||||
8 --- 19
|
||||
9 --- 14
|
||||
9 --- 15
|
||||
19 <--x 9
|
||||
15 <--x 10
|
||||
10 --- 16
|
||||
10 --- 17
|
||||
17 <--x 11
|
||||
11 --- 18
|
||||
11 --- 19
|
||||
14 <--x 13
|
||||
16 <--x 13
|
||||
18 <--x 13
|
||||
```
|
780
rust/kcl-lib/tests/property_access_not_found_on_solid/ast.snap
Normal file
@ -0,0 +1,780 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of parsing property_access_not_found_on_solid.kcl
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
"body": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "myFunction",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"body": {
|
||||
"body": [
|
||||
{
|
||||
"argument": {
|
||||
"body": [
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "startSketchOn",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "XY",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "at",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "0",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 0.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "0",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 0.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "startProfile",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "end",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "10",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 10.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "10",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 10.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "tag",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "TagDeclarator",
|
||||
"type": "TagDeclarator",
|
||||
"value": "seg01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "line",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "end",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "20",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 20.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
},
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "0",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 0.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "line",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "end",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "10",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 10.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "10",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 10.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "line",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "close",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "length",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "5",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 5.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "tagEnd",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "TagDeclarator",
|
||||
"type": "TagDeclarator",
|
||||
"value": "end01"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "extrude",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ReturnStatement",
|
||||
"type": "ReturnStatement"
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"params": [],
|
||||
"start": 0,
|
||||
"type": "FunctionExpression",
|
||||
"type": "FunctionExpression"
|
||||
},
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 0,
|
||||
"kind": "fn",
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
},
|
||||
{
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "myShape",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "myFunction",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 0,
|
||||
"kind": "const",
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
},
|
||||
{
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "sketch001",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "face",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"computed": false,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"object": {
|
||||
"commentStart": 0,
|
||||
"computed": false,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"object": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "myShape",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
},
|
||||
"property": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "tags",
|
||||
"start": 0,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 0,
|
||||
"type": "MemberExpression",
|
||||
"type": "MemberExpression"
|
||||
},
|
||||
"property": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "seg01",
|
||||
"start": 0,
|
||||
"type": "Identifier",
|
||||
"type": "Identifier"
|
||||
},
|
||||
"start": 0,
|
||||
"type": "MemberExpression",
|
||||
"type": "MemberExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "startSketchOn",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "myShape",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 0,
|
||||
"kind": "const",
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"nonCodeMeta": {
|
||||
"nonCodeNodes": {
|
||||
"0": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLine"
|
||||
}
|
||||
}
|
||||
],
|
||||
"1": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLine"
|
||||
}
|
||||
}
|
||||
],
|
||||
"2": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "NonCodeNode",
|
||||
"value": {
|
||||
"type": "newLine"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"startNodes": []
|
||||
},
|
||||
"start": 0
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Error from executing property_access_not_found_on_solid.kcl
|
||||
---
|
||||
KCL Semantic error
|
||||
|
||||
× semantic: Property `tags` not found on a solid. You can get a solid's tags
|
||||
│ through its sketch, as in, `exampleSolid.sketch.tags`.
|
||||
╭─[13:43]
|
||||
12 │
|
||||
13 │ sketch001 = startSketchOn(myShape, face = myShape.tags.seg01)
|
||||
· ──────┬─────
|
||||
· ╰── tests/property_access_not_found_on_solid/input.kcl
|
||||
14 │
|
||||
╰────
|
@ -0,0 +1,14 @@
|
||||
fn myFunction() {
|
||||
return startSketchOn(XY)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(end = [10, 10], tag = $seg01)
|
||||
|> line(end = [-20, 0])
|
||||
|> line(end = [10, -10])
|
||||
|> close()
|
||||
|> extrude(length = 5, tagEnd = $end01)
|
||||
}
|
||||
|
||||
myShape = myFunction()
|
||||
|
||||
sketch001 = startSketchOn(myShape, face = myShape.tags.seg01)
|
||||
|
233
rust/kcl-lib/tests/property_access_not_found_on_solid/ops.snap
Normal file
@ -0,0 +1,233 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Operations executed property_access_not_found_on_solid.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/property_access_not_found_on_solid/input.kcl": [
|
||||
{
|
||||
"type": "GroupBegin",
|
||||
"group": {
|
||||
"type": "FunctionCall",
|
||||
"name": "myFunction",
|
||||
"functionSourceRange": [],
|
||||
"unlabeledArg": null,
|
||||
"labeledArgs": {}
|
||||
},
|
||||
"nodePath": {
|
||||
"steps": [
|
||||
{
|
||||
"type": "ProgramBodyItem",
|
||||
"index": 1
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationDeclaration"
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationInit"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "StdLibCall",
|
||||
"name": "startSketchOn",
|
||||
"unlabeledArg": {
|
||||
"value": {
|
||||
"type": "Plane",
|
||||
"artifact_id": "[uuid]"
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
"labeledArgs": {},
|
||||
"nodePath": {
|
||||
"steps": [
|
||||
{
|
||||
"type": "ProgramBodyItem",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationDeclaration"
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationInit"
|
||||
},
|
||||
{
|
||||
"type": "FunctionExpressionBody"
|
||||
},
|
||||
{
|
||||
"type": "FunctionExpressionBodyItem",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"type": "ReturnStatementArg"
|
||||
},
|
||||
{
|
||||
"type": "PipeBodyItem",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "StdLibCall",
|
||||
"name": "extrude",
|
||||
"unlabeledArg": {
|
||||
"value": {
|
||||
"type": "Sketch",
|
||||
"value": {
|
||||
"artifactId": "[uuid]"
|
||||
}
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
"labeledArgs": {
|
||||
"length": {
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 5.0,
|
||||
"ty": {
|
||||
"type": "Default",
|
||||
"len": {
|
||||
"type": "Mm"
|
||||
},
|
||||
"angle": {
|
||||
"type": "Degrees"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
"tagEnd": {
|
||||
"value": {
|
||||
"type": "TagDeclarator",
|
||||
"name": "end01"
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
},
|
||||
"nodePath": {
|
||||
"steps": [
|
||||
{
|
||||
"type": "ProgramBodyItem",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationDeclaration"
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationInit"
|
||||
},
|
||||
{
|
||||
"type": "FunctionExpressionBody"
|
||||
},
|
||||
{
|
||||
"type": "FunctionExpressionBodyItem",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"type": "ReturnStatementArg"
|
||||
},
|
||||
{
|
||||
"type": "PipeBodyItem",
|
||||
"index": 6
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "GroupEnd"
|
||||
}
|
||||
],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "PI",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 3.141592653589793,
|
||||
"ty": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "E",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 2.718281828459045,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "TAU",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 6.283185307179586,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::prelude": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "START",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "start"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "END",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "end"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of unparsing property_access_not_found_on_solid.kcl
|
||||
---
|
||||
fn myFunction() {
|
||||
return startSketchOn(XY)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line(end = [10, 10], tag = $seg01)
|
||||
|> line(end = [-20, 0])
|
||||
|> line(end = [10, -10])
|
||||
|> close()
|
||||
|> extrude(length = 5, tagEnd = $end01)
|
||||
}
|
||||
|
||||
myShape = myFunction()
|
||||
|
||||
sketch001 = startSketchOn(myShape, face = myShape.tags.seg01)
|
163
rust/kcl-lib/tests/rect/artifact_commands.snap
Normal file
@ -0,0 +1,163 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact commands rect.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/rect/input.kcl": [
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "make_plane",
|
||||
"origin": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"x_axis": {
|
||||
"x": 1.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"y_axis": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"size": 60.0,
|
||||
"clobber": false,
|
||||
"hide": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "enable_sketch_mode",
|
||||
"entity_id": "[uuid]",
|
||||
"ortho": false,
|
||||
"animated": false,
|
||||
"adjust_camera": false,
|
||||
"planar_normal": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 1.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "start_path"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "move_path_pen",
|
||||
"path": "[uuid]",
|
||||
"to": {
|
||||
"x": -2.0,
|
||||
"y": -1.0,
|
||||
"z": 0.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "sketch_mode_disable"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 3.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 0.00000000000000012246467991473532,
|
||||
"y": 2.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": -3.0,
|
||||
"y": -0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": -2.0,
|
||||
"y": -1.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "close_path",
|
||||
"path_id": "[uuid]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [],
|
||||
"std::prelude": [],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
6
rust/kcl-lib/tests/rect/artifact_graph_flowchart.snap
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact graph flowchart rect.kcl
|
||||
extension: md
|
||||
snapshot_kind: binary
|
||||
---
|
27
rust/kcl-lib/tests/rect/artifact_graph_flowchart.snap.md
Normal file
@ -0,0 +1,27 @@
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph path2 [Path]
|
||||
2["Path<br>[27, 54, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }]
|
||||
3["Segment<br>[60, 103, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 2 }]
|
||||
4["Segment<br>[109, 155, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 3 }]
|
||||
5["Segment<br>[161, 211, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 4 }]
|
||||
6["Segment<br>[217, 273, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 5 }]
|
||||
7["Segment<br>[279, 286, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 6 }]
|
||||
8[Solid2d]
|
||||
end
|
||||
1["Plane<br>[4, 21, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 0 }]
|
||||
1 --- 2
|
||||
2 --- 3
|
||||
2 --- 4
|
||||
2 --- 5
|
||||
2 --- 6
|
||||
2 --- 7
|
||||
2 --- 8
|
||||
```
|
701
rust/kcl-lib/tests/rect/ast.snap
Normal file
@ -0,0 +1,701 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of parsing rect.kcl
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
"body": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "x",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"body": [
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "startSketchOn",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "XY",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "at",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "2",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 2.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
},
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "1",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 1.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "startProfile",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "angle",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "0",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 0.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "length",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "3",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 3.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "tag",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "TagDeclarator",
|
||||
"type": "TagDeclarator",
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "angledLine",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "angle",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"left": {
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "segAng",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "a",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
"moduleId": 0,
|
||||
"operator": "+",
|
||||
"right": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "90",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 90.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"start": 0,
|
||||
"type": "BinaryExpression",
|
||||
"type": "BinaryExpression"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "length",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "2",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 2.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "angledLine",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "angle",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "segAng",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "a",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "length",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"argument": {
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "segLen",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "a",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "angledLine",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "endAbsolute",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "profileStartX",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
},
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "profileStartY",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "PipeSubstitution",
|
||||
"type": "PipeSubstitution"
|
||||
}
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "line",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
},
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "close",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
},
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 0,
|
||||
"kind": "const",
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0
|
||||
}
|
||||
}
|
7
rust/kcl-lib/tests/rect/input.kcl
Normal file
@ -0,0 +1,7 @@
|
||||
x = startSketchOn(XY)
|
||||
|> startProfile(at = [-2, -1])
|
||||
|> angledLine(angle = 0, length = 3, tag = $a)
|
||||
|> angledLine(angle = segAng(a) + 90, length = 2)
|
||||
|> angledLine(angle = segAng(a), length = -segLen(a))
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
128
rust/kcl-lib/tests/rect/ops.snap
Normal file
@ -0,0 +1,128 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Operations executed rect.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/rect/input.kcl": [
|
||||
{
|
||||
"type": "StdLibCall",
|
||||
"name": "startSketchOn",
|
||||
"unlabeledArg": {
|
||||
"value": {
|
||||
"type": "Plane",
|
||||
"artifact_id": "[uuid]"
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
"labeledArgs": {},
|
||||
"nodePath": {
|
||||
"steps": [
|
||||
{
|
||||
"type": "ProgramBodyItem",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationDeclaration"
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationInit"
|
||||
},
|
||||
{
|
||||
"type": "PipeBodyItem",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "PI",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 3.141592653589793,
|
||||
"ty": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "E",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 2.718281828459045,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "TAU",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 6.283185307179586,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::prelude": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "START",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "start"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "END",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "end"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
181
rust/kcl-lib/tests/rect/program_memory.snap
Normal file
@ -0,0 +1,181 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Variables in memory after executing rect.kcl
|
||||
---
|
||||
{
|
||||
"a": {
|
||||
"type": "TagIdentifier",
|
||||
"type": "TagIdentifier",
|
||||
"value": "a"
|
||||
},
|
||||
"x": {
|
||||
"type": "Sketch",
|
||||
"value": {
|
||||
"type": "Sketch",
|
||||
"id": "[uuid]",
|
||||
"paths": [
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"tag": {
|
||||
"commentStart": 100,
|
||||
"end": 102,
|
||||
"moduleId": 0,
|
||||
"start": 100,
|
||||
"type": "TagDeclarator",
|
||||
"value": "a"
|
||||
},
|
||||
"to": [
|
||||
1.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
1.0,
|
||||
-1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
1.0000000000000002,
|
||||
1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
1.0000000000000002,
|
||||
1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
-1.9999999999999998,
|
||||
1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
-1.9999999999999998,
|
||||
1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
}
|
||||
],
|
||||
"on": {
|
||||
"artifactId": "[uuid]",
|
||||
"id": "[uuid]",
|
||||
"origin": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
"type": "plane",
|
||||
"value": "XY",
|
||||
"xAxis": {
|
||||
"x": 1.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"units": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
},
|
||||
"yAxis": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
"z": 0.0,
|
||||
"units": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
}
|
||||
},
|
||||
"start": {
|
||||
"from": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"to": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
},
|
||||
"tag": null,
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
}
|
||||
},
|
||||
"tags": {
|
||||
"a": {
|
||||
"type": "TagIdentifier",
|
||||
"value": "a"
|
||||
}
|
||||
},
|
||||
"artifactId": "[uuid]",
|
||||
"originalId": "[uuid]",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
rust/kcl-lib/tests/rect/rendered_model.png
Normal file
After Width: | Height: | Size: 26 KiB |
11
rust/kcl-lib/tests/rect/unparsed.snap
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of unparsing rect.kcl
|
||||
---
|
||||
x = startSketchOn(XY)
|
||||
|> startProfile(at = [-2, -1])
|
||||
|> angledLine(angle = 0, length = 3, tag = $a)
|
||||
|> angledLine(angle = segAng(a) + 90, length = 2)
|
||||
|> angledLine(angle = segAng(a), length = -segLen(a))
|
||||
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
|> close()
|
163
rust/kcl-lib/tests/rect_helper/artifact_commands.snap
Normal file
@ -0,0 +1,163 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact commands rect_helper.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/rect_helper/input.kcl": [
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "make_plane",
|
||||
"origin": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"x_axis": {
|
||||
"x": 1.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"y_axis": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"size": 60.0,
|
||||
"clobber": false,
|
||||
"hide": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "enable_sketch_mode",
|
||||
"entity_id": "[uuid]",
|
||||
"ortho": false,
|
||||
"animated": false,
|
||||
"adjust_camera": false,
|
||||
"planar_normal": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 1.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "start_path"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "move_path_pen",
|
||||
"path": "[uuid]",
|
||||
"to": {
|
||||
"x": -2.0,
|
||||
"y": -1.0,
|
||||
"z": 0.0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "sketch_mode_disable"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 3.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 0.0,
|
||||
"y": 2.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": -3.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "extend_path",
|
||||
"path": "[uuid]",
|
||||
"segment": {
|
||||
"type": "line",
|
||||
"end": {
|
||||
"x": 0.0,
|
||||
"y": -2.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"relative": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cmdId": "[uuid]",
|
||||
"range": [],
|
||||
"command": {
|
||||
"type": "close_path",
|
||||
"path_id": "[uuid]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [],
|
||||
"std::prelude": [],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Artifact graph flowchart rect_helper.kcl
|
||||
extension: md
|
||||
snapshot_kind: binary
|
||||
---
|
@ -0,0 +1,24 @@
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph path2 [Path]
|
||||
2["Path<br>[25, 76, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }]
|
||||
3["Segment<br>[25, 76, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }]
|
||||
4["Segment<br>[25, 76, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }]
|
||||
5["Segment<br>[25, 76, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }]
|
||||
6["Segment<br>[25, 76, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }]
|
||||
7[Solid2d]
|
||||
end
|
||||
1["Plane<br>[4, 21, 0]"]
|
||||
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 0 }]
|
||||
1 --- 2
|
||||
2 --- 3
|
||||
2 --- 4
|
||||
2 --- 5
|
||||
2 --- 6
|
||||
2 --- 7
|
||||
```
|
233
rust/kcl-lib/tests/rect_helper/ast.snap
Normal file
@ -0,0 +1,233 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of parsing rect_helper.kcl
|
||||
---
|
||||
{
|
||||
"Ok": {
|
||||
"body": [
|
||||
{
|
||||
"commentStart": 0,
|
||||
"declaration": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"id": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "x",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"init": {
|
||||
"body": [
|
||||
{
|
||||
"arguments": [],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "startSketchOn",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "XY",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name",
|
||||
"type": "Name"
|
||||
}
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "width",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "3",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 3.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "height",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "2",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 2.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "LabeledArg",
|
||||
"label": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "corner",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"arg": {
|
||||
"commentStart": 0,
|
||||
"elements": [
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "2",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 2.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
},
|
||||
{
|
||||
"argument": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"raw": "1",
|
||||
"start": 0,
|
||||
"type": "Literal",
|
||||
"type": "Literal",
|
||||
"value": {
|
||||
"value": 1.0,
|
||||
"suffix": "None"
|
||||
}
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"operator": "-",
|
||||
"start": 0,
|
||||
"type": "UnaryExpression",
|
||||
"type": "UnaryExpression"
|
||||
}
|
||||
],
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "ArrayExpression",
|
||||
"type": "ArrayExpression"
|
||||
}
|
||||
}
|
||||
],
|
||||
"callee": {
|
||||
"abs_path": false,
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": {
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"name": "rectangle",
|
||||
"start": 0,
|
||||
"type": "Identifier"
|
||||
},
|
||||
"path": [],
|
||||
"start": 0,
|
||||
"type": "Name"
|
||||
},
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "CallExpressionKw",
|
||||
"type": "CallExpressionKw",
|
||||
"unlabeled": null
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "PipeExpression",
|
||||
"type": "PipeExpression"
|
||||
},
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclarator"
|
||||
},
|
||||
"end": 0,
|
||||
"kind": "const",
|
||||
"moduleId": 0,
|
||||
"start": 0,
|
||||
"type": "VariableDeclaration",
|
||||
"type": "VariableDeclaration"
|
||||
}
|
||||
],
|
||||
"commentStart": 0,
|
||||
"end": 0,
|
||||
"moduleId": 0,
|
||||
"start": 0
|
||||
}
|
||||
}
|
2
rust/kcl-lib/tests/rect_helper/input.kcl
Normal file
@ -0,0 +1,2 @@
|
||||
x = startSketchOn(XY)
|
||||
|> rectangle(width = 3, height = 2, corner = [-2, -1])
|
128
rust/kcl-lib/tests/rect_helper/ops.snap
Normal file
@ -0,0 +1,128 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Operations executed rect_helper.kcl
|
||||
---
|
||||
{
|
||||
"rust/kcl-lib/tests/rect_helper/input.kcl": [
|
||||
{
|
||||
"type": "StdLibCall",
|
||||
"name": "startSketchOn",
|
||||
"unlabeledArg": {
|
||||
"value": {
|
||||
"type": "Plane",
|
||||
"artifact_id": "[uuid]"
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
"labeledArgs": {},
|
||||
"nodePath": {
|
||||
"steps": [
|
||||
{
|
||||
"type": "ProgramBodyItem",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationDeclaration"
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclarationInit"
|
||||
},
|
||||
{
|
||||
"type": "PipeBodyItem",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::appearance": [],
|
||||
"std::array": [],
|
||||
"std::math": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "PI",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 3.141592653589793,
|
||||
"ty": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "E",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 2.718281828459045,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "TAU",
|
||||
"value": {
|
||||
"type": "Number",
|
||||
"value": 6.283185307179586,
|
||||
"ty": {
|
||||
"type": "Known",
|
||||
"type": "Count"
|
||||
}
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::prelude": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "START",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "start"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
},
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"name": "END",
|
||||
"value": {
|
||||
"type": "String",
|
||||
"value": "end"
|
||||
},
|
||||
"visibility": "export",
|
||||
"nodePath": {
|
||||
"steps": []
|
||||
},
|
||||
"sourceRange": []
|
||||
}
|
||||
],
|
||||
"std::sketch": [],
|
||||
"std::solid": [],
|
||||
"std::sweep": [],
|
||||
"std::transform": [],
|
||||
"std::turns": [],
|
||||
"std::types": [],
|
||||
"std::units": []
|
||||
}
|
144
rust/kcl-lib/tests/rect_helper/program_memory.snap
Normal file
@ -0,0 +1,144 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Variables in memory after executing rect_helper.kcl
|
||||
---
|
||||
{
|
||||
"x": {
|
||||
"type": "Sketch",
|
||||
"value": {
|
||||
"type": "Sketch",
|
||||
"id": "[uuid]",
|
||||
"paths": [
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
1.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
1.0,
|
||||
-1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
-2.0,
|
||||
1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
},
|
||||
"from": [
|
||||
-2.0,
|
||||
1.0
|
||||
],
|
||||
"tag": null,
|
||||
"to": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "ToPoint",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
}
|
||||
],
|
||||
"on": {
|
||||
"artifactId": "[uuid]",
|
||||
"id": "[uuid]",
|
||||
"origin": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
},
|
||||
"type": "plane",
|
||||
"value": "XY",
|
||||
"xAxis": {
|
||||
"x": 1.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0,
|
||||
"units": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
},
|
||||
"yAxis": {
|
||||
"x": 0.0,
|
||||
"y": 1.0,
|
||||
"z": 0.0,
|
||||
"units": {
|
||||
"type": "Unknown"
|
||||
}
|
||||
}
|
||||
},
|
||||
"start": {
|
||||
"from": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"to": [
|
||||
-2.0,
|
||||
-1.0
|
||||
],
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
},
|
||||
"tag": null,
|
||||
"__geoMeta": {
|
||||
"id": "[uuid]",
|
||||
"sourceRange": []
|
||||
}
|
||||
},
|
||||
"artifactId": "[uuid]",
|
||||
"originalId": "[uuid]",
|
||||
"units": {
|
||||
"type": "Mm"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
rust/kcl-lib/tests/rect_helper/rendered_model.png
Normal file
After Width: | Height: | Size: 26 KiB |
6
rust/kcl-lib/tests/rect_helper/unparsed.snap
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
source: kcl-lib/src/simulation_tests.rs
|
||||
description: Result of unparsing rect_helper.kcl
|
||||
---
|
||||
x = startSketchOn(XY)
|
||||
|> rectangle(width = 3, height = 2, corner = [-2, -1])
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "kcl-python-bindings"
|
||||
version = "0.3.83"
|
||||
version = "0.3.84"
|
||||
edition = "2021"
|
||||
repository = "https://github.com/kittycad/modeling-app"
|
||||
exclude = ["tests/*", "files/*", "venv/*"]
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-test-server"
|
||||
description = "A test server for KCL"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "kcl-to-core"
|
||||
description = "Utility methods to convert kcl to engine core executable tests"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "kcl-wasm-lib"
|
||||
version = "0.1.83"
|
||||
version = "0.1.84"
|
||||
edition = "2021"
|
||||
repository = "https://github.com/KittyCAD/modeling-app"
|
||||
rust-version = "1.83"
|
||||
|
@ -324,6 +324,8 @@ export class SceneEntities {
|
||||
group: segment,
|
||||
scale: factor,
|
||||
sceneInfra: this.sceneInfra,
|
||||
// Note: AST and code not available in onCamChange, so constraints won't be checked here
|
||||
// This is primarily for scaling changes
|
||||
})
|
||||
callBack && !err(callBack) && callbacks.push(callBack)
|
||||
if (segment.name === PROFILE_START) {
|
||||
@ -729,6 +731,8 @@ export class SceneEntities {
|
||||
scale,
|
||||
theme: this.sceneInfra._theme,
|
||||
isDraft: false,
|
||||
ast: maybeModdedAst,
|
||||
code: this.codeManager.code,
|
||||
})
|
||||
_profileStart.layers.set(SKETCH_LAYER)
|
||||
_profileStart.traverse((child) => {
|
||||
@ -866,6 +870,8 @@ export class SceneEntities {
|
||||
isSelected,
|
||||
sceneInfra: this.sceneInfra,
|
||||
selection,
|
||||
ast: maybeModdedAst,
|
||||
code: this.codeManager.code,
|
||||
})
|
||||
if (err(result)) return
|
||||
const { group: _group, updateOverlaysCallback } = result
|
||||
@ -3252,6 +3258,8 @@ export class SceneEntities {
|
||||
scale: factor,
|
||||
prevSegment: sgPaths[index - 1],
|
||||
sceneInfra: this.sceneInfra,
|
||||
ast: modifiedAst,
|
||||
code: this.codeManager.code,
|
||||
})
|
||||
if (callBack && !err(callBack)) return callBack
|
||||
|
||||
|
@ -76,12 +76,17 @@ import {
|
||||
} from '@src/clientSideScene/sceneUtils'
|
||||
import { angleLengthInfo } from '@src/components/Toolbar/angleLengthInfo'
|
||||
import type { Coords2d } from '@src/lang/std/sketch'
|
||||
import { getConstraintInfoKw } from '@src/lang/std/sketch'
|
||||
import type { SegmentInputs } from '@src/lang/std/stdTypes'
|
||||
import type { PathToNode } from '@src/lang/wasm'
|
||||
import type { PathToNode, Program } from '@src/lang/wasm'
|
||||
import { getTangentialArcToInfo } from '@src/lang/wasm'
|
||||
import { getNodeFromPath } from '@src/lang/queryAst'
|
||||
import type { Selections } from '@src/lib/selections'
|
||||
import type { Themes } from '@src/lib/theme'
|
||||
import { getThemeColorForThreeJs } from '@src/lib/theme'
|
||||
import {
|
||||
getThemeColorForThreeJs,
|
||||
getPrimaryColorForThreeJs,
|
||||
} from '@src/lib/theme'
|
||||
import { err } from '@src/lib/trap'
|
||||
import { isClockwise, normaliseAngle, roundOff } from '@src/lib/utils'
|
||||
import { getTangentPointFromPreviousArc } from '@src/lib/utils2d'
|
||||
@ -95,6 +100,7 @@ import toast from 'react-hot-toast'
|
||||
import { ARG_INTERIOR_ABSOLUTE } from '@src/lang/constants'
|
||||
|
||||
const ANGLE_INDICATOR_RADIUS = 30 // in px
|
||||
|
||||
interface CreateSegmentArgs {
|
||||
input: SegmentInputs
|
||||
prevSegment: Sketch['paths'][number]
|
||||
@ -108,6 +114,9 @@ interface CreateSegmentArgs {
|
||||
isSelected?: boolean
|
||||
sceneInfra: SceneInfra
|
||||
selection?: Selections
|
||||
// Add optional AST and code for constraint checking
|
||||
ast?: Program
|
||||
code?: string
|
||||
}
|
||||
|
||||
interface UpdateSegmentArgs {
|
||||
@ -116,6 +125,9 @@ interface UpdateSegmentArgs {
|
||||
group: Group
|
||||
sceneInfra: SceneInfra
|
||||
scale?: number
|
||||
// Add optional AST and code for constraint checking
|
||||
ast?: Program
|
||||
code?: string
|
||||
}
|
||||
|
||||
interface CreateSegmentResult {
|
||||
@ -144,6 +156,55 @@ export interface SegmentUtils {
|
||||
) => CreateSegmentResult['updateOverlaysCallback'] | Error
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a segment is fully constrained by examining all its constraint info
|
||||
*/
|
||||
function isSegmentFullyConstrained(
|
||||
pathToNode: PathToNode,
|
||||
ast: Program,
|
||||
code: string
|
||||
): boolean {
|
||||
try {
|
||||
const nodeMeta = getNodeFromPath<any>(ast, pathToNode)
|
||||
if (err(nodeMeta) || nodeMeta.node.type !== 'CallExpressionKw') {
|
||||
return false
|
||||
}
|
||||
|
||||
const constraintInfos = getConstraintInfoKw(nodeMeta.node, code, pathToNode)
|
||||
|
||||
// If there are no constraints, consider it not fully constrained
|
||||
if (constraintInfos.length === 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if all constraints are constrained
|
||||
return constraintInfos.every((info) => info.isConstrained)
|
||||
} catch (error) {
|
||||
console.warn('Error checking segment constraints:', error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the appropriate color for a segment based on selection, constraints, and theme
|
||||
*/
|
||||
function getSegmentColor({
|
||||
theme,
|
||||
isSelected,
|
||||
callExpName = '',
|
||||
isFullyConstrained = false,
|
||||
}: {
|
||||
theme: Themes
|
||||
isSelected: boolean
|
||||
callExpName?: string
|
||||
isFullyConstrained: boolean
|
||||
}): number {
|
||||
if (isSelected) return 0x0000ff // Blue for selected
|
||||
if (callExpName === 'close') return 0x444444 // Gray for close segments
|
||||
if (!isFullyConstrained) return getPrimaryColorForThreeJs() // Primary color for unconstrained segments
|
||||
return getThemeColorForThreeJs(theme) // Default theme color for constrained segments
|
||||
}
|
||||
|
||||
class StraightSegment implements SegmentUtils {
|
||||
init: SegmentUtils['init'] = ({
|
||||
input,
|
||||
@ -158,13 +219,32 @@ class StraightSegment implements SegmentUtils {
|
||||
sceneInfra,
|
||||
prevSegment,
|
||||
selection,
|
||||
ast,
|
||||
code,
|
||||
}) => {
|
||||
if (input.type !== 'straight-segment')
|
||||
return new Error('Invalid segment type')
|
||||
const { from, to } = input
|
||||
const baseColor =
|
||||
callExpName === 'close' ? 0x444444 : getThemeColorForThreeJs(theme)
|
||||
const color = isSelected ? 0x0000ff : baseColor
|
||||
|
||||
// Check if segment is fully constrained (only if we have AST and code)
|
||||
const isFullyConstrained =
|
||||
callExpName === 'close'
|
||||
? true
|
||||
: ast && code
|
||||
? isSegmentFullyConstrained(pathToNode, ast, code)
|
||||
: false
|
||||
|
||||
const color = getSegmentColor({
|
||||
theme,
|
||||
isSelected: !!isSelected,
|
||||
callExpName,
|
||||
isFullyConstrained,
|
||||
})
|
||||
const baseColor = !isFullyConstrained
|
||||
? getPrimaryColorForThreeJs()
|
||||
: callExpName === 'close'
|
||||
? 0x444444
|
||||
: getThemeColorForThreeJs(theme)
|
||||
const meshType = isDraftSegment
|
||||
? STRAIGHT_SEGMENT_DASH
|
||||
: STRAIGHT_SEGMENT_BODY
|
||||
@ -250,12 +330,40 @@ class StraightSegment implements SegmentUtils {
|
||||
group,
|
||||
scale = 1,
|
||||
sceneInfra,
|
||||
ast,
|
||||
code,
|
||||
}) => {
|
||||
if (input.type !== 'straight-segment')
|
||||
return new Error('Invalid segment type')
|
||||
const { from, to } = input
|
||||
group.userData.from = from
|
||||
group.userData.to = to
|
||||
|
||||
// Check if segment is fully constrained and update color if needed
|
||||
if (ast && code) {
|
||||
const pathToNode = group.userData.pathToNode
|
||||
const isFullyConstrained =
|
||||
group.userData.callExpName === 'close'
|
||||
? true
|
||||
: isSegmentFullyConstrained(pathToNode, ast, code)
|
||||
const color = getSegmentColor({
|
||||
theme: sceneInfra._theme,
|
||||
isSelected: group.userData.isSelected,
|
||||
callExpName: group.userData.callExpName,
|
||||
isFullyConstrained,
|
||||
})
|
||||
|
||||
// Update the material color
|
||||
const straightSegmentBody = group.children.find(
|
||||
(child) => child.userData.type === STRAIGHT_SEGMENT_BODY
|
||||
) as Mesh
|
||||
if (
|
||||
straightSegmentBody &&
|
||||
straightSegmentBody.material instanceof MeshBasicMaterial
|
||||
) {
|
||||
straightSegmentBody.material.color.set(color)
|
||||
}
|
||||
}
|
||||
const shape = createLineShape(scale)
|
||||
const arrowGroup = group.getObjectByName(ARROWHEAD) as Group
|
||||
const labelGroup = group.getObjectByName(SEGMENT_LENGTH_LABEL) as Group
|
||||
@ -391,6 +499,8 @@ class TangentialArcToSegment implements SegmentUtils {
|
||||
theme,
|
||||
isSelected,
|
||||
sceneInfra,
|
||||
ast,
|
||||
code,
|
||||
}) => {
|
||||
if (input.type !== 'straight-segment')
|
||||
return new Error('Invalid segment type')
|
||||
@ -409,8 +519,19 @@ class TangentialArcToSegment implements SegmentUtils {
|
||||
isDashed: isDraftSegment,
|
||||
scale,
|
||||
})
|
||||
const baseColor = getThemeColorForThreeJs(theme)
|
||||
const color = isSelected ? 0x0000ff : baseColor
|
||||
|
||||
// Check if segment is fully constrained (only if we have AST and code)
|
||||
const isFullyConstrained =
|
||||
ast && code ? isSegmentFullyConstrained(pathToNode, ast, code) : false
|
||||
|
||||
const color = getSegmentColor({
|
||||
theme,
|
||||
isSelected: !!isSelected,
|
||||
isFullyConstrained,
|
||||
})
|
||||
const baseColor = !isFullyConstrained
|
||||
? getPrimaryColorForThreeJs()
|
||||
: getThemeColorForThreeJs(theme)
|
||||
const body = new MeshBasicMaterial({ color })
|
||||
const mesh = new Mesh(geometry, body)
|
||||
const arrowGroup = createArrowhead(scale, theme, color)
|
||||
@ -453,6 +574,8 @@ class TangentialArcToSegment implements SegmentUtils {
|
||||
group,
|
||||
scale = 1,
|
||||
sceneInfra,
|
||||
ast,
|
||||
code,
|
||||
}) => {
|
||||
if (input.type !== 'straight-segment')
|
||||
return new Error('Invalid segment type')
|
||||
@ -460,6 +583,32 @@ class TangentialArcToSegment implements SegmentUtils {
|
||||
group.userData.from = from
|
||||
group.userData.to = to
|
||||
group.userData.prevSegment = prevSegment
|
||||
|
||||
// Check if segment is fully constrained and update color if needed
|
||||
if (ast && code) {
|
||||
const pathToNode = group.userData.pathToNode
|
||||
const isFullyConstrained = isSegmentFullyConstrained(
|
||||
pathToNode,
|
||||
ast,
|
||||
code
|
||||
)
|
||||
const color = getSegmentColor({
|
||||
theme: sceneInfra._theme,
|
||||
isSelected: group.userData.isSelected,
|
||||
isFullyConstrained,
|
||||
})
|
||||
|
||||
// Update the material color
|
||||
const tangentialArcSegmentBody = group.children.find(
|
||||
(child) => child.userData.type === TANGENTIAL_ARC_TO_SEGMENT_BODY
|
||||
) as Mesh
|
||||
if (
|
||||
tangentialArcSegmentBody &&
|
||||
tangentialArcSegmentBody.material instanceof MeshBasicMaterial
|
||||
) {
|
||||
tangentialArcSegmentBody.material.color.set(color)
|
||||
}
|
||||
}
|
||||
const arrowGroup = group.getObjectByName(ARROWHEAD) as Group
|
||||
const extraSegmentGroup = group.getObjectByName(EXTRA_SEGMENT_HANDLE)
|
||||
|
||||
@ -588,13 +737,26 @@ class CircleSegment implements SegmentUtils {
|
||||
theme,
|
||||
isSelected,
|
||||
sceneInfra,
|
||||
ast,
|
||||
code,
|
||||
}) => {
|
||||
if (input.type !== 'arc-segment') {
|
||||
return new Error('Invalid segment type')
|
||||
}
|
||||
const { from, center, radius } = input
|
||||
const baseColor = getThemeColorForThreeJs(theme)
|
||||
const color = isSelected ? 0x0000ff : baseColor
|
||||
|
||||
// Check if segment is fully constrained
|
||||
const isFullyConstrained =
|
||||
ast && code ? isSegmentFullyConstrained(pathToNode, ast, code) : false
|
||||
|
||||
const color = getSegmentColor({
|
||||
theme,
|
||||
isSelected: !!isSelected,
|
||||
isFullyConstrained,
|
||||
})
|
||||
const baseColor = !isFullyConstrained
|
||||
? getPrimaryColorForThreeJs()
|
||||
: getThemeColorForThreeJs(theme)
|
||||
|
||||
const group = new Group()
|
||||
const geometry = createArcGeometry({
|
||||
@ -678,6 +840,8 @@ class CircleSegment implements SegmentUtils {
|
||||
group,
|
||||
scale = 1,
|
||||
sceneInfra,
|
||||
ast,
|
||||
code,
|
||||
}) => {
|
||||
if (input.type !== 'arc-segment') {
|
||||
return new Error('Invalid segment type')
|
||||
@ -687,6 +851,32 @@ class CircleSegment implements SegmentUtils {
|
||||
group.userData.center = center
|
||||
group.userData.radius = radius
|
||||
group.userData.prevSegment = prevSegment
|
||||
|
||||
// Check if segment is fully constrained and update color if needed
|
||||
if (ast && code) {
|
||||
const pathToNode = group.userData.pathToNode
|
||||
const isFullyConstrained = isSegmentFullyConstrained(
|
||||
pathToNode,
|
||||
ast,
|
||||
code
|
||||
)
|
||||
const color = getSegmentColor({
|
||||
theme: sceneInfra._theme,
|
||||
isSelected: group.userData.isSelected,
|
||||
isFullyConstrained,
|
||||
})
|
||||
|
||||
// Update the material color
|
||||
const circleSegmentBody = group.children.find(
|
||||
(child) => child.userData.type === CIRCLE_SEGMENT_BODY
|
||||
) as Mesh
|
||||
if (
|
||||
circleSegmentBody &&
|
||||
circleSegmentBody.material instanceof MeshBasicMaterial
|
||||
) {
|
||||
circleSegmentBody.material.color.set(color)
|
||||
}
|
||||
}
|
||||
const arrowGroup = group.getObjectByName(ARROWHEAD) as Group
|
||||
const radiusLengthIndicator = group.getObjectByName(
|
||||
SEGMENT_LENGTH_LABEL
|
||||
@ -831,6 +1021,8 @@ class CircleThreePointSegment implements SegmentUtils {
|
||||
isSelected = false,
|
||||
sceneInfra,
|
||||
prevSegment,
|
||||
ast,
|
||||
code,
|
||||
}) => {
|
||||
if (input.type !== 'circle-three-point-segment') {
|
||||
return new Error('Invalid segment type')
|
||||
@ -845,8 +1037,19 @@ class CircleThreePointSegment implements SegmentUtils {
|
||||
p3[1]
|
||||
)
|
||||
const center: [number, number] = [center_x, center_y]
|
||||
const baseColor = getThemeColorForThreeJs(theme)
|
||||
const color = isSelected ? 0x0000ff : baseColor
|
||||
|
||||
// Check if segment is fully constrained
|
||||
const isFullyConstrained =
|
||||
ast && code ? isSegmentFullyConstrained(pathToNode, ast, code) : false
|
||||
|
||||
const color = getSegmentColor({
|
||||
theme,
|
||||
isSelected: !!isSelected,
|
||||
isFullyConstrained,
|
||||
})
|
||||
const baseColor = !isFullyConstrained
|
||||
? getPrimaryColorForThreeJs()
|
||||
: getThemeColorForThreeJs(theme)
|
||||
|
||||
const group = new Group()
|
||||
const geometry = createArcGeometry({
|
||||
@ -919,6 +1122,8 @@ class CircleThreePointSegment implements SegmentUtils {
|
||||
group,
|
||||
scale = 1,
|
||||
sceneInfra,
|
||||
ast,
|
||||
code,
|
||||
}) => {
|
||||
if (input.type !== 'circle-three-point-segment') {
|
||||
return new Error('Invalid segment type')
|
||||
@ -927,6 +1132,32 @@ class CircleThreePointSegment implements SegmentUtils {
|
||||
group.userData.p1 = p1
|
||||
group.userData.p2 = p2
|
||||
group.userData.p3 = p3
|
||||
|
||||
// Check if segment is fully constrained and update color if needed
|
||||
if (ast && code) {
|
||||
const pathToNode = group.userData.pathToNode
|
||||
const isFullyConstrained = isSegmentFullyConstrained(
|
||||
pathToNode,
|
||||
ast,
|
||||
code
|
||||
)
|
||||
const color = getSegmentColor({
|
||||
theme: sceneInfra._theme,
|
||||
isSelected: group.userData.isSelected,
|
||||
isFullyConstrained,
|
||||
})
|
||||
|
||||
// Update the material color
|
||||
const circleSegmentBody = group.children.find(
|
||||
(child) => child.userData.type === CIRCLE_THREE_POINT_SEGMENT_BODY
|
||||
) as Mesh
|
||||
if (
|
||||
circleSegmentBody &&
|
||||
circleSegmentBody.material instanceof MeshBasicMaterial
|
||||
) {
|
||||
circleSegmentBody.material.color.set(color)
|
||||
}
|
||||
}
|
||||
const { center_x, center_y, radius } = calculate_circle_from_3_points(
|
||||
p1[0],
|
||||
p1[1],
|
||||
@ -1048,13 +1279,26 @@ class ArcSegment implements SegmentUtils {
|
||||
theme,
|
||||
isSelected,
|
||||
sceneInfra,
|
||||
ast,
|
||||
code,
|
||||
}) => {
|
||||
if (input.type !== 'arc-segment') {
|
||||
return new Error('Invalid segment type')
|
||||
}
|
||||
const { from, to, center, radius, ccw } = input
|
||||
const baseColor = getThemeColorForThreeJs(theme)
|
||||
const color = isSelected ? 0x0000ff : baseColor
|
||||
|
||||
// Check if segment is fully constrained
|
||||
const isFullyConstrained =
|
||||
ast && code ? isSegmentFullyConstrained(pathToNode, ast, code) : false
|
||||
|
||||
const color = getSegmentColor({
|
||||
theme,
|
||||
isSelected: !!isSelected,
|
||||
isFullyConstrained,
|
||||
})
|
||||
const baseColor = !isFullyConstrained
|
||||
? getPrimaryColorForThreeJs()
|
||||
: getThemeColorForThreeJs(theme)
|
||||
|
||||
// Calculate start and end angles
|
||||
const startAngle = Math.atan2(from[1] - center[1], from[0] - center[0])
|
||||
@ -1195,6 +1439,8 @@ class ArcSegment implements SegmentUtils {
|
||||
group,
|
||||
scale = 1,
|
||||
sceneInfra,
|
||||
ast,
|
||||
code,
|
||||
}) => {
|
||||
if (input.type !== 'arc-segment') {
|
||||
return new Error('Invalid segment type')
|
||||
@ -1207,6 +1453,32 @@ class ArcSegment implements SegmentUtils {
|
||||
group.userData.ccw = ccw
|
||||
group.userData.prevSegment = prevSegment
|
||||
|
||||
// Check if segment is fully constrained and update color if needed
|
||||
if (ast && code) {
|
||||
const pathToNode = group.userData.pathToNode
|
||||
const isFullyConstrained = isSegmentFullyConstrained(
|
||||
pathToNode,
|
||||
ast,
|
||||
code
|
||||
)
|
||||
const color = getSegmentColor({
|
||||
theme: sceneInfra._theme,
|
||||
isSelected: group.userData.isSelected,
|
||||
isFullyConstrained,
|
||||
})
|
||||
|
||||
// Update the material color
|
||||
const arcSegmentBody = group.children.find(
|
||||
(child) => child.userData.type === ARC_SEGMENT_BODY
|
||||
) as Mesh
|
||||
if (
|
||||
arcSegmentBody &&
|
||||
arcSegmentBody.material instanceof MeshBasicMaterial
|
||||
) {
|
||||
arcSegmentBody.material.color.set(color)
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate start and end angles
|
||||
const startAngle = Math.atan2(from[1] - center[1], from[0] - center[0])
|
||||
const endAngle = Math.atan2(to[1] - center[1], to[0] - center[0])
|
||||
@ -1403,6 +1675,8 @@ class ThreePointArcSegment implements SegmentUtils {
|
||||
isSelected = false,
|
||||
sceneInfra,
|
||||
prevSegment,
|
||||
ast,
|
||||
code,
|
||||
}) => {
|
||||
if (input.type !== 'circle-three-point-segment') {
|
||||
return new Error('Invalid segment type')
|
||||
@ -1417,8 +1691,19 @@ class ThreePointArcSegment implements SegmentUtils {
|
||||
p3[1]
|
||||
)
|
||||
const center: [number, number] = [center_x, center_y]
|
||||
const baseColor = getThemeColorForThreeJs(theme)
|
||||
const color = isSelected ? 0x0000ff : baseColor
|
||||
|
||||
// Check if segment is fully constrained
|
||||
const isFullyConstrained =
|
||||
ast && code ? isSegmentFullyConstrained(pathToNode, ast, code) : false
|
||||
|
||||
const color = getSegmentColor({
|
||||
theme,
|
||||
isSelected: !!isSelected,
|
||||
isFullyConstrained,
|
||||
})
|
||||
const baseColor = !isFullyConstrained
|
||||
? getPrimaryColorForThreeJs()
|
||||
: getThemeColorForThreeJs(theme)
|
||||
|
||||
// Calculate start and end angles
|
||||
const startAngle = Math.atan2(p1[1] - center[1], p1[0] - center[0])
|
||||
@ -1500,6 +1785,8 @@ class ThreePointArcSegment implements SegmentUtils {
|
||||
group,
|
||||
scale = 1,
|
||||
sceneInfra,
|
||||
ast,
|
||||
code,
|
||||
}) => {
|
||||
if (input.type !== 'circle-three-point-segment') {
|
||||
return new Error('Invalid segment type')
|
||||
@ -1523,6 +1810,32 @@ class ThreePointArcSegment implements SegmentUtils {
|
||||
group.userData.radius = radius
|
||||
group.userData.prevSegment = prevSegment
|
||||
|
||||
// Check if segment is fully constrained and update color if needed
|
||||
if (ast && code) {
|
||||
const pathToNode = group.userData.pathToNode
|
||||
const isFullyConstrained = isSegmentFullyConstrained(
|
||||
pathToNode,
|
||||
ast,
|
||||
code
|
||||
)
|
||||
const color = getSegmentColor({
|
||||
theme: sceneInfra._theme,
|
||||
isSelected: group.userData.isSelected,
|
||||
isFullyConstrained,
|
||||
})
|
||||
|
||||
// Update the material color
|
||||
const arcSegmentBody = group.children.find(
|
||||
(child) => child.userData.type === THREE_POINT_ARC_SEGMENT_BODY
|
||||
) as Mesh
|
||||
if (
|
||||
arcSegmentBody &&
|
||||
arcSegmentBody.material instanceof MeshBasicMaterial
|
||||
) {
|
||||
arcSegmentBody.material.color.set(color)
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate start and end angles
|
||||
const startAngle = Math.atan2(p1[1] - center[1], p1[0] - center[0])
|
||||
const endAngle = Math.atan2(p3[1] - center[1], p3[0] - center[0])
|
||||
@ -1619,6 +1932,8 @@ export function createProfileStartHandle({
|
||||
theme,
|
||||
isSelected,
|
||||
size = 12,
|
||||
ast,
|
||||
code,
|
||||
...rest
|
||||
}: {
|
||||
from: Coords2d
|
||||
@ -1626,15 +1941,30 @@ export function createProfileStartHandle({
|
||||
theme: Themes
|
||||
isSelected?: boolean
|
||||
size?: number
|
||||
ast?: Program
|
||||
code?: string
|
||||
} & (
|
||||
| { isDraft: true }
|
||||
| { isDraft: false; id: string; pathToNode: PathToNode }
|
||||
)) {
|
||||
const group = new Group()
|
||||
|
||||
// Check if profile start is fully constrained (only if we have AST, code, and it's not a draft)
|
||||
const isFullyConstrained =
|
||||
!isDraft && ast && code && 'pathToNode' in rest
|
||||
? isSegmentFullyConstrained(rest.pathToNode, ast, code)
|
||||
: false
|
||||
|
||||
const geometry = new BoxGeometry(size, size, size) // in pixels scaled later
|
||||
const baseColor = getThemeColorForThreeJs(theme)
|
||||
const color = isSelected ? 0x0000ff : baseColor
|
||||
const color = getSegmentColor({
|
||||
theme,
|
||||
isSelected: !!isSelected,
|
||||
callExpName: 'profileStart',
|
||||
isFullyConstrained,
|
||||
})
|
||||
const baseColor = !isFullyConstrained
|
||||
? getPrimaryColorForThreeJs()
|
||||
: getThemeColorForThreeJs(theme)
|
||||
const body = new MeshBasicMaterial({ color })
|
||||
const mesh = new Mesh(geometry, body)
|
||||
|
||||
@ -1645,6 +1975,7 @@ export function createProfileStartHandle({
|
||||
from,
|
||||
isSelected,
|
||||
baseColor,
|
||||
isFullyConstrained,
|
||||
...rest,
|
||||
}
|
||||
group.name = isDraft ? DRAFT_POINT : PROFILE_START
|
||||
|
@ -1,4 +1,5 @@
|
||||
import type { AppTheme } from '@rust/kcl-lib/bindings/AppTheme'
|
||||
import { converter } from 'culori'
|
||||
|
||||
/** A media query matcher for dark mode */
|
||||
export const darkModeMatcher =
|
||||
@ -58,6 +59,84 @@ export function getOppositeTheme(theme: Themes) {
|
||||
return resolvedTheme === Themes.Dark ? Themes.Light : Themes.Dark
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts OKLCH values to RGB using Culori library
|
||||
* @param l - Lightness (0-1)
|
||||
* @param c - Chroma (0-1)
|
||||
* @param h - Hue (0-360 degrees)
|
||||
* @returns RGB values as [r, g, b] where each component is 0-255
|
||||
*/
|
||||
function oklchToRgb(l: number, c: number, h: number): [number, number, number] {
|
||||
// Create a converter from OKLCH to RGB using Culori
|
||||
const toRgb = converter('rgb')
|
||||
|
||||
// Convert OKLCH to RGB using Culori
|
||||
const rgb = toRgb({ mode: 'oklch', l, c, h })
|
||||
|
||||
if (!rgb) {
|
||||
// Fallback if conversion fails
|
||||
return [255, 255, 255]
|
||||
}
|
||||
|
||||
// Clamp values. When OKLCH values represent colors outside the sRGB gamut, the RGB values can be negative or greater than 1.
|
||||
const clampedR = Math.max(0, Math.min(1, rgb.r))
|
||||
const clampedG = Math.max(0, Math.min(1, rgb.g))
|
||||
const clampedB = Math.max(0, Math.min(1, rgb.b))
|
||||
|
||||
// Convert from 0-1 range to 0-255 range
|
||||
return [
|
||||
Math.round(clampedR * 255),
|
||||
Math.round(clampedG * 255),
|
||||
Math.round(clampedB * 255),
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the primary color from CSS custom properties and converts it to Three.js hex format
|
||||
* @returns Primary color as a hex number for Three.js, or fallback purple if unable to get CSS value
|
||||
*/
|
||||
export function getPrimaryColorForThreeJs(): number {
|
||||
if (typeof globalThis.window === 'undefined' || !globalThis.document) {
|
||||
// Fallback for SSR or when DOM is not available
|
||||
return 0x7c3aed // Default purple
|
||||
}
|
||||
|
||||
try {
|
||||
const computedStyle = getComputedStyle(document.documentElement)
|
||||
|
||||
// Get the individual primary color components
|
||||
const hue = parseFloat(
|
||||
computedStyle.getPropertyValue('--primary-hue').trim()
|
||||
)
|
||||
const chroma = parseFloat(
|
||||
computedStyle.getPropertyValue('--primary-chroma').trim()
|
||||
)
|
||||
const lightness =
|
||||
parseFloat(
|
||||
computedStyle
|
||||
.getPropertyValue('--primary-lightness')
|
||||
.replace('%', '')
|
||||
.trim()
|
||||
) / 100
|
||||
|
||||
if (Number.isNaN(hue) || Number.isNaN(chroma) || Number.isNaN(lightness)) {
|
||||
console.warn(
|
||||
'Unable to parse primary color components from CSS, using fallback'
|
||||
)
|
||||
return 0x7c3aed // Default purple
|
||||
}
|
||||
|
||||
// Convert OKLCH to RGB
|
||||
const [r, g, b] = oklchToRgb(lightness, chroma, hue)
|
||||
|
||||
// Convert RGB to hex
|
||||
return (r << 16) | (g << 8) | b
|
||||
} catch (error) {
|
||||
console.warn('Error getting primary color from CSS:', error)
|
||||
return 0x7c3aed // Default purple fallback
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The engine takes RGBA values from 0-1
|
||||
* So we convert from the conventional 0-255 found in Figma
|
||||
|