Avoid using Plane with Handle

`Plane` is not an operation (i.e. it doesn't implement the `Operation`
trait), and I'm working on change that will restrict `Handle` to working
with operations.
This commit is contained in:
Hanno Braun 2025-02-10 20:07:14 +01:00
parent e1daf4ba91
commit a3d9ea4674
4 changed files with 9 additions and 10 deletions

View File

@ -10,7 +10,7 @@ pub struct Sketch {
}
impl Sketch {
pub fn to_face(&self, surface: Handle<Plane>) -> Face {
pub fn to_face(&self, surface: Plane) -> Face {
let vertices = self
.points
.iter()

View File

@ -9,13 +9,13 @@ pub fn model() -> AnyOp {
let sketch =
Sketch::from([[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5], [-0.5, 0.5]]);
let surface = Handle::new(Plane {
let surface = Plane {
origin: Point::from([0., 0., 0.5]),
coords: Bivector {
a: Vector::from([1., 0., 0.]),
b: Vector::from([0., 1., 0.]),
},
});
};
sketch.to_face(surface)
};

View File

@ -39,9 +39,8 @@ impl ConnectExt for Handle<Face> {
.half_edges()
.zip(other.half_edges())
.map(|([q, r], [t, s])| {
let surface = Handle::new(Plane::from_points(
[q, r, s].map(|vertex| vertex.point),
));
let surface =
Plane::from_points([q, r, s].map(|vertex| vertex.point));
let face = Face::new(
surface,
[q, r, s, t].map(|vertex| vertex.clone()),

View File

@ -12,13 +12,13 @@ use super::vertex::Vertex;
#[derive(Debug)]
pub struct Face {
surface: Handle<Plane>,
surface: Plane,
vertices: Vec<Handle<Vertex>>,
}
impl Face {
pub fn new(
surface: Handle<Plane>,
surface: Plane,
vertices: impl IntoIterator<Item = Handle<Vertex>>,
) -> Self {
Self {
@ -41,7 +41,7 @@ impl Face {
pub fn flip(&self) -> Self {
Self {
surface: Handle::new(self.surface.flip()),
surface: self.surface.flip(),
vertices: self.vertices.clone(),
}
}
@ -50,7 +50,7 @@ impl Face {
let offset = offset.into();
Self {
surface: Handle::new(self.surface.translate(offset)),
surface: self.surface.translate(offset),
vertices: self
.vertices
.iter()