Skip to content

Commit

Permalink
Update name of trait method
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Jan 15, 2025
1 parent 79d19fb commit 86b0415
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion experiments/2024-12-09/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions experiments/2024-12-09/src/geometry/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}

Expand Down Expand Up @@ -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> {
Expand Down
10 changes: 5 additions & 5 deletions experiments/2024-12-09/src/geometry/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion experiments/2024-12-09/src/geometry/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
}
Expand Down
2 changes: 1 addition & 1 deletion experiments/2024-12-09/src/render/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion experiments/2024-12-09/src/topology/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion experiments/2024-12-09/src/topology/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl fmt::Display for Vertex {
}

impl Operation for Vertex {
fn triangles(&self) -> TriMesh {
fn tri_mesh(&self) -> TriMesh {
TriMesh::new()
}

Expand Down
4 changes: 2 additions & 2 deletions experiments/2024-12-09/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit 86b0415

Please sign in to comment.