Skip to content

Commit

Permalink
Add UpdateSketch::add_circle
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Jun 12, 2023
1 parent 6064c51 commit d0eb0b2
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion crates/fj-core/src/operations/update/sketch.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use fj_math::Point;
use fj_math::{Point, Scalar};

use crate::{
geometry::region::Region,
Expand All @@ -12,6 +12,14 @@ pub trait UpdateSketch {
/// Add a region to the sketch
fn add_region(&self, region: Region) -> Self;

/// Add a circle to the sketch
fn add_circle(
&self,
center: impl Into<Point<2>>,
radius: impl Into<Scalar>,
services: &mut Services,
) -> Self;

/// Add a polygon to the sketch
fn add_polygon<P, Ps>(&self, points: Ps, services: &mut Services) -> Self
where
Expand All @@ -25,6 +33,16 @@ impl UpdateSketch for Sketch {
Sketch::new(self.regions().cloned().chain([region]))
}

fn add_circle(
&self,
center: impl Into<Point<2>>,
radius: impl Into<Scalar>,
services: &mut Services,
) -> Self {
let exterior = Cycle::circle(center, radius, services).insert(services);
self.add_region(Region::new(exterior, [], None))
}

fn add_polygon<P, Ps>(&self, points: Ps, services: &mut Services) -> Self
where
P: Into<Point<2>>,
Expand Down

0 comments on commit d0eb0b2

Please sign in to comment.