mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-25 17:46:08 +00:00
Move Vertex
to dedicated module
This commit is contained in:
parent
cf30a152fd
commit
87e03ced94
@ -5,7 +5,7 @@ mod sketch;
|
||||
|
||||
pub use self::{
|
||||
operation::{AnyOp, Handle, Operation},
|
||||
primitives::{Triangle, Vertex},
|
||||
primitives::Triangle,
|
||||
shape::Shape,
|
||||
sketch::Sketch,
|
||||
};
|
||||
|
@ -1,6 +1,8 @@
|
||||
use std::{fmt, ops::Deref, rc::Rc};
|
||||
|
||||
use super::{Triangle, Vertex};
|
||||
use crate::topology::Vertex;
|
||||
|
||||
use super::Triangle;
|
||||
|
||||
pub trait Operation: fmt::Display {
|
||||
fn vertices(&self, vertices: &mut Vec<Vertex>);
|
||||
|
@ -1,44 +1,9 @@
|
||||
use std::fmt;
|
||||
|
||||
use crate::math::Point;
|
||||
use crate::{math::Point, topology::Vertex};
|
||||
|
||||
use super::{operation::AnyOp, Operation};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub struct Vertex {
|
||||
pub point: Point<3>,
|
||||
}
|
||||
|
||||
impl<P> From<P> for Vertex
|
||||
where
|
||||
P: Into<Point<3>>,
|
||||
{
|
||||
fn from(point: P) -> Self {
|
||||
Self {
|
||||
point: point.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Vertex {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let [x, y, z] = self.point.coords.components.map(|s| s.value());
|
||||
write!(f, "vertex {x:.2}, {y:.2}, {z:.2}")
|
||||
}
|
||||
}
|
||||
|
||||
impl Operation for Vertex {
|
||||
fn vertices(&self, vertices: &mut Vec<Vertex>) {
|
||||
vertices.push(*self);
|
||||
}
|
||||
|
||||
fn triangles(&self, _: &mut Vec<Triangle>) {}
|
||||
|
||||
fn children(&self) -> Vec<AnyOp> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub struct Triangle {
|
||||
pub vertices: [Point<3>; 3],
|
||||
|
@ -2,11 +2,11 @@ use std::fmt;
|
||||
|
||||
use tuples::CombinRight;
|
||||
|
||||
use crate::storage::Store;
|
||||
use crate::{storage::Store, topology::Vertex};
|
||||
|
||||
use super::{
|
||||
operation::{AnyOp, Handle},
|
||||
Operation, Triangle, Vertex,
|
||||
Operation, Triangle,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -7,6 +7,7 @@ mod math;
|
||||
mod model;
|
||||
mod render;
|
||||
mod storage;
|
||||
mod topology;
|
||||
mod view;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
geometry::{Shape, Sketch, Triangle, Vertex},
|
||||
geometry::{Shape, Sketch, Triangle},
|
||||
math::{Bivector, Plane, Point, Vector},
|
||||
storage::Store,
|
||||
storage::Store, topology::Vertex,
|
||||
};
|
||||
|
||||
pub fn model(shape: &mut Shape) {
|
||||
|
3
experiments/2024-12-09/src/topology/mod.rs
Normal file
3
experiments/2024-12-09/src/topology/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
mod vertex;
|
||||
|
||||
pub use self::vertex::Vertex;
|
41
experiments/2024-12-09/src/topology/vertex.rs
Normal file
41
experiments/2024-12-09/src/topology/vertex.rs
Normal file
@ -0,0 +1,41 @@
|
||||
use std::fmt;
|
||||
|
||||
use crate::{
|
||||
geometry::{AnyOp, Operation, Triangle},
|
||||
math::Point,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub struct Vertex {
|
||||
pub point: Point<3>,
|
||||
}
|
||||
|
||||
impl<P> From<P> for Vertex
|
||||
where
|
||||
P: Into<Point<3>>,
|
||||
{
|
||||
fn from(point: P) -> Self {
|
||||
Self {
|
||||
point: point.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Vertex {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let [x, y, z] = self.point.coords.components.map(|s| s.value());
|
||||
write!(f, "vertex {x:.2}, {y:.2}, {z:.2}")
|
||||
}
|
||||
}
|
||||
|
||||
impl Operation for Vertex {
|
||||
fn vertices(&self, vertices: &mut Vec<Vertex>) {
|
||||
vertices.push(*self);
|
||||
}
|
||||
|
||||
fn triangles(&self, _: &mut Vec<Triangle>) {}
|
||||
|
||||
fn children(&self) -> Vec<AnyOp> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
use std::{fmt, iter};
|
||||
|
||||
use crate::geometry::{AnyOp, Operation, Triangle, Vertex};
|
||||
use crate::{
|
||||
geometry::{AnyOp, Operation, Triangle},
|
||||
topology::Vertex,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct OperationView {
|
||||
|
Loading…
Reference in New Issue
Block a user