-
-
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.
Extract non-essential methods from
PartialFace
- Loading branch information
1 parent
2dd5f6d
commit e8e74cf
Showing
14 changed files
with
64 additions
and
36 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
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
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
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
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
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
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,49 @@ | ||
use fj_math::Point; | ||
|
||
use crate::{ | ||
objects::Cycle, | ||
partial::{HasPartial, PartialFace}, | ||
}; | ||
|
||
use super::CycleBuilder; | ||
|
||
/// Builder API for [`PartialFace`] | ||
pub trait FaceBuilder { | ||
/// Update the [`PartialFace`] with an exterior polygon | ||
fn with_exterior_polygon_from_points( | ||
self, | ||
points: impl IntoIterator<Item = impl Into<Point<2>>>, | ||
) -> Self; | ||
|
||
/// Update the [`PartialFace`] with an interior polygon | ||
fn with_interior_polygon_from_points( | ||
self, | ||
points: impl IntoIterator<Item = impl Into<Point<2>>>, | ||
) -> Self; | ||
} | ||
|
||
impl FaceBuilder for PartialFace { | ||
fn with_exterior_polygon_from_points( | ||
self, | ||
points: impl IntoIterator<Item = impl Into<Point<2>>>, | ||
) -> Self { | ||
let surface = self.surface().expect("Need surface to create polygon"); | ||
|
||
self.with_exterior( | ||
Cycle::partial() | ||
.with_poly_chain_from_points(surface, points) | ||
.close_with_line_segment(), | ||
) | ||
} | ||
|
||
fn with_interior_polygon_from_points( | ||
self, | ||
points: impl IntoIterator<Item = impl Into<Point<2>>>, | ||
) -> Self { | ||
let surface = self.surface().expect("Need surface to build polygon."); | ||
|
||
self.with_interiors([Cycle::partial() | ||
.with_poly_chain_from_points(surface, points) | ||
.close_with_line_segment()]) | ||
} | ||
} |
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
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
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
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
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
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
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