Skip to content

Commit

Permalink
Merge pull request #2366 from hannobraun/build
Browse files Browse the repository at this point in the history
Expand `BuildSketch`
  • Loading branch information
hannobraun authored May 27, 2024
2 parents e861a51 + 25ab473 commit 34c415f
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion crates/fj-core/src/operations/build/sketch.rs
Original file line number Diff line number Diff line change
@@ -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`]
///
Expand All @@ -10,6 +18,38 @@ pub trait BuildSketch {
fn empty(topology: &Topology) -> Sketch {
Sketch::new(topology.surfaces.space_2d(), [])
}

/// Build a circle
fn circle(
center: impl Into<Point<2>>,
radius: impl Into<Scalar>,
core: &mut Core,
) -> Sketch {
let sketch = Sketch::empty(&core.layers.topology);
sketch.add_regions(
[Region::circle(
center,
radius,
sketch.surface().clone(),
core,
)],
core,
)
}

/// Build a polygon
fn polygon<P, Ps>(points: Ps, core: &mut Core) -> Sketch
where
P: Into<Point<2>>,
Ps: IntoIterator<Item = P>,
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 {}

0 comments on commit 34c415f

Please sign in to comment.