Skip to content

Commit

Permalink
Refactor to prepare for follow-on change
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Nov 24, 2023
1 parent 417d17d commit 9da808e
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions crates/fj-core/src/operations/sweep/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ use fj_math::{Scalar, Vector};
use crate::{
algorithms::transform::TransformObject,
geometry::GlobalPath,
objects::{Face, Region, Shell},
objects::{Cycle, Face, Region, Shell},
operations::{insert::Insert, reverse::Reverse},
services::Services,
storage::Handle,
};

use super::{SweepCache, SweepCycle};
Expand Down Expand Up @@ -59,25 +60,19 @@ impl SweepFace for Face {
let mut top_interiors = Vec::new();

for (i, bottom_cycle) in bottom_face.region().all_cycles().enumerate() {
let swept_cycle = bottom_cycle.reverse(services).sweep_cycle(
bottom_face.surface(),
bottom_face.region().color(),
let top_cycle = sweep_cycle(
bottom_cycle,
&bottom_face,
&mut faces,
path,
cache,
services,
);

faces.extend(
swept_cycle
.faces
.into_iter()
.map(|side_face| side_face.insert(services)),
);

if i == 0 {
top_exterior = Some(swept_cycle.top_cycle.insert(services));
top_exterior = Some(top_cycle);
} else {
top_interiors.push(swept_cycle.top_cycle.insert(services));
top_interiors.push(top_cycle);
};
}

Expand Down Expand Up @@ -117,3 +112,29 @@ fn bottom_face(face: &Face, path: Vector<3>, services: &mut Services) -> Face {
face.reverse(services)
}
}

fn sweep_cycle(
bottom_cycle: &Cycle,
bottom_face: &Face,
faces: &mut Vec<Handle<Face>>,
path: Vector<3>,
cache: &mut SweepCache,
services: &mut Services,
) -> Handle<Cycle> {
let swept_cycle = bottom_cycle.reverse(services).sweep_cycle(
bottom_face.surface(),
bottom_face.region().color(),
path,
cache,
services,
);

faces.extend(
swept_cycle
.faces
.into_iter()
.map(|side_face| side_face.insert(services)),
);

swept_cycle.top_cycle.insert(services)
}

0 comments on commit 9da808e

Please sign in to comment.