mirror of https://github.com/hannobraun/Fornjot
Refactor
This commit is contained in:
parent
a988da3e5a
commit
a79bd1a7c2
|
@ -12,22 +12,11 @@ impl TransformObject for PartialCycle {
|
|||
transform: &Transform,
|
||||
objects: &Objects,
|
||||
) -> Result<Self, ValidationError> {
|
||||
let surface = self
|
||||
.surface()
|
||||
.map(|surface| surface.transform(transform, objects))
|
||||
.transpose()?;
|
||||
let half_edges = self
|
||||
.half_edges()
|
||||
.map(|edge| {
|
||||
Ok(edge
|
||||
.into_partial()
|
||||
.transform(transform, objects)?
|
||||
.with_surface(surface.clone()))
|
||||
})
|
||||
.map(|edge| edge.into_partial().transform(transform, objects))
|
||||
.collect::<Result<Vec<_>, ValidationError>>()?;
|
||||
|
||||
Ok(Self::default()
|
||||
.with_surface(surface)
|
||||
.with_half_edges(half_edges))
|
||||
Ok(Self::default().with_half_edges(half_edges))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
objects::{Cycle, HalfEdge, Objects, Surface},
|
||||
partial::MaybePartial,
|
||||
partial::{util::merge_options, MaybePartial},
|
||||
storage::Handle,
|
||||
validate::ValidationError,
|
||||
};
|
||||
|
@ -43,9 +43,15 @@ impl PartialCycle {
|
|||
mut self,
|
||||
half_edges: impl IntoIterator<Item = impl Into<MaybePartial<HalfEdge>>>,
|
||||
) -> Self {
|
||||
self.half_edges
|
||||
.extend(half_edges.into_iter().map(Into::into));
|
||||
self
|
||||
let half_edges = half_edges.into_iter().map(Into::into);
|
||||
|
||||
let mut surface = self.surface();
|
||||
for half_edge in half_edges {
|
||||
surface = merge_options(surface, half_edge.curve().surface());
|
||||
self.half_edges.push(half_edge);
|
||||
}
|
||||
|
||||
self.with_surface(surface)
|
||||
}
|
||||
|
||||
/// Merge this partial object with another
|
||||
|
|
Loading…
Reference in New Issue