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

Provide Handle<Surface> to sweep code #2299

Merged
merged 4 commits into from
Mar 26, 2024
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
4 changes: 2 additions & 2 deletions crates/fj-core/src/operations/holes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl AddHole for Shell {
core,
)
.sweep_region(
location.face.surface(),
location.face.surface().clone(),
None,
path,
&mut SweepCache::default(),
Expand Down Expand Up @@ -113,7 +113,7 @@ impl AddHole for Shell {
core,
)
.sweep_region(
entry_location.face.surface(),
entry_location.face.surface().clone(),
None,
path,
&mut SweepCache::default(),
Expand Down
10 changes: 5 additions & 5 deletions crates/fj-core/src/operations/sweep/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use fj_interop::Color;
use fj_math::Vector;

use crate::{
geometry::SurfaceGeometry,
operations::{
build::BuildCycle, join::JoinCycle, sweep::half_edge::SweepHalfEdge,
},
topology::{Cycle, Face},
storage::Handle,
topology::{Cycle, Face, Surface},
Core,
};

Expand Down Expand Up @@ -38,7 +38,7 @@ pub trait SweepCycle {
/// operation is called in, and therefore falls outside of its scope.
fn sweep_cycle(
&self,
surface: &SurfaceGeometry,
surface: Handle<Surface>,
color: Option<Color>,
path: impl Into<Vector<3>>,
cache: &mut SweepCache,
Expand All @@ -49,7 +49,7 @@ pub trait SweepCycle {
impl SweepCycle for Cycle {
fn sweep_cycle(
&self,
surface: &SurfaceGeometry,
surface: Handle<Surface>,
color: Option<Color>,
path: impl Into<Vector<3>>,
cache: &mut SweepCache,
Expand All @@ -66,7 +66,7 @@ impl SweepCycle for Cycle {

let (side_face, top_edge) = bottom_half_edge.sweep_half_edge(
bottom_half_edge_next.start_vertex().clone(),
surface,
surface.clone(),
color,
path,
cache,
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-core/src/operations/sweep/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl SweepFace for Handle<Face> {
let other_faces = bottom_face
.region()
.sweep_region(
bottom_face.surface(),
bottom_face.surface().clone(),
bottom_face.region().get_color(core),
path,
cache,
Expand Down
13 changes: 8 additions & 5 deletions crates/fj-core/src/operations/sweep/half_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use fj_interop::{ext::ArrayExt, Color};
use fj_math::{Point, Scalar, Vector};

use crate::{
geometry::SurfaceGeometry,
operations::{
build::{BuildCycle, BuildHalfEdge},
geometry::UpdateHalfEdgeGeometry,
Expand All @@ -11,7 +10,7 @@ use crate::{
update::{UpdateCycle, UpdateHalfEdge},
},
storage::Handle,
topology::{Cycle, Face, HalfEdge, Region, Vertex},
topology::{Cycle, Face, HalfEdge, Region, Surface, Vertex},
Core,
};

Expand Down Expand Up @@ -39,7 +38,7 @@ pub trait SweepHalfEdge {
fn sweep_half_edge(
&self,
end_vertex: Handle<Vertex>,
surface: &SurfaceGeometry,
surface: Handle<Surface>,
color: Option<Color>,
path: impl Into<Vector<3>>,
cache: &mut SweepCache,
Expand All @@ -51,7 +50,7 @@ impl SweepHalfEdge for Handle<HalfEdge> {
fn sweep_half_edge(
&self,
end_vertex: Handle<Vertex>,
surface: &SurfaceGeometry,
surface: Handle<Surface>,
color: Option<Color>,
path: impl Into<Vector<3>>,
cache: &mut SweepCache,
Expand All @@ -60,7 +59,11 @@ impl SweepHalfEdge for Handle<HalfEdge> {
let path = path.into();

let geometry = core.layers.geometry.of_half_edge(self);
let surface = geometry.path.sweep_surface_path(surface, path, core);
let surface = geometry.path.sweep_surface_path(
&core.layers.geometry.of_surface(&surface),
path,
core,
);

// Next, we need to define the boundaries of the face. Let's start with
// the global vertices and edges.
Expand Down
11 changes: 5 additions & 6 deletions crates/fj-core/src/operations/sweep/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use fj_interop::Color;
use fj_math::Vector;

use crate::{
geometry::SurfaceGeometry,
operations::{
insert::Insert, reverse::Reverse, transform::TransformObject,
},
Expand Down Expand Up @@ -32,7 +31,7 @@ pub trait SweepRegion {
/// operation's scope.
fn sweep_region(
&self,
surface: &Handle<Surface>,
surface: Handle<Surface>,
color: Option<Color>,
path: impl Into<Vector<3>>,
cache: &mut SweepCache,
Expand All @@ -43,7 +42,7 @@ pub trait SweepRegion {
impl SweepRegion for Region {
fn sweep_region(
&self,
surface: &Handle<Surface>,
surface: Handle<Surface>,
color: Option<Color>,
path: impl Into<Vector<3>>,
cache: &mut SweepCache,
Expand All @@ -55,7 +54,7 @@ impl SweepRegion for Region {

let top_exterior = sweep_cycle(
self.exterior(),
&core.layers.geometry.of_surface(surface),
surface.clone(),
color,
&mut faces,
path,
Expand All @@ -69,7 +68,7 @@ impl SweepRegion for Region {
.map(|bottom_cycle| {
sweep_cycle(
bottom_cycle,
&core.layers.geometry.of_surface(surface),
surface.clone(),
color,
&mut faces,
path,
Expand All @@ -96,7 +95,7 @@ impl SweepRegion for Region {

fn sweep_cycle(
bottom_cycle: &Cycle,
bottom_surface: &SurfaceGeometry,
bottom_surface: Handle<Surface>,
color: Option<Color>,
faces: &mut Vec<Face>,
path: Vector<3>,
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-core/src/operations/sweep/shell_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl SweepFaceOfShell for Shell {
.derive_from(face.region().exterior(), core);
let region = Region::new(exterior, []);
let swept_region = region.sweep_region(
face.surface(),
face.surface().clone(),
face.region().get_color(core),
path,
&mut cache,
Expand Down