Skip to content

Commit

Permalink
Merge pull request #1432 from hannobraun/partial
Browse files Browse the repository at this point in the history
Finish replacing old partial object API with new one
  • Loading branch information
hannobraun authored Dec 9, 2022
2 parents 39fadcd + 8ecbabe commit c72eb99
Show file tree
Hide file tree
Showing 55 changed files with 649 additions and 1,412 deletions.
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/approx/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ mod tests {
builder::{CurveBuilder, SurfaceBuilder},
geometry::path::GlobalPath,
insert::Insert,
partial2::{Partial, PartialCurve, PartialObject, PartialSurface},
partial::{Partial, PartialCurve, PartialObject, PartialSurface},
services::Services,
};

Expand Down
6 changes: 4 additions & 2 deletions crates/fj-kernel/src/algorithms/intersect/curve_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ mod tests {
use crate::{
builder::{CurveBuilder, HalfEdgeBuilder},
objects::Vertex,
partial::PartialHalfEdge,
partial2::{Partial, PartialCurve, PartialGlobalEdge, PartialObject},
partial::{
Partial, PartialCurve, PartialGlobalEdge, PartialHalfEdge,
PartialObject,
},
services::Services,
};

Expand Down
6 changes: 2 additions & 4 deletions crates/fj-kernel/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ where
mod tests {
use crate::{
builder::{CurveBuilder, FaceBuilder},
objects::Face,
partial::HasPartial,
partial2::{Partial, PartialCurve, PartialObject},
partial::{Partial, PartialCurve, PartialFace, PartialObject},
services::Services,
};

Expand Down Expand Up @@ -187,7 +185,7 @@ mod tests {
[ 1., -1.],
];

let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(surface.clone(), exterior)
.with_interior_polygon_from_points(surface, interior)
.build(&mut services.objects);
Expand Down
8 changes: 3 additions & 5 deletions crates/fj-kernel/src/algorithms/intersect/face_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ mod tests {
algorithms::intersect::CurveFaceIntersection,
builder::{CurveBuilder, FaceBuilder},
insert::Insert,
objects::Face,
partial::HasPartial,
partial2::{Partial, PartialCurve, PartialObject},
partial::{Partial, PartialCurve, PartialFace, PartialObject},
services::Services,
};

Expand All @@ -95,7 +93,7 @@ mod tests {
services.objects.surfaces.xz_plane(),
]
.map(|surface| {
Face::partial()
PartialFace::default()
.with_exterior_polygon_from_points(surface, points)
.build(&mut services.objects)
});
Expand All @@ -122,7 +120,7 @@ mod tests {
services.objects.surfaces.xz_plane(),
];
let [a, b] = surfaces.clone().map(|surface| {
Face::partial()
PartialFace::default()
.with_exterior_polygon_from_points(surface, points)
.build(&mut services.objects)
});
Expand Down
19 changes: 9 additions & 10 deletions crates/fj-kernel/src/algorithms/intersect/face_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ mod tests {
builder::FaceBuilder,
insert::Insert,
iter::ObjectIters,
objects::Face,
partial::HasPartial,
partial::{PartialFace, PartialObject},
services::Services,
};

Expand All @@ -149,7 +148,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [1., 1.], [0., 2.]],
Expand All @@ -167,7 +166,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 1.], [0., 2.]],
Expand All @@ -188,7 +187,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[4., 2.], [0., 4.], [0., 0.]],
Expand All @@ -209,7 +208,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 1.], [3., 0.], [3., 4.]],
Expand All @@ -230,7 +229,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 1.], [3., 1.], [0., 2.]],
Expand All @@ -251,7 +250,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]],
Expand All @@ -272,7 +271,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 0.], [0., 1.]],
Expand Down Expand Up @@ -302,7 +301,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [1., 0.], [0., 1.]],
Expand Down
17 changes: 8 additions & 9 deletions crates/fj-kernel/src/algorithms/intersect/ray_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ mod tests {
builder::FaceBuilder,
insert::Insert,
iter::ObjectIters,
objects::Face,
partial::HasPartial,
partial::{PartialFace, PartialObject},
services::Services,
};

Expand All @@ -167,7 +166,7 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.yz_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
Expand All @@ -186,7 +185,7 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.yz_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
Expand All @@ -208,7 +207,7 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.yz_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
Expand All @@ -227,7 +226,7 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.yz_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
Expand Down Expand Up @@ -257,7 +256,7 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.yz_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
Expand Down Expand Up @@ -285,7 +284,7 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
Expand All @@ -306,7 +305,7 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ mod tests {
algorithms::transform::TransformObject,
builder::CurveBuilder,
insert::Insert,
partial2::{Partial, PartialCurve, PartialObject},
partial::{Partial, PartialCurve, PartialObject},
services::Services,
};

Expand Down
25 changes: 16 additions & 9 deletions crates/fj-kernel/src/algorithms/reverse/face.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
insert::Insert,
objects::{Face, Objects},
partial::HasPartial,
partial::{FullToPartialCache, Partial, PartialFace, PartialObject},
services::Service,
storage::Handle,
};
Expand All @@ -10,17 +10,24 @@ use super::Reverse;

impl Reverse for Handle<Face> {
fn reverse(self, objects: &mut Service<Objects>) -> Self {
let exterior = self.exterior().clone().reverse(objects);
let mut cache = FullToPartialCache::default();

let exterior = Partial::from_full(
self.exterior().clone().reverse(objects),
&mut cache,
);
let interiors = self
.interiors()
.map(|cycle| cycle.clone().reverse(objects))
.map(|cycle| {
Partial::from_full(cycle.clone().reverse(objects), &mut cache)
})
.collect::<Vec<_>>();

Face::partial()
.with_exterior(exterior)
.with_interiors(interiors)
.with_color(self.color())
.build(objects)
.insert(objects)
let face = PartialFace {
exterior,
interiors,
color: Some(self.color()),
};
face.build(objects).insert(objects)
}
}
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/sweep/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
geometry::path::{GlobalPath, SurfacePath},
insert::Insert,
objects::{Curve, Objects, Surface},
partial2::{PartialObject, PartialSurface},
partial::{PartialObject, PartialSurface},
services::Service,
storage::Handle,
};
Expand Down
29 changes: 16 additions & 13 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
Curve, Cycle, Face, GlobalEdge, HalfEdge, Objects, SurfaceVertex,
Vertex,
},
partial::HasPartial,
partial::{Partial, PartialFace, PartialObject},
services::Service,
storage::Handle,
};
Expand Down Expand Up @@ -174,11 +174,12 @@ impl Sweep for (Handle<HalfEdge>, Color) {
Cycle::new(edges).insert(objects)
};

Face::partial()
.with_exterior(cycle)
.with_color(color)
.build(objects)
.insert(objects)
let face = PartialFace {
exterior: Partial::from_full_entry_point(cycle),
color: Some(color),
..Default::default()
};
face.build(objects).insert(objects)
}
}

Expand All @@ -193,10 +194,10 @@ mod tests {
algorithms::{reverse::Reverse, sweep::Sweep},
builder::HalfEdgeBuilder,
insert::Insert,
objects::{Cycle, Face, Vertex},
partial::{HasPartial, PartialHalfEdge},
partial2::{
Partial, PartialCurve, PartialGlobalEdge, PartialSurfaceVertex,
objects::{Cycle, Vertex},
partial::{
Partial, PartialCurve, PartialFace, PartialGlobalEdge,
PartialHalfEdge, PartialObject, PartialSurfaceVertex,
PartialVertex,
},
services::Services,
Expand Down Expand Up @@ -418,9 +419,11 @@ mod tests {
let cycle = Cycle::new([bottom, side_up, top, side_down])
.insert(&mut services.objects);

Face::partial()
.with_exterior(cycle)
.build(&mut services.objects)
let face = PartialFace {
exterior: Partial::from_full_entry_point(cycle),
..Default::default()
};
face.build(&mut services.objects)
.insert(&mut services.objects)
};

Expand Down
16 changes: 9 additions & 7 deletions crates/fj-kernel/src/algorithms/sweep/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ mod tests {
algorithms::{reverse::Reverse, transform::TransformObject},
builder::{FaceBuilder, HalfEdgeBuilder},
insert::Insert,
objects::{Face, Sketch, Vertex},
partial::{HasPartial, PartialHalfEdge},
partial2::{Partial, PartialGlobalEdge},
objects::{Sketch, Vertex},
partial::{
Partial, PartialFace, PartialGlobalEdge, PartialHalfEdge,
PartialObject,
},
services::Services,
};

Expand All @@ -118,12 +120,12 @@ mod tests {
.build(&mut services.objects)
.sweep(UP, &mut services.objects);

let bottom = Face::partial()
let bottom = PartialFace::default()
.with_exterior_polygon_from_points(surface.clone(), TRIANGLE)
.build(&mut services.objects)
.insert(&mut services.objects)
.reverse(&mut services.objects);
let top = Face::partial()
let top = PartialFace::default()
.with_exterior_polygon_from_points(
surface.translate(UP, &mut services.objects),
TRIANGLE,
Expand Down Expand Up @@ -186,15 +188,15 @@ mod tests {
.build(&mut services.objects)
.sweep(DOWN, &mut services.objects);

let bottom = Face::partial()
let bottom = PartialFace::default()
.with_exterior_polygon_from_points(
surface.clone().translate(DOWN, &mut services.objects),
TRIANGLE,
)
.build(&mut services.objects)
.insert(&mut services.objects)
.reverse(&mut services.objects);
let top = Face::partial()
let top = PartialFace::default()
.with_exterior_polygon_from_points(surface, TRIANGLE)
.build(&mut services.objects)
.insert(&mut services.objects);
Expand Down
Loading

0 comments on commit c72eb99

Please sign in to comment.