mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-26 09:05:52 +00:00
Move point conversion out of Polygon
It doesn't need to know about any of that. That it does, only makes testing it more complicated.
This commit is contained in:
parent
6d3e738b65
commit
02643a735f
@ -35,13 +35,23 @@ pub fn triangulate(
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let face_as_polygon = Polygon::new(surface)
|
let face_as_polygon = Polygon::new(surface)
|
||||||
.with_exterior(approx.exterior.points)
|
.with_exterior(approx.exterior.points.into_iter().map(
|
||||||
.with_interiors(
|
|point| {
|
||||||
approx
|
// Can't panic, unless the approximation wrongfully
|
||||||
.interiors
|
// generates points that are not in the surface.
|
||||||
.into_iter()
|
surface.point_model_to_surface(point).native()
|
||||||
.map(|interior| interior.points),
|
},
|
||||||
);
|
))
|
||||||
|
.with_interiors(approx.interiors.into_iter().map(
|
||||||
|
|interior| {
|
||||||
|
interior.points.into_iter().map(|point| {
|
||||||
|
// Can't panic, unless the approximation
|
||||||
|
// wrongfully generates points that are not in
|
||||||
|
// the surface.
|
||||||
|
surface.point_model_to_surface(point).native()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
));
|
||||||
|
|
||||||
let mut triangles = delaunay(points);
|
let mut triangles = delaunay(points);
|
||||||
triangles.retain(|triangle| {
|
triangles.retain(|triangle| {
|
||||||
|
@ -22,13 +22,13 @@ impl Polygon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_exterior(self, exterior: impl Into<PolyChain<3>>) -> Self {
|
pub fn with_exterior(self, exterior: impl Into<PolyChain<2>>) -> Self {
|
||||||
self.with_approx(exterior)
|
self.with_approx(exterior)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_interiors(
|
pub fn with_interiors(
|
||||||
mut self,
|
mut self,
|
||||||
interiors: impl IntoIterator<Item = impl Into<PolyChain<3>>>,
|
interiors: impl IntoIterator<Item = impl Into<PolyChain<2>>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
for interior in interiors {
|
for interior in interiors {
|
||||||
self = self.with_approx(interior);
|
self = self.with_approx(interior);
|
||||||
@ -37,18 +37,14 @@ impl Polygon {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_approx(mut self, approx: impl Into<PolyChain<3>>) -> Self {
|
fn with_approx(mut self, approx: impl Into<PolyChain<2>>) -> Self {
|
||||||
for segment in approx.into().segments() {
|
for segment in approx.into().segments() {
|
||||||
let segment = segment.points().map(|point| {
|
let segment = segment.points().map(|point| {
|
||||||
// Can't panic, unless the approximation wrongfully generates
|
if point > self.max {
|
||||||
// points that are not in the surface.
|
self.max = point;
|
||||||
let point = self.surface.point_model_to_surface(point);
|
|
||||||
|
|
||||||
if point.native() > self.max {
|
|
||||||
self.max = point.native();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
point.native()
|
point
|
||||||
});
|
});
|
||||||
|
|
||||||
let edge = Segment::from(segment);
|
let edge = Segment::from(segment);
|
||||||
|
Loading…
Reference in New Issue
Block a user