Update name of trait method

This commit is contained in:
Hanno Braun 2025-01-15 20:44:55 +01:00
parent 79d19fbc49
commit 86b0415791
8 changed files with 15 additions and 15 deletions

View File

@ -3,7 +3,7 @@ use std::{collections::BTreeMap, fs::File};
use crate::geometry::{Operation, Shape};
pub fn export(shape: &Shape) -> anyhow::Result<()> {
let tri_mesh = shape.triangles();
let tri_mesh = shape.tri_mesh();
let mut indices_by_vertex = BTreeMap::new();

View File

@ -3,7 +3,7 @@ use std::{fmt, ops::Deref, rc::Rc};
use super::tri_mesh::TriMesh;
pub trait Operation: fmt::Display {
fn triangles(&self) -> TriMesh;
fn tri_mesh(&self) -> TriMesh;
fn children(&self) -> Vec<AnyOp>;
}
@ -68,8 +68,8 @@ impl fmt::Display for AnyOp {
}
impl Operation for AnyOp {
fn triangles(&self) -> TriMesh {
self.inner.triangles()
fn tri_mesh(&self) -> TriMesh {
self.inner.tri_mesh()
}
fn children(&self) -> Vec<AnyOp> {

View File

@ -31,9 +31,9 @@ impl fmt::Display for Shape {
}
impl Operation for Shape {
fn triangles(&self) -> TriMesh {
fn tri_mesh(&self) -> TriMesh {
if let Some(op) = self.sequence.last() {
op.triangles()
op.tri_mesh()
} else {
TriMesh::new()
}
@ -54,14 +54,14 @@ struct OperationInSequence {
}
impl Operation for OperationInSequence {
fn triangles(&self) -> TriMesh {
fn tri_mesh(&self) -> TriMesh {
let mesh = if let Some(op) = &self.previous {
op.triangles()
op.tri_mesh()
} else {
TriMesh::new()
};
mesh.merge(self.operation.triangles())
mesh.merge(self.operation.tri_mesh())
}
fn children(&self) -> Vec<AnyOp> {

View File

@ -27,7 +27,7 @@ impl fmt::Display for Triangle {
}
impl Operation for Triangle {
fn triangles(&self) -> TriMesh {
fn tri_mesh(&self) -> TriMesh {
TriMesh {
triangles: vec![self.clone()],
}

View File

@ -13,7 +13,7 @@ pub struct Geometry {
impl Geometry {
pub fn new(device: &wgpu::Device, operation: &dyn Operation) -> Self {
let tri_mesh = operation.triangles();
let tri_mesh = operation.tri_mesh();
let mut indices = Vec::new();
let mut vertices = Vec::new();

View File

@ -43,7 +43,7 @@ impl fmt::Display for Face {
}
impl Operation for Face {
fn triangles(&self) -> TriMesh {
fn tri_mesh(&self) -> TriMesh {
// This is a placeholder implementation that only supports convex faces.
let mut triangulation =

View File

@ -29,7 +29,7 @@ impl fmt::Display for Vertex {
}
impl Operation for Vertex {
fn triangles(&self) -> TriMesh {
fn tri_mesh(&self) -> TriMesh {
TriMesh::new()
}

View File

@ -128,8 +128,8 @@ impl fmt::Display for OperationView {
}
impl Operation for OperationView {
fn triangles(&self) -> TriMesh {
self.operation.triangles()
fn tri_mesh(&self) -> TriMesh {
self.operation.tri_mesh()
}
fn children(&self) -> Vec<AnyOp> {