test: Add SSI pattern simulation test (#5379)

* Add new SSI pattern test

* Update output since adding new test
This commit is contained in:
Jonathan Tran
2025-02-13 16:04:12 -05:00
committed by GitHub
parent 78b42ea191
commit e27e9ecc63
9 changed files with 20528 additions and 0 deletions

View File

@ -1600,6 +1600,27 @@ mod parametric {
super::execute(TEST_NAME, true).await
}
}
mod ssi_pattern {
const TEST_NAME: &str = "ssi_pattern";
/// Test parsing KCL.
#[test]
fn parse() {
super::parse(TEST_NAME)
}
/// Test that parsing and unparsing KCL produces the original KCL input.
#[test]
fn unparse() {
super::unparse(TEST_NAME)
}
/// Test that KCL is executed correctly.
#[tokio::test(flavor = "multi_thread")]
async fn kcl_test_execute() {
super::execute(TEST_NAME, true).await
}
}
mod angled_line {
const TEST_NAME: &str = "angled_line";

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
---
source: kcl/src/simulation_tests.rs
description: Artifact graph flowchart ssi_pattern.kcl
extension: md
snapshot_kind: binary
---

View File

@ -0,0 +1,92 @@
```mermaid
flowchart LR
subgraph path2 [Path]
2["Path<br>[37, 71, 0]"]
3["Segment<br>[77, 91, 0]"]
4["Segment<br>[97, 122, 0]"]
5["Segment<br>[128, 161, 0]"]
6["Segment<br>[167, 183, 0]"]
7["Segment<br>[189, 259, 0]"]
8["Segment<br>[265, 272, 0]"]
9[Solid2d]
end
subgraph path28 [Path]
28["Path<br>[370, 421, 0]"]
29["Segment<br>[370, 421, 0]"]
30[Solid2d]
end
1["Plane<br>[12, 31, 0]"]
10["Sweep Extrusion<br>[287, 318, 0]"]
11[Wall]
12[Wall]
13[Wall]
14[Wall]
15[Wall]
16["Cap Start"]
17["Cap End"]
18["SweepEdge Opposite"]
19["SweepEdge Adjacent"]
20["SweepEdge Opposite"]
21["SweepEdge Adjacent"]
22["SweepEdge Opposite"]
23["SweepEdge Adjacent"]
24["SweepEdge Opposite"]
25["SweepEdge Adjacent"]
26["SweepEdge Opposite"]
27["SweepEdge Adjacent"]
31["Sweep Extrusion<br>[611, 632, 0]"]
32[Wall]
33["SweepEdge Opposite"]
34["SweepEdge Adjacent"]
1 --- 2
2 --- 3
2 --- 4
2 --- 5
2 --- 6
2 --- 7
2 --- 8
2 ---- 10
2 --- 9
3 --- 15
3 --- 26
3 --- 27
4 --- 14
4 --- 24
4 --- 25
5 --- 13
5 --- 22
5 --- 23
6 --- 12
6 --- 20
6 --- 21
7 --- 11
7 --- 18
7 --- 19
10 --- 11
10 --- 12
10 --- 13
10 --- 14
10 --- 15
10 --- 16
10 --- 17
10 --- 18
10 --- 19
10 --- 20
10 --- 21
10 --- 22
10 --- 23
10 --- 24
10 --- 25
10 --- 26
10 --- 27
11 --- 28
28 --- 29
28 ---- 31
28 --- 30
29 --- 32
29 --- 33
29 --- 34
31 --- 32
31 --- 33
31 --- 34
```

View File

@ -0,0 +1,873 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing ssi_pattern.kcl
---
{
"Ok": {
"body": [
{
"declaration": {
"end": 272,
"id": {
"end": 9,
"name": "sketch001",
"start": 0,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"end": 30,
"raw": "'XZ'",
"start": 26,
"type": "Literal",
"type": "Literal",
"value": "XZ"
}
],
"callee": {
"end": 25,
"name": "startSketchOn",
"start": 12,
"type": "Identifier"
},
"end": 31,
"start": 12,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"argument": {
"end": 58,
"raw": "4.35",
"start": 54,
"type": "Literal",
"type": "Literal",
"value": {
"value": 4.35,
"suffix": "None"
}
},
"end": 58,
"operator": "-",
"start": 53,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"argument": {
"end": 66,
"raw": "12.26",
"start": 61,
"type": "Literal",
"type": "Literal",
"value": {
"value": 12.26,
"suffix": "None"
}
},
"end": 66,
"operator": "-",
"start": 60,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"end": 67,
"start": 52,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 70,
"start": 69,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 51,
"name": "startProfileAt",
"start": 37,
"type": "Identifier"
},
"end": 71,
"start": 37,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 87,
"raw": "10.2",
"start": 83,
"type": "Literal",
"type": "Literal",
"value": {
"value": 10.2,
"suffix": "None"
}
},
{
"end": 90,
"start": 89,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 82,
"name": "yLine",
"start": 77,
"type": "Identifier"
},
"end": 91,
"start": 77,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "end"
},
"arg": {
"elements": [
{
"end": 113,
"raw": "0.54",
"start": 109,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.54,
"suffix": "None"
}
},
{
"argument": {
"end": 120,
"raw": "0.03",
"start": 116,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.03,
"suffix": "None"
}
},
"end": 120,
"operator": "-",
"start": 115,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"end": 121,
"start": 108,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
}
],
"callee": {
"end": 101,
"name": "line",
"start": 97,
"type": "Identifier"
},
"end": 122,
"start": 97,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
},
{
"arguments": [
{
"elements": [
{
"end": 149,
"raw": "20.4",
"start": 145,
"type": "Literal",
"type": "Literal",
"value": {
"value": 20.4,
"suffix": "None"
}
},
{
"end": 156,
"raw": "14.61",
"start": 151,
"type": "Literal",
"type": "Literal",
"value": {
"value": 14.61,
"suffix": "None"
}
}
],
"end": 157,
"start": 144,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 160,
"start": 159,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 143,
"name": "tangentialArcTo",
"start": 128,
"type": "Identifier"
},
"end": 161,
"start": 128,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"argument": {
"end": 179,
"raw": "26.76",
"start": 174,
"type": "Literal",
"type": "Literal",
"value": {
"value": 26.76,
"suffix": "None"
}
},
"end": 179,
"operator": "-",
"start": 173,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"end": 182,
"start": 181,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 172,
"name": "yLine",
"start": 167,
"type": "Identifier"
},
"end": 183,
"start": 167,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "endAbsolute"
},
"arg": {
"elements": [
{
"arguments": [
{
"end": 224,
"start": 223,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 222,
"name": "profileStartX",
"start": 209,
"type": "Identifier"
},
"end": 225,
"start": 209,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 242,
"start": 241,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 240,
"name": "profileStartY",
"start": 227,
"type": "Identifier"
},
"end": 243,
"start": 227,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 244,
"start": 208,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "tag"
},
"arg": {
"end": 258,
"start": 252,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "seg01"
}
}
],
"callee": {
"end": 193,
"name": "line",
"start": 189,
"type": "Identifier"
},
"end": 259,
"start": 189,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
},
{
"arguments": [],
"callee": {
"end": 270,
"name": "close",
"start": 265,
"type": "Identifier"
},
"end": 272,
"start": 265,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 272,
"start": 12,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 272,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 318,
"id": {
"end": 284,
"name": "extrude001",
"start": 274,
"type": "Identifier"
},
"init": {
"arguments": [
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "length"
},
"arg": {
"end": 317,
"raw": "50",
"start": 315,
"type": "Literal",
"type": "Literal",
"value": {
"value": 50.0,
"suffix": "None"
}
}
}
],
"callee": {
"end": 294,
"name": "extrude",
"start": 287,
"type": "Identifier"
},
"end": 318,
"start": 287,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"end": 304,
"name": "sketch001",
"start": 295,
"type": "Identifier",
"type": "Identifier"
}
},
"start": 274,
"type": "VariableDeclarator"
},
"end": 318,
"kind": "const",
"start": 274,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declaration": {
"end": 632,
"id": {
"end": 329,
"name": "sketch002",
"start": 320,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"end": 356,
"name": "extrude001",
"start": 346,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 363,
"name": "seg01",
"start": 358,
"type": "Identifier",
"type": "Identifier"
}
],
"callee": {
"end": 345,
"name": "startSketchOn",
"start": 332,
"type": "Identifier"
},
"end": 364,
"start": 332,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 417,
"properties": [
{
"end": 401,
"key": {
"end": 385,
"name": "center",
"start": 379,
"type": "Identifier"
},
"start": 379,
"type": "ObjectProperty",
"value": {
"elements": [
{
"argument": {
"end": 394,
"raw": "2.08",
"start": 390,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.08,
"suffix": "None"
}
},
"end": 394,
"operator": "-",
"start": 389,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"end": 400,
"raw": "47.7",
"start": 396,
"type": "Literal",
"type": "Literal",
"value": {
"value": 47.7,
"suffix": "None"
}
}
],
"end": 401,
"start": 388,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 415,
"key": {
"end": 409,
"name": "radius",
"start": 403,
"type": "Identifier"
},
"start": 403,
"type": "ObjectProperty",
"value": {
"end": 415,
"raw": "1.4",
"start": 412,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.4,
"suffix": "None"
}
}
}
],
"start": 377,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"end": 420,
"start": 419,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 376,
"name": "circle",
"start": 370,
"type": "Identifier"
},
"end": 421,
"start": 370,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "instances"
},
"arg": {
"end": 456,
"raw": "5",
"start": 455,
"type": "Literal",
"type": "Literal",
"value": {
"value": 5.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "distance"
},
"arg": {
"end": 470,
"raw": "5",
"start": 469,
"type": "Literal",
"type": "Literal",
"value": {
"value": 5.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "axis"
},
"arg": {
"elements": [
{
"end": 481,
"raw": "1",
"start": 480,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
{
"end": 484,
"raw": "0",
"start": 483,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
],
"end": 485,
"start": 479,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
}
],
"callee": {
"end": 442,
"name": "patternLinear2d",
"start": 427,
"type": "Identifier"
},
"end": 486,
"start": 427,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "instances"
},
"arg": {
"end": 574,
"raw": "6",
"start": 573,
"type": "Literal",
"type": "Literal",
"value": {
"value": 6.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "distance"
},
"arg": {
"end": 588,
"raw": "4",
"start": 587,
"type": "Literal",
"type": "Literal",
"value": {
"value": 4.0,
"suffix": "None"
}
}
},
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "axis"
},
"arg": {
"elements": [
{
"end": 599,
"raw": "0",
"start": 598,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"argument": {
"end": 603,
"raw": "1",
"start": 602,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"end": 603,
"operator": "-",
"start": 601,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"end": 604,
"start": 597,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
}
],
"callee": {
"end": 560,
"name": "patternLinear2d",
"start": 545,
"type": "Identifier"
},
"end": 605,
"start": 545,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"type": "Identifier",
"name": "length"
},
"arg": {
"argument": {
"end": 631,
"raw": "40",
"start": 629,
"type": "Literal",
"type": "Literal",
"value": {
"value": 40.0,
"suffix": "None"
}
},
"end": 631,
"operator": "-",
"start": 628,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
}
],
"callee": {
"end": 618,
"name": "extrude",
"start": 611,
"type": "Identifier"
},
"end": 632,
"start": 611,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
}
],
"end": 632,
"nonCodeMeta": {
"nonCodeNodes": {
"2": [
{
"end": 539,
"start": 488,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
"value": "Instances was reduced from 12 to speed this up.",
"style": "line"
}
}
]
},
"startNodes": []
},
"start": 332,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 320,
"type": "VariableDeclarator"
},
"end": 632,
"kind": "const",
"start": 320,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 633,
"nonCodeMeta": {
"nonCodeNodes": {
"0": [
{
"end": 274,
"start": 272,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"1": [
{
"end": 320,
"start": 318,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"startNodes": []
},
"start": 0
}
}

View File

@ -0,0 +1,17 @@
sketch001 = startSketchOn('XZ')
|> startProfileAt([-4.35, -12.26], %)
|> yLine(10.2, %)
|> line(end = [0.54, -0.03])
|> tangentialArcTo([20.4, 14.61], %)
|> yLine(-26.76, %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg01)
|> close()
extrude001 = extrude(sketch001, length = 50)
sketch002 = startSketchOn(extrude001, seg01)
|> circle({ center = [-2.08, 47.7], radius = 1.4 }, %)
|> patternLinear2d(instances = 5, distance = 5, axis = [1, 0])
// Instances was reduced from 12 to speed this up.
|> patternLinear2d(instances = 6, distance = 4, axis = [0, -1])
|> extrude(length = -40)

View File

@ -0,0 +1,95 @@
---
source: kcl/src/simulation_tests.rs
description: Operations executed ssi_pattern.kcl
---
[
{
"labeledArgs": {
"data": {
"sourceRange": [
26,
30,
0
]
}
},
"name": "startSketchOn",
"sourceRange": [
12,
31,
0
],
"type": "StdLibCall",
"unlabeledArg": null
},
{
"labeledArgs": {
"length": {
"sourceRange": [
315,
317,
0
]
}
},
"name": "extrude",
"sourceRange": [
287,
318,
0
],
"type": "StdLibCall",
"unlabeledArg": {
"sourceRange": [
295,
304,
0
]
}
},
{
"labeledArgs": {
"data": {
"sourceRange": [
346,
356,
0
]
},
"tag": {
"sourceRange": [
358,
363,
0
]
}
},
"name": "startSketchOn",
"sourceRange": [
332,
364,
0
],
"type": "StdLibCall",
"unlabeledArg": null
},
{
"labeledArgs": {
"length": {
"sourceRange": [
628,
631,
0
]
}
},
"name": "extrude",
"sourceRange": [
611,
632,
0
],
"type": "StdLibCall",
"unlabeledArg": null
}
]

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB