mirror of
https://github.com/hannobraun/Fornjot
synced 2025-10-03 22:48:11 +00:00
Merge pull request #2046 from hannobraun/boundary
Make some improvements to `CurveBoundaries`
This commit is contained in:
commit
8048d8a44d
@ -50,12 +50,10 @@ impl CurveApprox {
|
|||||||
impl<const N: usize> From<[CurveApproxSegment; N]> for CurveApprox {
|
impl<const N: usize> From<[CurveApproxSegment; N]> for CurveApprox {
|
||||||
fn from(segments: [CurveApproxSegment; N]) -> Self {
|
fn from(segments: [CurveApproxSegment; N]) -> Self {
|
||||||
Self {
|
Self {
|
||||||
segments: CurveBoundaries {
|
segments: segments
|
||||||
inner: segments
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|segment| (segment.boundary, segment.points))
|
.map(|segment| (segment.boundary, segment.points))
|
||||||
.collect(),
|
.collect(),
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,7 @@ use crate::geometry::CurveBoundary;
|
|||||||
/// boundary.
|
/// boundary.
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||||
pub struct CurveBoundaries<T: CurveBoundariesPayload = ()> {
|
pub struct CurveBoundaries<T: CurveBoundariesPayload = ()> {
|
||||||
/// The [`CurveBoundary`] instances
|
inner: Vec<(CurveBoundary<Point<1>>, T)>,
|
||||||
pub inner: Vec<(CurveBoundary<Point<1>>, T)>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: CurveBoundariesPayload> CurveBoundaries<T> {
|
impl<T: CurveBoundariesPayload> CurveBoundaries<T> {
|
||||||
@ -29,7 +28,7 @@ impl<T: CurveBoundariesPayload> CurveBoundaries<T> {
|
|||||||
// the removed element's boundary matches the boundary provided
|
// the removed element's boundary matches the boundary provided
|
||||||
// to us.
|
// to us.
|
||||||
//
|
//
|
||||||
// This is what the caller was asking for. Return it!
|
// This is what the caller is asking for. Return it!
|
||||||
Some(payload)
|
Some(payload)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@ -115,6 +114,19 @@ impl<T: CurveBoundariesPayload> Default for CurveBoundaries<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: CurveBoundariesPayload> FromIterator<(CurveBoundary<Point<1>>, T)>
|
||||||
|
for CurveBoundaries<T>
|
||||||
|
{
|
||||||
|
fn from_iter<I>(iter: I) -> Self
|
||||||
|
where
|
||||||
|
I: IntoIterator<Item = (CurveBoundary<Point<1>>, T)>,
|
||||||
|
{
|
||||||
|
Self {
|
||||||
|
inner: iter.into_iter().collect(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A payload that can be used in [`CurveBoundaries`]
|
/// A payload that can be used in [`CurveBoundaries`]
|
||||||
pub trait CurveBoundariesPayload: Clone + Ord {
|
pub trait CurveBoundariesPayload: Clone + Ord {
|
||||||
/// Reverse the orientation of the payload
|
/// Reverse the orientation of the payload
|
||||||
|
Loading…
x
Reference in New Issue
Block a user