Skip to content

Commit

Permalink
Merge pull request #1813 from hannobraun/builder
Browse files Browse the repository at this point in the history
Migrate last piece of code from builder to operations API; remove builder API
  • Loading branch information
hannobraun authored May 4, 2023
2 parents fa02019 + fb77439 commit d7b4fca
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 91 deletions.
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

0 comments on commit d7b4fca

Please sign in to comment.