Compare commits
	
		
			3 Commits
		
	
	
		
			franknoiro
			...
			achalmers/
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 50cf30c0d9 | |||
| 47532e5fc4 | |||
| 0da92411c4 | 
							
								
								
									
										92654
									
								
								docs/kcl/std.json
									
									
									
									
									
								
							
							
						
						| @ -21,6 +21,7 @@ A sketch is a collection of paths. | ||||
| | `on` |[`SketchSurface`](/docs/kcl/types/SketchSurface)| What the sketch is on (can be a plane or a face). | No | | ||||
| | `start` |[`BasePath`](/docs/kcl/types/BasePath)| The starting path. | No | | ||||
| | `tags` |`object`| Tag identifiers that have been declared in this sketch. | No | | ||||
| | `originalId` |`string`| The original id of the sketch. This stays the same even if the sketch is sketched on face etc. | No | | ||||
| | `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| Metadata. | No | | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -30,6 +30,7 @@ A sketch is a collection of paths. | ||||
| | `on` |[`SketchSurface`](/docs/kcl/types/SketchSurface)| What the sketch is on (can be a plane or a face). | No | | ||||
| | `start` |[`BasePath`](/docs/kcl/types/BasePath)| The starting path. | No | | ||||
| | `tags` |`object`| Tag identifiers that have been declared in this sketch. | No | | ||||
| | `originalId` |`string`| The original id of the sketch. This stays the same even if the sketch is sketched on face etc. | No | | ||||
| | `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| Metadata. | No | | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -22,6 +22,7 @@ const mySketch001 = startSketchOn('XY') | ||||
|       value: { | ||||
|         type: 'Sketch', | ||||
|         on: expect.any(Object), | ||||
|         originalId: expect.any(String), | ||||
|         start: { | ||||
|           to: [0, 0], | ||||
|           from: [0, 0], | ||||
| @ -91,6 +92,7 @@ const mySketch001 = startSketchOn('XY') | ||||
|       ], | ||||
|       sketch: { | ||||
|         id: expect.any(String), | ||||
|         originalId: expect.any(String), | ||||
|         __meta: expect.any(Array), | ||||
|         on: expect.any(Object), | ||||
|         start: expect.any(Object), | ||||
| @ -185,6 +187,7 @@ const sk2 = startSketchOn('XY') | ||||
|         ], | ||||
|         sketch: { | ||||
|           id: expect.any(String), | ||||
|           originalId: expect.any(String), | ||||
|           __meta: expect.any(Array), | ||||
|           on: expect.any(Object), | ||||
|           start: expect.any(Object), | ||||
| @ -277,6 +280,7 @@ const sk2 = startSketchOn('XY') | ||||
|         ], | ||||
|         sketch: { | ||||
|           id: expect.any(String), | ||||
|           originalId: expect.any(String), | ||||
|           __meta: expect.any(Array), | ||||
|           on: expect.any(Object), | ||||
|           start: expect.any(Object), | ||||
|  | ||||
| @ -160,6 +160,7 @@ const newVar = myVar + 1` | ||||
|       value: { | ||||
|         type: 'Sketch', | ||||
|         on: expect.any(Object), | ||||
|         originalId: expect.any(String), | ||||
|         start: { | ||||
|           to: [0, 0], | ||||
|           from: [0, 0], | ||||
|  | ||||
| @ -345,6 +345,12 @@ impl Geometry { | ||||
|             Geometry::Solid(e) => e.id, | ||||
|         } | ||||
|     } | ||||
|     pub fn original_id(&self) -> uuid::Uuid { | ||||
|         match self { | ||||
|             Geometry::Sketch(s) => s.original_id, | ||||
|             Geometry::Solid(e) => e.sketch.original_id, | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| /// A set of geometry. | ||||
| @ -776,7 +782,6 @@ pub struct Sketch { | ||||
|     pub tags: IndexMap<String, TagIdentifier>, | ||||
|     /// The original id of the sketch. This stays the same even if the sketch is | ||||
|     /// is sketched on face etc. | ||||
|     #[serde(skip)] | ||||
|     pub original_id: uuid::Uuid, | ||||
|     /// Metadata. | ||||
|     #[serde(rename = "__meta")] | ||||
|  | ||||
| @ -111,7 +111,7 @@ async fn inner_extrude( | ||||
|         args.batch_modeling_cmd( | ||||
|             id, | ||||
|             ModelingCmd::from(mcmd::Extrude { | ||||
|                 target: sketch.id.into(), | ||||
|                 target: dbg!(sketch.id.into()), | ||||
|                 distance: LengthUnit(length), | ||||
|                 faces: Default::default(), | ||||
|             }), | ||||
|  | ||||
| @ -384,9 +384,9 @@ async fn send_pattern_transform<T: GeometryTrait>( | ||||
|         .send_modeling_cmd( | ||||
|             id, | ||||
|             ModelingCmd::from(mcmd::EntityLinearPatternTransform { | ||||
|                 entity_id: solid.id(), | ||||
|                 transform: Default::default(), | ||||
|                 entity_id: solid.original_id(), | ||||
|                 transforms, | ||||
|                 transform: Default::default(), | ||||
|             }), | ||||
|         ) | ||||
|         .await?; | ||||
| @ -597,7 +597,9 @@ fn array_to_point2d(val: &KclValue, source_ranges: Vec<SourceRange>) -> Result<P | ||||
|  | ||||
| trait GeometryTrait: Clone { | ||||
|     type Set: Into<Vec<Self>> + Clone; | ||||
|     #[allow(dead_code)] | ||||
|     fn id(&self) -> Uuid; | ||||
|     fn original_id(&self) -> Uuid; | ||||
|     fn set_id(&mut self, id: Uuid); | ||||
|     fn array_to_point3d(val: &KclValue, source_ranges: Vec<SourceRange>) -> Result<Point3d, KclError>; | ||||
|     async fn flush_batch(args: &Args, exec_state: &mut ExecState, set: Self::Set) -> Result<(), KclError>; | ||||
| @ -608,9 +610,15 @@ impl GeometryTrait for Box<Sketch> { | ||||
|     fn set_id(&mut self, id: Uuid) { | ||||
|         self.id = id; | ||||
|     } | ||||
|  | ||||
|     fn id(&self) -> Uuid { | ||||
|         self.id | ||||
|     } | ||||
|  | ||||
|     fn original_id(&self) -> Uuid { | ||||
|         self.original_id | ||||
|     } | ||||
|  | ||||
|     fn array_to_point3d(val: &KclValue, source_ranges: Vec<SourceRange>) -> Result<Point3d, KclError> { | ||||
|         let Point2d { x, y } = array_to_point2d(val, source_ranges)?; | ||||
|         Ok(Point3d { x, y, z: 0.0 }) | ||||
| @ -630,6 +638,11 @@ impl GeometryTrait for Box<Solid> { | ||||
|     fn id(&self) -> Uuid { | ||||
|         self.id | ||||
|     } | ||||
|  | ||||
|     fn original_id(&self) -> Uuid { | ||||
|         self.sketch.original_id | ||||
|     } | ||||
|  | ||||
|     fn array_to_point3d(val: &KclValue, source_ranges: Vec<SourceRange>) -> Result<Point3d, KclError> { | ||||
|         array_to_point3d(val, source_ranges) | ||||
|     } | ||||
| @ -1049,7 +1062,7 @@ async fn pattern_circular( | ||||
|             id, | ||||
|             ModelingCmd::from(mcmd::EntityCircularPattern { | ||||
|                 axis: kcmc::shared::Point3d::from(data.axis()), | ||||
|                 entity_id: geometry.id(), | ||||
|                 entity_id: geometry.original_id(), | ||||
|                 center: kcmc::shared::Point3d { | ||||
|                     x: LengthUnit(center[0]), | ||||
|                     y: LengthUnit(center[1]), | ||||
|  | ||||
							
								
								
									
										20
									
								
								src/wasm-lib/tests/executor/inputs/repeat_bumps_only.kcl
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,20 @@ | ||||
| w = 400 | ||||
|  | ||||
| case = startSketchOn('XY') | ||||
|     |> startProfileAt([-w, -w], %) | ||||
|     |> lineTo([-w,  w], %) | ||||
|     |> lineTo([ w, -w], %) | ||||
|     |> lineTo([-w, -w], %) | ||||
|     |> close(%) | ||||
|     |> extrude(200, %) | ||||
|  | ||||
| bump1 = startSketchOn(case, 'end') | ||||
|     |> circle({center: [-50, -50], radius: 40}, %) | ||||
|     |> extrude(20, %) | ||||
|  | ||||
| // We pass in "bump1" here since we want to pattern just this object on the face. | ||||
| |> patternLinear3d({ | ||||
|        axis: [1, 0, 0], | ||||
|        instances: 3, | ||||
|        distance: -100, | ||||
|      }, %) | ||||
| Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 64 KiB | 
| Before Width: | Height: | Size: 123 KiB After Width: | Height: | Size: 76 KiB | 
| Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 55 KiB | 
							
								
								
									
										
											BIN
										
									
								
								src/wasm-lib/tests/executor/outputs/repeat_bumps_only.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 51 KiB | 
							
								
								
									
										65
									
								
								src/wasm-lib/tests/executor/visuals.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @ -0,0 +1,65 @@ | ||||
| macro_rules! kcl_input { | ||||
|     ($file:literal) => { | ||||
|         include_str!(concat!("inputs/", $file, ".kcl")) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| macro_rules! kcl_test { | ||||
|     ($file:literal, $test_name:ident) => { | ||||
|         #[tokio::test(flavor = "multi_thread")] | ||||
|         async fn $test_name() { | ||||
|             let code = kcl_input!($file); | ||||
|  | ||||
|             let result = super::execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm) | ||||
|                 .await | ||||
|                 .unwrap(); | ||||
|             super::assert_out($file, &result); | ||||
|         } | ||||
|     }; | ||||
| } | ||||
|  | ||||
| kcl_test!("sketch_on_face", kcl_test_sketch_on_face); | ||||
| kcl_test!("tangential_arc", kcl_test_tangential_arc); | ||||
| kcl_test!( | ||||
|     "big_number_angle_to_match_length_x", | ||||
|     kcl_test_big_number_angle_to_match_length_x | ||||
| ); | ||||
| kcl_test!( | ||||
|     "big_number_angle_to_match_length_y", | ||||
|     kcl_test_big_number_angle_to_match_length_y | ||||
| ); | ||||
| kcl_test!("sketch_on_face_circle_tagged", kcl_test_sketch_on_face_circle_tagged); | ||||
| kcl_test!("basic_fillet_cube_start", kcl_test_basic_fillet_cube_start); | ||||
| kcl_test!( | ||||
|     "basic_fillet_cube_next_adjacent", | ||||
|     kcl_test_basic_fillet_cube_next_adjacent | ||||
| ); | ||||
| kcl_test!( | ||||
|     "basic_fillet_cube_previous_adjacent", | ||||
|     kcl_test_basic_fillet_cube_previous_adjacent | ||||
| ); | ||||
| kcl_test!("basic_fillet_cube_end", kcl_test_basic_fillet_cube_end); | ||||
| kcl_test!( | ||||
|     "basic_fillet_cube_close_opposite", | ||||
|     kcl_test_basic_fillet_cube_close_opposite | ||||
| ); | ||||
| kcl_test!("sketch_on_face_end", kcl_test_sketch_on_face_end); | ||||
| kcl_test!("sketch_on_face_start", kcl_test_sketch_on_face_start); | ||||
| kcl_test!( | ||||
|     "sketch_on_face_end_negative_extrude", | ||||
|     kcl_test_sketch_on_face_end_negative_extrude | ||||
| ); | ||||
| kcl_test!("mike_stress_test", kcl_test_mike_stress_test); | ||||
| kcl_test!("pentagon_fillet_sugar", kcl_test_pentagon_fillet_sugar); | ||||
| kcl_test!("pipe_as_arg", kcl_test_pipe_as_arg); | ||||
| kcl_test!("computed_var", kcl_test_computed_var); | ||||
| kcl_test!("lego", kcl_test_lego); | ||||
| kcl_test!("riddle_small", kcl_test_riddle_small); | ||||
| kcl_test!("tan_arc_x_line", kcl_test_tan_arc_x_line); | ||||
| kcl_test!("fillet-and-shell", kcl_test_fillet_and_shell); | ||||
| kcl_test!("sketch-on-chamfer-two-times", kcl_test_sketch_on_chamfer_two_times); | ||||
| kcl_test!( | ||||
|     "sketch-on-chamfer-two-times-different-order", | ||||
|     kcl_test_sketch_on_chamfer_two_times_different_order | ||||
| ); | ||||
| kcl_test!("repeat_bumps_only", repeat_bumps_only); | ||||
