mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-26 09:05:52 +00:00
Replace Edge::circle
with Edges::add_circle
See previous commit for an explanation.
This commit is contained in:
parent
8a578e3782
commit
a88476d3e6
@ -1,6 +1,9 @@
|
|||||||
use crate::kernel::{
|
use crate::{
|
||||||
geometry::{Curve, Line},
|
kernel::{
|
||||||
|
geometry::{Curve, Line, Circle},
|
||||||
topology::{edges::Edge, vertices::Vertex},
|
topology::{edges::Edge, vertices::Vertex},
|
||||||
|
},
|
||||||
|
math::{Scalar, Vector, Point},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::handle::{Handle, Storage};
|
use super::handle::{Handle, Storage};
|
||||||
@ -27,6 +30,20 @@ impl Edges {
|
|||||||
Storage::new(edge).handle()
|
Storage::new(edge).handle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add a circle to the shape
|
||||||
|
///
|
||||||
|
/// Calls [`Edges::add`] internally, and is subject to the same
|
||||||
|
/// restrictions.
|
||||||
|
pub fn add_circle(&mut self, radius: Scalar) -> Handle<Edge> {
|
||||||
|
self.add(Edge {
|
||||||
|
curve: Curve::Circle(Circle {
|
||||||
|
center: Point::origin(),
|
||||||
|
radius: Vector::from([radius, Scalar::ZERO]),
|
||||||
|
}),
|
||||||
|
vertices: None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/// Add a line segment to the shape
|
/// Add a line segment to the shape
|
||||||
///
|
///
|
||||||
/// Calls [`Edges::add`] internally, and is subject to the same
|
/// Calls [`Edges::add`] internally, and is subject to the same
|
||||||
|
@ -3,10 +3,7 @@ use crate::{
|
|||||||
kernel::{
|
kernel::{
|
||||||
geometry::Surface,
|
geometry::Surface,
|
||||||
shape::Shape,
|
shape::Shape,
|
||||||
topology::{
|
topology::{edges::Cycle, faces::Face},
|
||||||
edges::{Cycle, Edge},
|
|
||||||
faces::Face,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
math::{Aabb, Point, Scalar},
|
math::{Aabb, Point, Scalar},
|
||||||
};
|
};
|
||||||
@ -20,9 +17,7 @@ impl ToShape for fj::Circle {
|
|||||||
// Circles have just a single round edge with no vertices. So none need
|
// Circles have just a single round edge with no vertices. So none need
|
||||||
// to be added here.
|
// to be added here.
|
||||||
|
|
||||||
let edge = shape
|
let edge = shape.edges().add_circle(Scalar::from_f64(self.radius));
|
||||||
.edges()
|
|
||||||
.add(Edge::circle(Scalar::from_f64(self.radius)));
|
|
||||||
shape.cycles().add(Cycle { edges: vec![edge] });
|
shape.cycles().add(Cycle { edges: vec![edge] });
|
||||||
|
|
||||||
let cycles = shape.cycles().all().collect();
|
let cycles = shape.cycles().all().collect();
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
use crate::{
|
use crate::kernel::{geometry::Curve, shape::handle::Handle};
|
||||||
kernel::{
|
|
||||||
geometry::{Circle, Curve},
|
|
||||||
shape::handle::Handle,
|
|
||||||
},
|
|
||||||
math::{Point, Scalar, Vector},
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::vertices::Vertex;
|
use super::vertices::Vertex;
|
||||||
|
|
||||||
@ -44,16 +38,3 @@ pub struct Edge {
|
|||||||
/// and store 1D vertices again, at some point.
|
/// and store 1D vertices again, at some point.
|
||||||
pub vertices: Option<[Handle<Vertex>; 2]>,
|
pub vertices: Option<[Handle<Vertex>; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Edge {
|
|
||||||
/// Create a circle
|
|
||||||
pub fn circle(radius: Scalar) -> Self {
|
|
||||||
Edge {
|
|
||||||
curve: Curve::Circle(Circle {
|
|
||||||
center: Point::origin(),
|
|
||||||
radius: Vector::from([radius, Scalar::ZERO]),
|
|
||||||
}),
|
|
||||||
vertices: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user