From 5d230a6e7e1e41b0fecfceea96696993468cd0e3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 27 May 2024 14:42:05 +0200 Subject: [PATCH 1/2] Add `BuildSketch::circle` --- crates/fj-core/src/operations/build/sketch.rs | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/fj-core/src/operations/build/sketch.rs b/crates/fj-core/src/operations/build/sketch.rs index 93e8a6840..3463cf0b6 100644 --- a/crates/fj-core/src/operations/build/sketch.rs +++ b/crates/fj-core/src/operations/build/sketch.rs @@ -1,4 +1,12 @@ -use crate::topology::{Sketch, Topology}; +use fj_math::{Point, Scalar}; + +use crate::{ + operations::update::UpdateSketch, + topology::{Region, Sketch, Topology}, + Core, +}; + +use super::BuildRegion; /// Build a [`Sketch`] /// @@ -10,6 +18,24 @@ pub trait BuildSketch { fn empty(topology: &Topology) -> Sketch { Sketch::new(topology.surfaces.space_2d(), []) } + + /// Build a circle + fn circle( + center: impl Into>, + radius: impl Into, + core: &mut Core, + ) -> Sketch { + let sketch = Sketch::empty(&core.layers.topology); + sketch.add_regions( + [Region::circle( + center, + radius, + sketch.surface().clone(), + core, + )], + core, + ) + } } impl BuildSketch for Sketch {} From 25ab473301746a3653f3a8164eca36348c7c82f0 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 27 May 2024 14:53:53 +0200 Subject: [PATCH 2/2] Add `BuildSketch::polygon` --- crates/fj-core/src/operations/build/sketch.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/fj-core/src/operations/build/sketch.rs b/crates/fj-core/src/operations/build/sketch.rs index 3463cf0b6..25edbe263 100644 --- a/crates/fj-core/src/operations/build/sketch.rs +++ b/crates/fj-core/src/operations/build/sketch.rs @@ -36,6 +36,20 @@ pub trait BuildSketch { core, ) } + + /// Build a polygon + fn polygon(points: Ps, core: &mut Core) -> Sketch + where + P: Into>, + Ps: IntoIterator, + Ps::IntoIter: Clone + ExactSizeIterator, + { + let sketch = Sketch::empty(&core.layers.topology); + sketch.add_regions( + [Region::polygon(points, sketch.surface().clone(), core)], + core, + ) + } } impl BuildSketch for Sketch {}