This commit is contained in:
Hanno Braun 2022-11-04 15:33:22 +01:00
parent a988da3e5a
commit a79bd1a7c2
2 changed files with 12 additions and 17 deletions

View File

@ -12,22 +12,11 @@ impl TransformObject for PartialCycle {
transform: &Transform, transform: &Transform,
objects: &Objects, objects: &Objects,
) -> Result<Self, ValidationError> { ) -> Result<Self, ValidationError> {
let surface = self
.surface()
.map(|surface| surface.transform(transform, objects))
.transpose()?;
let half_edges = self let half_edges = self
.half_edges() .half_edges()
.map(|edge| { .map(|edge| edge.into_partial().transform(transform, objects))
Ok(edge
.into_partial()
.transform(transform, objects)?
.with_surface(surface.clone()))
})
.collect::<Result<Vec<_>, ValidationError>>()?; .collect::<Result<Vec<_>, ValidationError>>()?;
Ok(Self::default() Ok(Self::default().with_half_edges(half_edges))
.with_surface(surface)
.with_half_edges(half_edges))
} }
} }

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
objects::{Cycle, HalfEdge, Objects, Surface}, objects::{Cycle, HalfEdge, Objects, Surface},
partial::MaybePartial, partial::{util::merge_options, MaybePartial},
storage::Handle, storage::Handle,
validate::ValidationError, validate::ValidationError,
}; };
@ -43,9 +43,15 @@ impl PartialCycle {
mut self, mut self,
half_edges: impl IntoIterator<Item = impl Into<MaybePartial<HalfEdge>>>, half_edges: impl IntoIterator<Item = impl Into<MaybePartial<HalfEdge>>>,
) -> Self { ) -> Self {
self.half_edges let half_edges = half_edges.into_iter().map(Into::into);
.extend(half_edges.into_iter().map(Into::into));
self 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 /// Merge this partial object with another