-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1850 from hannobraun/build
Add `BuildSketch`
- Loading branch information
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters