Skip to content

Commit

Permalink
Merge pull request #1850 from hannobraun/build
Browse files Browse the repository at this point in the history
Add `BuildSketch`
  • Loading branch information
hannobraun authored May 30, 2023
2 parents d74949b + 1fee152 commit 2d1385b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/fj-kernel/src/operations/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ pub mod cycle;
pub mod edge;
pub mod face;
pub mod shell;
pub mod sketch;
pub mod solid;
pub mod surface;
25 changes: 25 additions & 0 deletions crates/fj-kernel/src/operations/build/sketch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use fj_math::Point;

use crate::{
geometry::region::Region,
objects::{Cycle, Sketch},
operations::{BuildCycle, Insert},
services::Services,
};

/// Build a [`Sketch`]
pub trait BuildSketch {
/// Build a polygon
fn polygon<P, Ps>(points: Ps, services: &mut Services) -> Sketch
where
P: Into<Point<2>>,
Ps: IntoIterator<Item = P>,
Ps::IntoIter: Clone + ExactSizeIterator,
{
let exterior = Cycle::polygon(points, services).insert(services);
let region = Region::new(exterior, Vec::new(), None);
Sketch::new([region])
}
}

impl BuildSketch for Sketch {}
1 change: 1 addition & 0 deletions crates/fj-kernel/src/operations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub use self::{
edge::BuildHalfEdge,
face::{BuildFace, Polygon},
shell::{BuildShell, TetrahedronShell},
sketch::BuildSketch,
solid::{BuildSolid, Tetrahedron},
surface::BuildSurface,
},
Expand Down

0 comments on commit 2d1385b

Please sign in to comment.