Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert edge builder API into partial edge API #1135

Merged
merged 25 commits into from
Sep 23, 2022
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4f2e39b
Move `builder::edge` to `partial`
hannobraun Sep 22, 2022
12e3453
Derive `Default` for `GlobalEdgeBuilder`
hannobraun Sep 22, 2022
238c24c
Split `GlobalEdgeBuilder` method
hannobraun Sep 22, 2022
1b649d4
Rename `GlobalEdgeBuilder` to `PartialGlobalEdge`
hannobraun Sep 22, 2022
bbcc1e8
Rename `GlobalEdge::builder`
hannobraun Sep 22, 2022
7db7209
Derive full set of traits for `PartialGlobalEdge`
hannobraun Sep 23, 2022
25d3f12
Add conversion to `PartialGlobalEdge`
hannobraun Sep 23, 2022
07016d2
Integrate `PartialGlobalEdge` into `partial` infra
hannobraun Sep 23, 2022
5310c1d
Update documentation of `PartialGlobalEdge`
hannobraun Sep 22, 2022
14381c0
Rename `HalfEdgeBuilder` to `PartialHalfEdge`
hannobraun Sep 22, 2022
ced8d37
Rename `HalfEdge::builder` to `HalfEdge::partial`
hannobraun Sep 22, 2022
6c2d6a5
Pass `Surface` only into the methods that need it
hannobraun Sep 23, 2022
a342528
Make vertices settable separately
hannobraun Sep 23, 2022
73bdcdb
Don't create duplicate vertices in `CycleBuilder`
hannobraun Sep 23, 2022
8a9952d
Simplify `PartialHalfEdge::as_circle_from_radius`
hannobraun Sep 23, 2022
10c1807
Consolidate redundant code
hannobraun Sep 23, 2022
a2aba5e
Simplify `PartialHalfEdge` method
hannobraun Sep 23, 2022
5ac6767
Make `PartialHalfEdge`'s `vertices` more flexible
hannobraun Sep 23, 2022
0481a4d
Make `PartialHalfEdge`'s `curve` more flexible
hannobraun Sep 23, 2022
38d41c6
Pass `&Stores` into `PartialHalfEdge::build`
hannobraun Sep 23, 2022
5c47e5d
Derive `Default` for `PartialHalfEdge`
hannobraun Sep 23, 2022
1b0badb
Derive full set of traits for `PartialHalfEdge`
hannobraun Sep 23, 2022
fcb9c63
Implement conversion to `PartialHalfEdge`
hannobraun Sep 23, 2022
42c12fa
Integrate `PartialHalfEdge` into `partial` infra
hannobraun Sep 23, 2022
7270df9
Update documentation of `PartialHalfEdge`
hannobraun Sep 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Split GlobalEdgeBuilder method
  • Loading branch information
hannobraun committed Sep 23, 2022
commit 238c24c09e53db0180713e52f1157acd5cb914bd
3 changes: 2 additions & 1 deletion crates/fj-kernel/src/algorithms/validate/mod.rs
Original file line number Diff line number Diff line change
@@ -237,7 +237,8 @@ mod tests {
let vertices = [a, b];

let global_edge = GlobalEdge::builder()
.build_from_curve_and_vertices(&curve, &vertices);
.from_curve_and_vertices(&curve, &vertices)
.build(&stores);
let half_edge = HalfEdge::new(curve, vertices, global_edge);

let result =
46 changes: 35 additions & 11 deletions crates/fj-kernel/src/partial/edge.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ use crate::{
SurfaceVertex, Vertex,
},
path::{GlobalPath, SurfacePath},
stores::Stores,
stores::{Handle, Stores},
};

/// API for building a [`HalfEdge`]
@@ -170,7 +170,8 @@ impl<'a> HalfEdgeBuilder<'a> {

let global_form = self.global_form.unwrap_or_else(|| {
GlobalEdge::builder()
.build_from_curve_and_vertices(&curve, &vertices)
.from_curve_and_vertices(&curve, &vertices)
.build(self.stores)
});

HalfEdge::new(curve, vertices, global_form)
@@ -181,18 +182,41 @@ impl<'a> HalfEdgeBuilder<'a> {
///
/// Also see [`GlobalEdge::builder`].
#[derive(Default)]
pub struct GlobalEdgeBuilder;
pub struct GlobalEdgeBuilder {
/// The curve that the [`GlobalEdge`] is defined in
///
/// Must be provided before [`PartialGlobalEdge::build`] is called.
pub curve: Option<Handle<GlobalCurve>>,

/// The vertices that bound the [`GlobalEdge`] in the curve
///
/// Must be provided before [`PartialGlobalEdge::build`] is called.
pub vertices: Option<[GlobalVertex; 2]>,
}

impl GlobalEdgeBuilder {
/// Build a [`GlobalEdge`] from the provided curve and vertices
pub fn build_from_curve_and_vertices(
self,
/// Update partial global edge from the given curve and vertices
pub fn from_curve_and_vertices(
mut self,
curve: &Curve,
vertices: &[Vertex; 2],
) -> GlobalEdge {
GlobalEdge::new(
curve.global_form().clone(),
vertices.clone().map(|vertex| *vertex.global_form()),
)
) -> Self {
self.curve = Some(curve.global_form().clone());
self.vertices =
Some(vertices.clone().map(|vertex| *vertex.global_form()));

self
}

/// Build a full [`GlobalEdge`] from the partial global edge
pub fn build(self, _: &Stores) -> GlobalEdge {
let curve = self
.curve
.expect("Can't build `GlobalEdge` without `GlobalCurve`");
let vertices = self
.vertices
.expect("Can't build `GlobalEdge` without vertices");

GlobalEdge::new(curve, vertices)
}
}