mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-05 02:18:28 +00:00
Prepare to support curved surfaces
This commit is contained in:
parent
e593aa9760
commit
4a108d7b0a
@ -1,9 +1,11 @@
|
||||
mod sketch;
|
||||
mod surface;
|
||||
mod tri_mesh;
|
||||
mod triangle;
|
||||
|
||||
pub use self::{
|
||||
sketch::Sketch,
|
||||
surface::SurfaceGeometry,
|
||||
tri_mesh::{MeshTriangle, TriMesh},
|
||||
triangle::Triangle,
|
||||
};
|
||||
|
26
experiments/2024-12-09/src/geometry/surface.rs
Normal file
26
experiments/2024-12-09/src/geometry/surface.rs
Normal file
@ -0,0 +1,26 @@
|
||||
use crate::math::{Plane, Point, Vector};
|
||||
|
||||
pub trait SurfaceGeometry {
|
||||
fn point_from_local(&self, point: Point<2>) -> Point<3>;
|
||||
fn project_point(&self, point: Point<3>) -> Point<2>;
|
||||
fn flip(&self) -> Box<dyn SurfaceGeometry>;
|
||||
fn translate(&self, offset: Vector<3>) -> Box<dyn SurfaceGeometry>;
|
||||
}
|
||||
|
||||
impl SurfaceGeometry for Plane {
|
||||
fn point_from_local(&self, point: Point<2>) -> Point<3> {
|
||||
self.point_from_local(point)
|
||||
}
|
||||
|
||||
fn project_point(&self, point: Point<3>) -> Point<2> {
|
||||
self.project_point(point)
|
||||
}
|
||||
|
||||
fn flip(&self) -> Box<dyn SurfaceGeometry> {
|
||||
Box::new((*self).flip())
|
||||
}
|
||||
|
||||
fn translate(&self, offset: Vector<3>) -> Box<dyn SurfaceGeometry> {
|
||||
Box::new((*self).translate(offset))
|
||||
}
|
||||
}
|
@ -27,13 +27,13 @@ pub fn model() -> HandleAny {
|
||||
]);
|
||||
|
||||
let surface = Handle::new(Surface {
|
||||
geometry: Plane {
|
||||
geometry: Box::new(Plane {
|
||||
origin: Point::from([0., 0., 1.]),
|
||||
coords: Bivector {
|
||||
a: Vector::from([1., 0., 0.]),
|
||||
b: Vector::from([0., 1., 0.]),
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
let face = sketch.to_face(surface);
|
||||
|
@ -53,9 +53,9 @@ impl ConnectExt for Handle<Face> {
|
||||
};
|
||||
|
||||
let surface = Handle::new(Surface {
|
||||
geometry: Plane::from_points(
|
||||
geometry: Box::new(Plane::from_points(
|
||||
[&q.start, r, s].map(|vertex| vertex.point),
|
||||
),
|
||||
)),
|
||||
});
|
||||
let face = Face::new(
|
||||
surface,
|
||||
|
@ -1,15 +1,15 @@
|
||||
use std::fmt;
|
||||
|
||||
use crate::math::Plane;
|
||||
use crate::geometry::SurfaceGeometry;
|
||||
|
||||
pub struct Surface {
|
||||
pub geometry: Plane,
|
||||
pub geometry: Box<dyn SurfaceGeometry>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Surface {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Surface")
|
||||
.field("geometry", &self.geometry)
|
||||
.field("geometry", &"Box<dyn SurfaceGeometry>")
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user