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

Migrate last piece of code from builder to operations API; remove builder API #1813

Merged
merged 5 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions crates/fj-kernel/src/algorithms/sweep/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ use itertools::Itertools;

use crate::{
algorithms::{reverse::Reverse, transform::TransformObject},
builder::CycleBuilder,
geometry::curve::GlobalPath,
objects::{Face, Shell},
operations::Insert,
objects::{Cycle, Face, Shell},
operations::{BuildCycle, Insert, JoinCycle},
services::Services,
storage::Handle,
};
Expand Down Expand Up @@ -82,13 +81,14 @@ impl Sweep for Handle<Face> {
));
}

let top_cycle = CycleBuilder::connect_to_edges(top_edges, services)
.build(services);
let top_cycle = Cycle::empty()
.add_joined_edges(top_edges, services)
.insert(services);

if i == 0 {
exterior = Some(top_cycle.insert(services));
exterior = Some(top_cycle);
} else {
interiors.push(top_cycle.insert(services));
interiors.push(top_cycle);
};
}

Expand Down
76 changes: 0 additions & 76 deletions crates/fj-kernel/src/builder/cycle.rs

This file was deleted.

5 changes: 0 additions & 5 deletions crates/fj-kernel/src/builder/mod.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/fj-kernel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
#![warn(missing_docs)]

pub mod algorithms;
pub mod builder;
pub mod geometry;
pub mod objects;
pub mod operations;
Expand Down
30 changes: 28 additions & 2 deletions crates/fj-kernel/src/operations/join/cycle.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
use std::ops::RangeInclusive;

use fj_math::Point;
use itertools::Itertools;

use crate::{
objects::Cycle,
operations::{Insert, UpdateCycle, UpdateHalfEdge},
geometry::curve::Curve,
objects::{Cycle, HalfEdge},
operations::{BuildHalfEdge, Insert, UpdateCycle, UpdateHalfEdge},
services::Services,
storage::Handle,
};

/// Join a [`Cycle`] to another
pub trait JoinCycle {
/// Create a cycle that is joined to the provided edges
fn add_joined_edges<Es>(&self, edges: Es, services: &mut Services) -> Self
where
Es: IntoIterator<Item = (Handle<HalfEdge>, Curve, [Point<1>; 2])>,
Es::IntoIter: Clone + ExactSizeIterator;

/// Join the cycle to another
///
/// Joins the cycle to the other at the provided ranges. The ranges specify
Expand Down Expand Up @@ -47,6 +58,21 @@ pub trait JoinCycle {
}

impl JoinCycle for Cycle {
fn add_joined_edges<Es>(&self, edges: Es, services: &mut Services) -> Self
where
Es: IntoIterator<Item = (Handle<HalfEdge>, Curve, [Point<1>; 2])>,
Es::IntoIter: Clone + ExactSizeIterator,
{
self.add_half_edges(edges.into_iter().circular_tuple_windows().map(
|((prev, _, _), (half_edge, curve, boundary))| {
HalfEdge::unjoined(curve, boundary, services)
.replace_start_vertex(prev.start_vertex().clone())
.replace_global_form(half_edge.global_form().clone())
.insert(services)
},
))
}

fn join_to(
&self,
other: &Cycle,
Expand Down