mirror of
https://github.com/hannobraun/Fornjot
synced 2025-10-13 03:18:02 +00:00
Prepare to lift fmt::Display
requirement
This commit is contained in:
parent
62e5e8db95
commit
183d834b3d
@ -3,6 +3,7 @@ use std::{fmt, ops::Deref, rc::Rc};
|
|||||||
use super::tri_mesh::TriMesh;
|
use super::tri_mesh::TriMesh;
|
||||||
|
|
||||||
pub trait Operation: fmt::Display {
|
pub trait Operation: fmt::Display {
|
||||||
|
fn label(&self) -> &'static str;
|
||||||
fn tri_mesh(&self) -> TriMesh;
|
fn tri_mesh(&self) -> TriMesh;
|
||||||
fn children(&self) -> Vec<AnyOp>;
|
fn children(&self) -> Vec<AnyOp>;
|
||||||
}
|
}
|
||||||
@ -68,6 +69,10 @@ impl fmt::Display for AnyOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Operation for AnyOp {
|
impl Operation for AnyOp {
|
||||||
|
fn label(&self) -> &'static str {
|
||||||
|
self.inner.label()
|
||||||
|
}
|
||||||
|
|
||||||
fn tri_mesh(&self) -> TriMesh {
|
fn tri_mesh(&self) -> TriMesh {
|
||||||
self.inner.tri_mesh()
|
self.inner.tri_mesh()
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,10 @@ impl fmt::Display for Shape {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Operation for Shape {
|
impl Operation for Shape {
|
||||||
|
fn label(&self) -> &'static str {
|
||||||
|
"Shape"
|
||||||
|
}
|
||||||
|
|
||||||
fn tri_mesh(&self) -> TriMesh {
|
fn tri_mesh(&self) -> TriMesh {
|
||||||
if let Some(op) = self.sequence.last() {
|
if let Some(op) = self.sequence.last() {
|
||||||
op.tri_mesh()
|
op.tri_mesh()
|
||||||
@ -54,6 +58,10 @@ struct OperationInSequence {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Operation for OperationInSequence {
|
impl Operation for OperationInSequence {
|
||||||
|
fn label(&self) -> &'static str {
|
||||||
|
self.operation.label()
|
||||||
|
}
|
||||||
|
|
||||||
fn tri_mesh(&self) -> TriMesh {
|
fn tri_mesh(&self) -> TriMesh {
|
||||||
let mesh = if let Some(op) = &self.previous {
|
let mesh = if let Some(op) = &self.previous {
|
||||||
op.tri_mesh()
|
op.tri_mesh()
|
||||||
|
@ -27,6 +27,10 @@ impl fmt::Display for Triangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Operation for Triangle {
|
impl Operation for Triangle {
|
||||||
|
fn label(&self) -> &'static str {
|
||||||
|
"Triangle"
|
||||||
|
}
|
||||||
|
|
||||||
fn tri_mesh(&self) -> TriMesh {
|
fn tri_mesh(&self) -> TriMesh {
|
||||||
TriMesh {
|
TriMesh {
|
||||||
triangles: vec![self.clone()],
|
triangles: vec![self.clone()],
|
||||||
|
@ -47,6 +47,10 @@ impl fmt::Display for Face {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Operation for Face {
|
impl Operation for Face {
|
||||||
|
fn label(&self) -> &'static str {
|
||||||
|
"Face"
|
||||||
|
}
|
||||||
|
|
||||||
fn tri_mesh(&self) -> TriMesh {
|
fn tri_mesh(&self) -> TriMesh {
|
||||||
// This is a placeholder implementation that only supports convex faces.
|
// This is a placeholder implementation that only supports convex faces.
|
||||||
|
|
||||||
|
@ -29,6 +29,10 @@ impl fmt::Display for Vertex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Operation for Vertex {
|
impl Operation for Vertex {
|
||||||
|
fn label(&self) -> &'static str {
|
||||||
|
"Vertex"
|
||||||
|
}
|
||||||
|
|
||||||
fn tri_mesh(&self) -> TriMesh {
|
fn tri_mesh(&self) -> TriMesh {
|
||||||
TriMesh::new()
|
TriMesh::new()
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,10 @@ impl fmt::Display for OperationView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Operation for OperationView {
|
impl Operation for OperationView {
|
||||||
|
fn label(&self) -> &'static str {
|
||||||
|
self.operation.label()
|
||||||
|
}
|
||||||
|
|
||||||
fn tri_mesh(&self) -> TriMesh {
|
fn tri_mesh(&self) -> TriMesh {
|
||||||
self.operation.tri_mesh()
|
self.operation.tri_mesh()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user