Merge pull request #1198 from hannobraun/objects

Rename `Stores` to `Objects`, move it to `Objects`
This commit is contained in:
Hanno Braun 2022-10-10 20:08:26 +02:00 committed by GitHub
commit bbddc4bc2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 552 additions and 528 deletions

View File

@ -14,7 +14,7 @@ use std::collections::BTreeMap;
use crate::{ use crate::{
objects::{Curve, GlobalCurve}, objects::{Curve, GlobalCurve},
path::{GlobalPath, SurfacePath}, path::{GlobalPath, SurfacePath},
stores::{Handle, ObjectId}, storage::{Handle, ObjectId},
}; };
use super::{path::RangeOnPath, Approx, ApproxPoint, Tolerance}; use super::{path::RangeOnPath, Approx, ApproxPoint, Tolerance};
@ -197,25 +197,25 @@ mod tests {
use crate::{ use crate::{
algorithms::approx::{path::RangeOnPath, Approx, ApproxPoint}, algorithms::approx::{path::RangeOnPath, Approx, ApproxPoint},
objects::{Curve, Surface}, objects::{Curve, Objects, Surface},
partial::HasPartial, partial::HasPartial,
path::GlobalPath, path::GlobalPath,
stores::{Handle, Stores}, storage::Handle,
}; };
use super::CurveApprox; use super::CurveApprox;
#[test] #[test]
fn approx_line_on_flat_surface() { fn approx_line_on_flat_surface() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores let surface = objects
.surfaces .surfaces
.insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.])); .insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.]));
let curve = Handle::<Curve>::partial() let curve = Handle::<Curve>::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.as_line_from_points([[1., 1.], [2., 1.]]) .as_line_from_points([[1., 1.], [2., 1.]])
.build(&stores); .build(&objects);
let range = RangeOnPath::from([[0.], [1.]]); let range = RangeOnPath::from([[0.], [1.]]);
let approx = (&curve, range).approx(1.); let approx = (&curve, range).approx(1.);
@ -225,16 +225,16 @@ mod tests {
#[test] #[test]
fn approx_line_on_curved_surface_but_not_along_curve() { fn approx_line_on_curved_surface_but_not_along_curve() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::new( let surface = objects.surfaces.insert(Surface::new(
GlobalPath::circle_from_radius(1.), GlobalPath::circle_from_radius(1.),
[0., 0., 1.], [0., 0., 1.],
)); ));
let curve = Handle::<Curve>::partial() let curve = Handle::<Curve>::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.as_line_from_points([[1., 1.], [1., 2.]]) .as_line_from_points([[1., 1.], [1., 2.]])
.build(&stores); .build(&objects);
let range = RangeOnPath::from([[0.], [1.]]); let range = RangeOnPath::from([[0.], [1.]]);
let approx = (&curve, range).approx(1.); let approx = (&curve, range).approx(1.);
@ -244,14 +244,14 @@ mod tests {
#[test] #[test]
fn approx_line_on_curved_surface_along_curve() { fn approx_line_on_curved_surface_along_curve() {
let stores = Stores::new(); let objects = Objects::new();
let path = GlobalPath::circle_from_radius(1.); let path = GlobalPath::circle_from_radius(1.);
let surface = stores.surfaces.insert(Surface::new(path, [0., 0., 1.])); let surface = objects.surfaces.insert(Surface::new(path, [0., 0., 1.]));
let curve = Handle::<Curve>::partial() let curve = Handle::<Curve>::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_line_from_points([[0., 1.], [1., 1.]]) .as_line_from_points([[0., 1.], [1., 1.]])
.build(&stores); .build(&objects);
let range = RangeOnPath::from([[0.], [TAU]]); let range = RangeOnPath::from([[0.], [TAU]]);
let tolerance = 1.; let tolerance = 1.;
@ -274,15 +274,15 @@ mod tests {
#[test] #[test]
fn approx_circle_on_flat_surface() { fn approx_circle_on_flat_surface() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores let surface = objects
.surfaces .surfaces
.insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.])); .insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.]));
let curve = Handle::<Curve>::partial() let curve = Handle::<Curve>::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.as_circle_from_radius(1.) .as_circle_from_radius(1.)
.build(&stores); .build(&objects);
let range = RangeOnPath::from([[0.], [TAU]]); let range = RangeOnPath::from([[0.], [TAU]]);
let tolerance = 1.; let tolerance = 1.;

View File

@ -20,7 +20,7 @@ use std::{
use fj_math::Point; use fj_math::Point;
use crate::{objects::Curve, stores::Handle}; use crate::{objects::Curve, storage::Handle};
pub use self::tolerance::{InvalidTolerance, Tolerance}; pub use self::tolerance::{InvalidTolerance, Tolerance};

View File

@ -75,26 +75,26 @@ mod tests {
use fj_math::Point; use fj_math::Point;
use crate::{ use crate::{
objects::{Curve, HalfEdge, Surface}, objects::{Curve, HalfEdge, Objects, Surface},
partial::HasPartial, partial::HasPartial,
stores::{Handle, Stores}, storage::Handle,
}; };
use super::CurveEdgeIntersection; use super::CurveEdgeIntersection;
#[test] #[test]
fn compute_edge_in_front_of_curve_origin() { fn compute_edge_in_front_of_curve_origin() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let curve = Handle::<Curve>::partial() let curve = Handle::<Curve>::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_u_axis() .as_u_axis()
.build(&stores); .build(&objects);
let half_edge = HalfEdge::partial() let half_edge = HalfEdge::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.as_line_segment_from_points([[1., -1.], [1., 1.]]) .as_line_segment_from_points([[1., -1.], [1., 1.]])
.build(&stores); .build(&objects);
let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);
@ -108,17 +108,17 @@ mod tests {
#[test] #[test]
fn compute_edge_behind_curve_origin() { fn compute_edge_behind_curve_origin() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let curve = Handle::<Curve>::partial() let curve = Handle::<Curve>::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_u_axis() .as_u_axis()
.build(&stores); .build(&objects);
let half_edge = HalfEdge::partial() let half_edge = HalfEdge::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.as_line_segment_from_points([[-1., -1.], [-1., 1.]]) .as_line_segment_from_points([[-1., -1.], [-1., 1.]])
.build(&stores); .build(&objects);
let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);
@ -132,17 +132,17 @@ mod tests {
#[test] #[test]
fn compute_edge_parallel_to_curve() { fn compute_edge_parallel_to_curve() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let curve = Handle::<Curve>::partial() let curve = Handle::<Curve>::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_u_axis() .as_u_axis()
.build(&stores); .build(&objects);
let half_edge = HalfEdge::partial() let half_edge = HalfEdge::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.as_line_segment_from_points([[-1., -1.], [1., -1.]]) .as_line_segment_from_points([[-1., -1.], [1., -1.]])
.build(&stores); .build(&objects);
let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);
@ -151,17 +151,17 @@ mod tests {
#[test] #[test]
fn compute_edge_on_curve() { fn compute_edge_on_curve() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let curve = Handle::<Curve>::partial() let curve = Handle::<Curve>::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_u_axis() .as_u_axis()
.build(&stores); .build(&objects);
let half_edge = HalfEdge::partial() let half_edge = HalfEdge::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.as_line_segment_from_points([[-1., 0.], [1., 0.]]) .as_line_segment_from_points([[-1., 0.], [1., 0.]])
.build(&stores); .build(&objects);
let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

View File

@ -156,23 +156,23 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{ use crate::{
objects::{Curve, Face, Surface}, objects::{Curve, Face, Objects, Surface},
partial::HasPartial, partial::HasPartial,
stores::{Handle, Stores}, storage::Handle,
}; };
use super::CurveFaceIntersection; use super::CurveFaceIntersection;
#[test] #[test]
fn compute() { fn compute() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let curve = Handle::<Curve>::partial() let curve = Handle::<Curve>::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_line_from_points([[-3., 0.], [-2., 0.]]) .as_line_from_points([[-3., 0.], [-2., 0.]])
.build(&stores); .build(&objects);
#[rustfmt::skip] #[rustfmt::skip]
let exterior = [ let exterior = [
@ -189,7 +189,7 @@ mod tests {
[ 1., -1.], [ 1., -1.],
]; ];
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points(exterior) .with_exterior_polygon_from_points(exterior)
.with_interior_polygon_from_points(interior) .with_interior_polygon_from_points(interior)
.build(); .build();

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
objects::{Curve, Face}, objects::{Curve, Face, Objects},
stores::{Handle, Stores}, storage::Handle,
}; };
use super::{CurveFaceIntersection, SurfaceSurfaceIntersection}; use super::{CurveFaceIntersection, SurfaceSurfaceIntersection};
@ -24,11 +24,11 @@ pub struct FaceFaceIntersection {
impl FaceFaceIntersection { impl FaceFaceIntersection {
/// Compute the intersections between two faces /// Compute the intersections between two faces
pub fn compute(faces: [&Face; 2], stores: &Stores) -> Option<Self> { pub fn compute(faces: [&Face; 2], objects: &Objects) -> Option<Self> {
let surfaces = faces.map(|face| face.surface().clone()); let surfaces = faces.map(|face| face.surface().clone());
let intersection_curves = let intersection_curves =
SurfaceSurfaceIntersection::compute(surfaces, stores)? SurfaceSurfaceIntersection::compute(surfaces, objects)?
.intersection_curves; .intersection_curves;
// Can be cleaned up, once `zip` is stable: // Can be cleaned up, once `zip` is stable:
@ -64,16 +64,16 @@ mod tests {
use crate::{ use crate::{
algorithms::intersect::CurveFaceIntersection, algorithms::intersect::CurveFaceIntersection,
objects::{Curve, Face, Surface}, objects::{Curve, Face, Objects, Surface},
partial::HasPartial, partial::HasPartial,
stores::{Handle, Stores}, storage::Handle,
}; };
use super::FaceFaceIntersection; use super::FaceFaceIntersection;
#[test] #[test]
fn compute_no_intersection() { fn compute_no_intersection() {
let stores = Stores::new(); let objects = Objects::new();
#[rustfmt::skip] #[rustfmt::skip]
let points = [ let points = [
@ -84,20 +84,20 @@ mod tests {
]; ];
let [a, b] = let [a, b] =
[Surface::xy_plane(), Surface::xz_plane()].map(|surface| { [Surface::xy_plane(), Surface::xz_plane()].map(|surface| {
let surface = stores.surfaces.insert(surface); let surface = objects.surfaces.insert(surface);
Face::builder(&stores, surface) Face::builder(&objects, surface)
.with_exterior_polygon_from_points(points) .with_exterior_polygon_from_points(points)
.build() .build()
}); });
let intersection = FaceFaceIntersection::compute([&a, &b], &stores); let intersection = FaceFaceIntersection::compute([&a, &b], &objects);
assert!(intersection.is_none()); assert!(intersection.is_none());
} }
#[test] #[test]
fn compute_one_intersection() { fn compute_one_intersection() {
let stores = Stores::new(); let objects = Objects::new();
#[rustfmt::skip] #[rustfmt::skip]
let points = [ let points = [
@ -107,20 +107,20 @@ mod tests {
[-1., 1.], [-1., 1.],
]; ];
let surfaces = [Surface::xy_plane(), Surface::xz_plane()] let surfaces = [Surface::xy_plane(), Surface::xz_plane()]
.map(|surface| stores.surfaces.insert(surface)); .map(|surface| objects.surfaces.insert(surface));
let [a, b] = surfaces.clone().map(|surface| { let [a, b] = surfaces.clone().map(|surface| {
Face::builder(&stores, surface) Face::builder(&objects, surface)
.with_exterior_polygon_from_points(points) .with_exterior_polygon_from_points(points)
.build() .build()
}); });
let intersection = FaceFaceIntersection::compute([&a, &b], &stores); let intersection = FaceFaceIntersection::compute([&a, &b], &objects);
let expected_curves = surfaces.map(|surface| { let expected_curves = surfaces.map(|surface| {
Handle::<Curve>::partial() Handle::<Curve>::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.as_line_from_points([[0., 0.], [1., 0.]]) .as_line_from_points([[0., 0.], [1., 0.]])
.build(&stores) .build(&objects)
}); });
let expected_intervals = let expected_intervals =
CurveFaceIntersection::from_intervals([[[-1.], [1.]]]); CurveFaceIntersection::from_intervals([[[-1.], [1.]]]);

View File

@ -134,16 +134,15 @@ mod tests {
use crate::{ use crate::{
algorithms::intersect::{face_point::FacePointIntersection, Intersect}, algorithms::intersect::{face_point::FacePointIntersection, Intersect},
iter::ObjectIters, iter::ObjectIters,
objects::{Face, Surface}, objects::{Face, Objects, Surface},
stores::Stores,
}; };
#[test] #[test]
fn point_is_outside_face() { fn point_is_outside_face() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([[0., 0.], [1., 1.], [0., 2.]]) .with_exterior_polygon_from_points([[0., 0.], [1., 1.], [0., 2.]])
.build(); .build();
let point = Point::from([2., 1.]); let point = Point::from([2., 1.]);
@ -154,10 +153,10 @@ mod tests {
#[test] #[test]
fn ray_hits_vertex_while_passing_outside() { fn ray_hits_vertex_while_passing_outside() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([[0., 0.], [2., 1.], [0., 2.]]) .with_exterior_polygon_from_points([[0., 0.], [2., 1.], [0., 2.]])
.build(); .build();
let point = Point::from([1., 1.]); let point = Point::from([1., 1.]);
@ -171,10 +170,10 @@ mod tests {
#[test] #[test]
fn ray_hits_vertex_at_cycle_seam() { fn ray_hits_vertex_at_cycle_seam() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([[4., 2.], [0., 4.], [0., 0.]]) .with_exterior_polygon_from_points([[4., 2.], [0., 4.], [0., 0.]])
.build(); .build();
let point = Point::from([1., 2.]); let point = Point::from([1., 2.]);
@ -188,10 +187,10 @@ mod tests {
#[test] #[test]
fn ray_hits_vertex_while_staying_inside() { fn ray_hits_vertex_while_staying_inside() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([ .with_exterior_polygon_from_points([
[0., 0.], [0., 0.],
[2., 1.], [2., 1.],
@ -210,10 +209,10 @@ mod tests {
#[test] #[test]
fn ray_hits_parallel_edge_and_leaves_face_at_vertex() { fn ray_hits_parallel_edge_and_leaves_face_at_vertex() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([ .with_exterior_polygon_from_points([
[0., 0.], [0., 0.],
[2., 1.], [2., 1.],
@ -232,10 +231,10 @@ mod tests {
#[test] #[test]
fn ray_hits_parallel_edge_and_does_not_leave_face_there() { fn ray_hits_parallel_edge_and_does_not_leave_face_there() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([ .with_exterior_polygon_from_points([
[0., 0.], [0., 0.],
[2., 1.], [2., 1.],
@ -255,10 +254,10 @@ mod tests {
#[test] #[test]
fn point_is_coincident_with_edge() { fn point_is_coincident_with_edge() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([[0., 0.], [2., 0.], [0., 1.]]) .with_exterior_polygon_from_points([[0., 0.], [2., 0.], [0., 1.]])
.build(); .build();
let point = Point::from([1., 0.]); let point = Point::from([1., 0.]);
@ -281,10 +280,10 @@ mod tests {
#[test] #[test]
fn point_is_coincident_with_vertex() { fn point_is_coincident_with_vertex() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]]) .with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]])
.build(); .build();
let point = Point::from([1., 0.]); let point = Point::from([1., 0.]);

View File

@ -152,18 +152,17 @@ mod tests {
transform::TransformObject, transform::TransformObject,
}, },
iter::ObjectIters, iter::ObjectIters,
objects::{Face, Surface}, objects::{Face, Objects, Surface},
stores::Stores,
}; };
#[test] #[test]
fn ray_misses_whole_surface() { fn ray_misses_whole_surface() {
let stores = Stores::new(); let objects = Objects::new();
let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
let surface = stores.surfaces.insert(Surface::yz_plane()); let surface = objects.surfaces.insert(Surface::yz_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([ .with_exterior_polygon_from_points([
[-1., -1.], [-1., -1.],
[1., -1.], [1., -1.],
@ -171,19 +170,19 @@ mod tests {
[-1., 1.], [-1., 1.],
]) ])
.build() .build()
.translate([-1., 0., 0.], &stores); .translate([-1., 0., 0.], &objects);
assert_eq!((&ray, &face).intersect(), None); assert_eq!((&ray, &face).intersect(), None);
} }
#[test] #[test]
fn ray_hits_face() { fn ray_hits_face() {
let stores = Stores::new(); let objects = Objects::new();
let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
let surface = stores.surfaces.insert(Surface::yz_plane()); let surface = objects.surfaces.insert(Surface::yz_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([ .with_exterior_polygon_from_points([
[-1., -1.], [-1., -1.],
[1., -1.], [1., -1.],
@ -191,7 +190,7 @@ mod tests {
[-1., 1.], [-1., 1.],
]) ])
.build() .build()
.translate([1., 0., 0.], &stores); .translate([1., 0., 0.], &objects);
assert_eq!( assert_eq!(
(&ray, &face).intersect(), (&ray, &face).intersect(),
@ -201,12 +200,12 @@ mod tests {
#[test] #[test]
fn ray_hits_surface_but_misses_face() { fn ray_hits_surface_but_misses_face() {
let stores = Stores::new(); let objects = Objects::new();
let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
let surface = stores.surfaces.insert(Surface::yz_plane()); let surface = objects.surfaces.insert(Surface::yz_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([ .with_exterior_polygon_from_points([
[-1., -1.], [-1., -1.],
[1., -1.], [1., -1.],
@ -214,19 +213,19 @@ mod tests {
[-1., 1.], [-1., 1.],
]) ])
.build() .build()
.translate([0., 0., 2.], &stores); .translate([0., 0., 2.], &objects);
assert_eq!((&ray, &face).intersect(), None); assert_eq!((&ray, &face).intersect(), None);
} }
#[test] #[test]
fn ray_hits_edge() { fn ray_hits_edge() {
let stores = Stores::new(); let objects = Objects::new();
let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
let surface = stores.surfaces.insert(Surface::yz_plane()); let surface = objects.surfaces.insert(Surface::yz_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([ .with_exterior_polygon_from_points([
[-1., -1.], [-1., -1.],
[1., -1.], [1., -1.],
@ -234,7 +233,7 @@ mod tests {
[-1., 1.], [-1., 1.],
]) ])
.build() .build()
.translate([1., 1., 0.], &stores); .translate([1., 1., 0.], &objects);
let edge = face let edge = face
.half_edge_iter() .half_edge_iter()
@ -252,12 +251,12 @@ mod tests {
#[test] #[test]
fn ray_hits_vertex() { fn ray_hits_vertex() {
let stores = Stores::new(); let objects = Objects::new();
let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
let surface = stores.surfaces.insert(Surface::yz_plane()); let surface = objects.surfaces.insert(Surface::yz_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([ .with_exterior_polygon_from_points([
[-1., -1.], [-1., -1.],
[1., -1.], [1., -1.],
@ -265,7 +264,7 @@ mod tests {
[-1., 1.], [-1., 1.],
]) ])
.build() .build()
.translate([1., 1., 1.], &stores); .translate([1., 1., 1.], &objects);
let vertex = face let vertex = face
.vertex_iter() .vertex_iter()
@ -281,12 +280,12 @@ mod tests {
#[test] #[test]
fn ray_is_parallel_to_surface_and_hits() { fn ray_is_parallel_to_surface_and_hits() {
let stores = Stores::new(); let objects = Objects::new();
let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([ .with_exterior_polygon_from_points([
[-1., -1.], [-1., -1.],
[1., -1.], [1., -1.],
@ -303,12 +302,12 @@ mod tests {
#[test] #[test]
fn ray_is_parallel_to_surface_and_misses() { fn ray_is_parallel_to_surface_and_misses() {
let stores = Stores::new(); let objects = Objects::new();
let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([ .with_exterior_polygon_from_points([
[-1., -1.], [-1., -1.],
[1., -1.], [1., -1.],
@ -316,7 +315,7 @@ mod tests {
[-1., 1.], [-1., 1.],
]) ])
.build() .build()
.translate([0., 0., 1.], &stores); .translate([0., 0., 1.], &objects);
assert_eq!((&ray, &face).intersect(), None) assert_eq!((&ray, &face).intersect(), None)
} }

View File

@ -1,9 +1,9 @@
use fj_math::{Line, Plane, Point, Scalar}; use fj_math::{Line, Plane, Point, Scalar};
use crate::{ use crate::{
objects::{Curve, GlobalCurve, Surface}, objects::{Curve, GlobalCurve, Objects, Surface},
path::{GlobalPath, SurfacePath}, path::{GlobalPath, SurfacePath},
stores::{Handle, Stores}, storage::Handle,
}; };
/// The intersection between two surfaces /// The intersection between two surfaces
@ -17,7 +17,7 @@ impl SurfaceSurfaceIntersection {
/// Compute the intersection between two surfaces /// Compute the intersection between two surfaces
pub fn compute( pub fn compute(
surfaces: [Handle<Surface>; 2], surfaces: [Handle<Surface>; 2],
stores: &Stores, objects: &Objects,
) -> Option<Self> { ) -> Option<Self> {
// Algorithm from Real-Time Collision Detection by Christer Ericson. See // Algorithm from Real-Time Collision Detection by Christer Ericson. See
// section 5.4.4, Intersection of Two Planes. // section 5.4.4, Intersection of Two Planes.
@ -57,9 +57,9 @@ impl SurfaceSurfaceIntersection {
let curves = surfaces_and_planes.map(|(surface, plane)| { let curves = surfaces_and_planes.map(|(surface, plane)| {
let path = SurfacePath::Line(plane.project_line(&line)); let path = SurfacePath::Line(plane.project_line(&line));
let global_form = GlobalCurve::new(stores); let global_form = GlobalCurve::new(objects);
Curve::new(surface, path, global_form, stores) Curve::new(surface, path, global_form, objects)
}); });
Some(Self { Some(Self {
@ -88,19 +88,19 @@ mod tests {
use crate::{ use crate::{
algorithms::transform::TransformObject, algorithms::transform::TransformObject,
objects::{Curve, Surface}, objects::{Curve, Objects, Surface},
partial::HasPartial, partial::HasPartial,
stores::{Handle, Stores}, storage::Handle,
}; };
use super::SurfaceSurfaceIntersection; use super::SurfaceSurfaceIntersection;
#[test] #[test]
fn plane_plane() { fn plane_plane() {
let stores = Stores::new(); let objects = Objects::new();
let xy = stores.surfaces.insert(Surface::xy_plane()); let xy = objects.surfaces.insert(Surface::xy_plane());
let xz = stores.surfaces.insert(Surface::xz_plane()); let xz = objects.surfaces.insert(Surface::xz_plane());
// Coincident and parallel planes don't have an intersection curve. // Coincident and parallel planes don't have an intersection curve.
assert_eq!( assert_eq!(
@ -109,10 +109,10 @@ mod tests {
xy.clone(), xy.clone(),
xy.clone().transform( xy.clone().transform(
&Transform::translation([0., 0., 1.],), &Transform::translation([0., 0., 1.],),
&stores &objects
) )
], ],
&stores &objects
), ),
None, None,
); );
@ -120,14 +120,14 @@ mod tests {
let expected_xy = Handle::<Curve>::partial() let expected_xy = Handle::<Curve>::partial()
.with_surface(Some(xy.clone())) .with_surface(Some(xy.clone()))
.as_u_axis() .as_u_axis()
.build(&stores); .build(&objects);
let expected_xz = Handle::<Curve>::partial() let expected_xz = Handle::<Curve>::partial()
.with_surface(Some(xz.clone())) .with_surface(Some(xz.clone()))
.as_u_axis() .as_u_axis()
.build(&stores); .build(&objects);
assert_eq!( assert_eq!(
SurfaceSurfaceIntersection::compute([xy, xz], &stores), SurfaceSurfaceIntersection::compute([xy, xz], &objects),
Some(SurfaceSurfaceIntersection { Some(SurfaceSurfaceIntersection {
intersection_curves: [expected_xy, expected_xz], intersection_curves: [expected_xy, expected_xz],
}) })

View File

@ -1,9 +1,9 @@
use fj_math::{Circle, Line, Vector}; use fj_math::{Circle, Line, Vector};
use crate::{ use crate::{
objects::{Curve, Surface}, objects::{Curve, Objects, Surface},
path::{GlobalPath, SurfacePath}, path::{GlobalPath, SurfacePath},
stores::{Handle, Stores}, storage::Handle,
}; };
use super::Sweep; use super::Sweep;
@ -11,7 +11,11 @@ use super::Sweep;
impl Sweep for Handle<Curve> { impl Sweep for Handle<Curve> {
type Swept = Handle<Surface>; type Swept = Handle<Surface>;
fn sweep(self, path: impl Into<Vector<3>>, stores: &Stores) -> Self::Swept { fn sweep(
self,
path: impl Into<Vector<3>>,
objects: &Objects,
) -> Self::Swept {
match self.surface().u() { match self.surface().u() {
GlobalPath::Circle(_) => { GlobalPath::Circle(_) => {
// Sweeping a `Curve` creates a `Surface`. The u-axis of that // Sweeping a `Curve` creates a `Surface`. The u-axis of that
@ -59,6 +63,6 @@ impl Sweep for Handle<Curve> {
} }
}; };
stores.surfaces.insert(Surface::new(u, path)) objects.surfaces.insert(Surface::new(u, path))
} }
} }

View File

@ -4,10 +4,10 @@ use fj_math::{Line, Scalar, Vector};
use crate::{ use crate::{
algorithms::{reverse::Reverse, transform::TransformObject}, algorithms::{reverse::Reverse, transform::TransformObject},
objects::{ objects::{
Curve, Cycle, Face, GlobalEdge, HalfEdge, SurfaceVertex, Vertex, Curve, Cycle, Face, GlobalEdge, HalfEdge, Objects, SurfaceVertex,
Vertex,
}, },
path::SurfacePath, path::SurfacePath,
stores::Stores,
}; };
use super::Sweep; use super::Sweep;
@ -15,11 +15,15 @@ use super::Sweep;
impl Sweep for (HalfEdge, Color) { impl Sweep for (HalfEdge, Color) {
type Swept = Face; type Swept = Face;
fn sweep(self, path: impl Into<Vector<3>>, stores: &Stores) -> Self::Swept { fn sweep(
self,
path: impl Into<Vector<3>>,
objects: &Objects,
) -> Self::Swept {
let (edge, color) = self; let (edge, color) = self;
let path = path.into(); let path = path.into();
let surface = edge.curve().clone().sweep(path, stores); let surface = edge.curve().clone().sweep(path, objects);
// We can't use the edge we're sweeping from as the bottom edge, as that // We can't use the edge we're sweeping from as the bottom edge, as that
// is not defined in the right surface. Let's create a new bottom edge, // is not defined in the right surface. Let's create a new bottom edge,
@ -44,7 +48,7 @@ impl Sweep for (HalfEdge, Color) {
surface.clone(), surface.clone(),
path, path,
edge.curve().global_form().clone(), edge.curve().global_form().clone(),
stores, objects,
) )
}; };
@ -80,7 +84,7 @@ impl Sweep for (HalfEdge, Color) {
let side_edges = bottom_edge let side_edges = bottom_edge
.vertices() .vertices()
.clone() .clone()
.map(|vertex| (vertex, surface.clone()).sweep(path, stores)); .map(|vertex| (vertex, surface.clone()).sweep(path, objects));
let top_edge = { let top_edge = {
let bottom_vertices = bottom_edge.vertices(); let bottom_vertices = bottom_edge.vertices();
@ -100,7 +104,7 @@ impl Sweep for (HalfEdge, Color) {
.curve() .curve()
.global_form() .global_form()
.clone() .clone()
.translate(path, stores); .translate(path, objects);
// Please note that creating a line here is correct, even if the // Please note that creating a line here is correct, even if the
// global curve is a circle. Projected into the side surface, it // global curve is a circle. Projected into the side surface, it
@ -110,7 +114,7 @@ impl Sweep for (HalfEdge, Color) {
points_curve_and_surface, points_curve_and_surface,
)); ));
Curve::new(surface.clone(), path, global, stores) Curve::new(surface.clone(), path, global, objects)
}; };
let global = GlobalEdge::new( let global = GlobalEdge::new(
@ -184,43 +188,42 @@ mod tests {
use crate::{ use crate::{
algorithms::{reverse::Reverse, sweep::Sweep}, algorithms::{reverse::Reverse, sweep::Sweep},
objects::{Cycle, Face, HalfEdge, Surface}, objects::{Cycle, Face, HalfEdge, Objects, Surface},
partial::HasPartial, partial::HasPartial,
stores::Stores,
}; };
#[test] #[test]
fn sweep() { fn sweep() {
let stores = Stores::new(); let objects = Objects::new();
let half_edge = HalfEdge::partial() let half_edge = HalfEdge::partial()
.with_surface(Some(stores.surfaces.insert(Surface::xy_plane()))) .with_surface(Some(objects.surfaces.insert(Surface::xy_plane())))
.as_line_segment_from_points([[0., 0.], [1., 0.]]) .as_line_segment_from_points([[0., 0.], [1., 0.]])
.build(&stores); .build(&objects);
let face = (half_edge, Color::default()).sweep([0., 0., 1.], &stores); let face = (half_edge, Color::default()).sweep([0., 0., 1.], &objects);
let expected_face = { let expected_face = {
let surface = stores.surfaces.insert(Surface::xz_plane()); let surface = objects.surfaces.insert(Surface::xz_plane());
let bottom = HalfEdge::partial() let bottom = HalfEdge::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_line_segment_from_points([[0., 0.], [1., 0.]]) .as_line_segment_from_points([[0., 0.], [1., 0.]])
.build(&stores); .build(&objects);
let top = HalfEdge::partial() let top = HalfEdge::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_line_segment_from_points([[0., 1.], [1., 1.]]) .as_line_segment_from_points([[0., 1.], [1., 1.]])
.build(&stores) .build(&objects)
.reverse(); .reverse();
let left = HalfEdge::partial() let left = HalfEdge::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_line_segment_from_points([[0., 0.], [0., 1.]]) .as_line_segment_from_points([[0., 0.], [0., 1.]])
.build(&stores) .build(&objects)
.reverse(); .reverse();
let right = HalfEdge::partial() let right = HalfEdge::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_line_segment_from_points([[1., 0.], [1., 1.]]) .as_line_segment_from_points([[1., 0.], [1., 1.]])
.build(&stores); .build(&objects);
let cycle = Cycle::new(surface, [bottom, right, top, left]); let cycle = Cycle::new(surface, [bottom, right, top, left]);

View File

@ -2,9 +2,8 @@ use fj_math::{Scalar, Vector};
use crate::{ use crate::{
algorithms::{reverse::Reverse, transform::TransformObject}, algorithms::{reverse::Reverse, transform::TransformObject},
objects::{Face, Shell}, objects::{Face, Objects, Shell},
path::GlobalPath, path::GlobalPath,
stores::Stores,
}; };
use super::Sweep; use super::Sweep;
@ -12,7 +11,11 @@ use super::Sweep;
impl Sweep for Face { impl Sweep for Face {
type Swept = Shell; type Swept = Shell;
fn sweep(self, path: impl Into<Vector<3>>, stores: &Stores) -> Self::Swept { fn sweep(
self,
path: impl Into<Vector<3>>,
objects: &Objects,
) -> Self::Swept {
let path = path.into(); let path = path.into();
let mut faces = Vec::new(); let mut faces = Vec::new();
@ -42,7 +45,7 @@ impl Sweep for Face {
faces.push(bottom_face); faces.push(bottom_face);
let top_face = { let top_face = {
let mut face = self.clone().translate(path, stores); let mut face = self.clone().translate(path, objects);
if is_negative_sweep { if is_negative_sweep {
face = face.reverse(); face = face.reverse();
@ -61,7 +64,7 @@ impl Sweep for Face {
half_edge.clone() half_edge.clone()
}; };
let face = (half_edge, self.color()).sweep(path, stores); let face = (half_edge, self.color()).sweep(path, objects);
faces.push(face); faces.push(face);
} }
@ -77,9 +80,8 @@ mod tests {
use crate::{ use crate::{
algorithms::{reverse::Reverse, transform::TransformObject}, algorithms::{reverse::Reverse, transform::TransformObject},
objects::{Face, HalfEdge, Sketch, Surface}, objects::{Face, HalfEdge, Objects, Sketch, Surface},
partial::HasPartial, partial::HasPartial,
stores::Stores,
}; };
use super::Sweep; use super::Sweep;
@ -91,18 +93,18 @@ mod tests {
#[test] #[test]
fn sweep_up() { fn sweep_up() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let solid = Sketch::builder(&stores, surface.clone()) let solid = Sketch::builder(&objects, surface.clone())
.build_polygon_from_points(TRIANGLE) .build_polygon_from_points(TRIANGLE)
.sweep(UP, &stores); .sweep(UP, &objects);
let bottom = Face::builder(&stores, surface.clone()) let bottom = Face::builder(&objects, surface.clone())
.with_exterior_polygon_from_points(TRIANGLE) .with_exterior_polygon_from_points(TRIANGLE)
.build() .build()
.reverse(); .reverse();
let top = Face::builder(&stores, surface.translate(UP, &stores)) let top = Face::builder(&objects, surface.translate(UP, &objects))
.with_exterior_polygon_from_points(TRIANGLE) .with_exterior_polygon_from_points(TRIANGLE)
.build(); .build();
@ -117,10 +119,12 @@ mod tests {
let [a, b] = [window[0], window[1]]; let [a, b] = [window[0], window[1]];
let half_edge = HalfEdge::partial() let half_edge = HalfEdge::partial()
.with_surface(Some(stores.surfaces.insert(Surface::xy_plane()))) .with_surface(Some(
objects.surfaces.insert(Surface::xy_plane()),
))
.as_line_segment_from_points([a, b]) .as_line_segment_from_points([a, b])
.build(&stores); .build(&objects);
(half_edge, Color::default()).sweep(UP, &stores) (half_edge, Color::default()).sweep(UP, &objects)
}); });
assert!(side_faces.all(|face| solid.find_face(&face).is_some())); assert!(side_faces.all(|face| solid.find_face(&face).is_some()));
@ -128,19 +132,19 @@ mod tests {
#[test] #[test]
fn sweep_down() { fn sweep_down() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let solid = Sketch::builder(&stores, surface.clone()) let solid = Sketch::builder(&objects, surface.clone())
.build_polygon_from_points(TRIANGLE) .build_polygon_from_points(TRIANGLE)
.sweep(DOWN, &stores); .sweep(DOWN, &objects);
let bottom = let bottom =
Face::builder(&stores, surface.clone().translate(DOWN, &stores)) Face::builder(&objects, surface.clone().translate(DOWN, &objects))
.with_exterior_polygon_from_points(TRIANGLE) .with_exterior_polygon_from_points(TRIANGLE)
.build() .build()
.reverse(); .reverse();
let top = Face::builder(&stores, surface) let top = Face::builder(&objects, surface)
.with_exterior_polygon_from_points(TRIANGLE) .with_exterior_polygon_from_points(TRIANGLE)
.build(); .build();
@ -155,11 +159,13 @@ mod tests {
let [a, b] = [window[0], window[1]]; let [a, b] = [window[0], window[1]];
let half_edge = HalfEdge::partial() let half_edge = HalfEdge::partial()
.with_surface(Some(stores.surfaces.insert(Surface::xy_plane()))) .with_surface(Some(
objects.surfaces.insert(Surface::xy_plane()),
))
.as_line_segment_from_points([a, b]) .as_line_segment_from_points([a, b])
.build(&stores) .build(&objects)
.reverse(); .reverse();
(half_edge, Color::default()).sweep(DOWN, &stores) (half_edge, Color::default()).sweep(DOWN, &objects)
}); });
assert!(side_faces.all(|face| solid.find_face(&face).is_some())); assert!(side_faces.all(|face| solid.find_face(&face).is_some()));

View File

@ -8,7 +8,7 @@ mod vertex;
use fj_math::Vector; use fj_math::Vector;
use crate::stores::Stores; use crate::objects::Objects;
/// Sweep an object along a path to create another object /// Sweep an object along a path to create another object
pub trait Sweep { pub trait Sweep {
@ -16,5 +16,9 @@ pub trait Sweep {
type Swept; type Swept;
/// Sweep the object along the given path /// Sweep the object along the given path
fn sweep(self, path: impl Into<Vector<3>>, store: &Stores) -> Self::Swept; fn sweep(
self,
path: impl Into<Vector<3>>,
objects: &Objects,
) -> Self::Swept;
} }

View File

@ -1,21 +1,22 @@
use fj_math::Vector; use fj_math::Vector;
use crate::{ use crate::objects::{Objects, Sketch, Solid};
objects::{Sketch, Solid},
stores::Stores,
};
use super::Sweep; use super::Sweep;
impl Sweep for Sketch { impl Sweep for Sketch {
type Swept = Solid; type Swept = Solid;
fn sweep(self, path: impl Into<Vector<3>>, stores: &Stores) -> Self::Swept { fn sweep(
self,
path: impl Into<Vector<3>>,
objects: &Objects,
) -> Self::Swept {
let path = path.into(); let path = path.into();
let mut shells = Vec::new(); let mut shells = Vec::new();
for face in self.into_faces() { for face in self.into_faces() {
let shell = face.sweep(path, stores); let shell = face.sweep(path, objects);
shells.push(shell); shells.push(shell);
} }

View File

@ -2,11 +2,11 @@ use fj_math::{Line, Point, Scalar, Vector};
use crate::{ use crate::{
objects::{ objects::{
Curve, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Surface, Curve, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Objects,
SurfaceVertex, Vertex, Surface, SurfaceVertex, Vertex,
}, },
path::SurfacePath, path::SurfacePath,
stores::{Handle, Stores}, storage::Handle,
}; };
use super::Sweep; use super::Sweep;
@ -14,7 +14,11 @@ use super::Sweep;
impl Sweep for (Vertex, Handle<Surface>) { impl Sweep for (Vertex, Handle<Surface>) {
type Swept = HalfEdge; type Swept = HalfEdge;
fn sweep(self, path: impl Into<Vector<3>>, stores: &Stores) -> Self::Swept { fn sweep(
self,
path: impl Into<Vector<3>>,
objects: &Objects,
) -> Self::Swept {
let (vertex, surface) = self; let (vertex, surface) = self;
let path = path.into(); let path = path.into();
@ -54,7 +58,7 @@ impl Sweep for (Vertex, Handle<Surface>) {
// as that is the most straight-forward part of this operations, and // as that is the most straight-forward part of this operations, and
// we're going to need it soon anyway. // we're going to need it soon anyway.
let (edge_global, vertices_global) = let (edge_global, vertices_global) =
vertex.global_form().clone().sweep(path, stores); vertex.global_form().clone().sweep(path, objects);
// Next, let's compute the surface coordinates of the two vertices of // Next, let's compute the surface coordinates of the two vertices of
// the output `Edge`, as we're going to need these for the rest of this // the output `Edge`, as we're going to need these for the rest of this
@ -84,7 +88,7 @@ impl Sweep for (Vertex, Handle<Surface>) {
surface.clone(), surface.clone(),
SurfacePath::Line(line), SurfacePath::Line(line),
edge_global.curve().clone(), edge_global.curve().clone(),
stores, objects,
) )
}; };
@ -123,12 +127,16 @@ impl Sweep for (Vertex, Handle<Surface>) {
impl Sweep for Handle<GlobalVertex> { impl Sweep for Handle<GlobalVertex> {
type Swept = (GlobalEdge, [Handle<GlobalVertex>; 2]); type Swept = (GlobalEdge, [Handle<GlobalVertex>; 2]);
fn sweep(self, path: impl Into<Vector<3>>, stores: &Stores) -> Self::Swept { fn sweep(
let curve = GlobalCurve::new(stores); self,
path: impl Into<Vector<3>>,
objects: &Objects,
) -> Self::Swept {
let curve = GlobalCurve::new(objects);
let a = self.clone(); let a = self.clone();
let b = let b =
GlobalVertex::from_position(self.position() + path.into(), stores); GlobalVertex::from_position(self.position() + path.into(), objects);
let vertices = [a, b]; let vertices = [a, b];
let global_edge = GlobalEdge::new(curve, vertices.clone()); let global_edge = GlobalEdge::new(curve, vertices.clone());
@ -146,31 +154,31 @@ mod tests {
use crate::{ use crate::{
algorithms::sweep::Sweep, algorithms::sweep::Sweep,
objects::{Curve, HalfEdge, Surface, Vertex}, objects::{Curve, HalfEdge, Objects, Surface, Vertex},
partial::HasPartial, partial::HasPartial,
stores::{Handle, Stores}, storage::Handle,
}; };
#[test] #[test]
fn vertex_surface() { fn vertex_surface() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xz_plane()); let surface = objects.surfaces.insert(Surface::xz_plane());
let curve = Handle::<Curve>::partial() let curve = Handle::<Curve>::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_u_axis() .as_u_axis()
.build(&stores); .build(&objects);
let vertex = Vertex::partial() let vertex = Vertex::partial()
.with_position(Some([0.])) .with_position(Some([0.]))
.with_curve(Some(curve)) .with_curve(Some(curve))
.build(&stores); .build(&objects);
let half_edge = (vertex, surface.clone()).sweep([0., 0., 1.], &stores); let half_edge = (vertex, surface.clone()).sweep([0., 0., 1.], &objects);
let expected_half_edge = HalfEdge::partial() let expected_half_edge = HalfEdge::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.as_line_segment_from_points([[0., 0.], [0., 1.]]) .as_line_segment_from_points([[0., 0.], [0., 1.]])
.build(&stores); .build(&objects);
assert_eq!(half_edge, expected_half_edge); assert_eq!(half_edge, expected_half_edge);
} }
} }

View File

@ -1,15 +1,15 @@
use fj_math::Transform; use fj_math::Transform;
use crate::{ use crate::{
objects::GlobalCurve, objects::{GlobalCurve, Objects},
partial::PartialCurve, partial::PartialCurve,
stores::{Handle, Stores}, storage::Handle,
}; };
use super::TransformObject; use super::TransformObject;
impl TransformObject for Handle<GlobalCurve> { impl TransformObject for Handle<GlobalCurve> {
fn transform(self, _: &Transform, stores: &Stores) -> Self { fn transform(self, _: &Transform, objects: &Objects) -> Self {
// `GlobalCurve` doesn't contain any internal geometry. If it did, that // `GlobalCurve` doesn't contain any internal geometry. If it did, that
// would just be redundant with the geometry of other objects, and this // would just be redundant with the geometry of other objects, and this
// other geometry is already being transformed by other implementations // other geometry is already being transformed by other implementations
@ -18,18 +18,18 @@ impl TransformObject for Handle<GlobalCurve> {
// All we need to do here is create a new `GlobalCurve` instance, to // All we need to do here is create a new `GlobalCurve` instance, to
// make sure the transformed `GlobalCurve` has a different identity than // make sure the transformed `GlobalCurve` has a different identity than
// the original one. // the original one.
GlobalCurve::new(stores) GlobalCurve::new(objects)
} }
} }
impl TransformObject for PartialCurve { impl TransformObject for PartialCurve {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
let surface = self let surface = self
.surface .surface
.map(|surface| surface.transform(transform, stores)); .map(|surface| surface.transform(transform, objects));
let global_form = self let global_form = self
.global_form .global_form
.map(|global_form| global_form.0.transform(transform, stores)); .map(|global_form| global_form.0.transform(transform, objects));
// Don't need to transform `self.path`, as that's defined in surface // Don't need to transform `self.path`, as that's defined in surface
// coordinates, and thus transforming `surface` takes care of it. // coordinates, and thus transforming `surface` takes care of it.

View File

@ -1,21 +1,21 @@
use fj_math::Transform; use fj_math::Transform;
use crate::{partial::PartialCycle, stores::Stores}; use crate::{objects::Objects, partial::PartialCycle};
use super::TransformObject; use super::TransformObject;
impl TransformObject for PartialCycle { impl TransformObject for PartialCycle {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
let surface = self let surface = self
.surface .surface
.clone() .clone()
.map(|surface| surface.transform(transform, stores)); .map(|surface| surface.transform(transform, objects));
let half_edges = self let half_edges = self
.half_edges .half_edges
.into_iter() .into_iter()
.map(|edge| { .map(|edge| {
edge.into_partial() edge.into_partial()
.transform(transform, stores) .transform(transform, objects)
.with_surface(surface.clone()) .with_surface(surface.clone())
.into() .into()
}) })

View File

@ -1,22 +1,22 @@
use fj_math::Transform; use fj_math::Transform;
use crate::{ use crate::{
objects::Curve, objects::{Curve, Objects},
partial::{MaybePartial, PartialGlobalEdge, PartialHalfEdge}, partial::{MaybePartial, PartialGlobalEdge, PartialHalfEdge},
stores::{Handle, Stores}, storage::Handle,
}; };
use super::TransformObject; use super::TransformObject;
impl TransformObject for PartialHalfEdge { impl TransformObject for PartialHalfEdge {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
let surface = self let surface = self
.surface .surface
.map(|surface| surface.transform(transform, stores)); .map(|surface| surface.transform(transform, objects));
let curve = self.curve.clone().map(|curve| { let curve = self.curve.clone().map(|curve| {
curve curve
.into_partial() .into_partial()
.transform(transform, stores) .transform(transform, objects)
.with_surface(surface.clone()) .with_surface(surface.clone())
.into() .into()
}); });
@ -24,7 +24,7 @@ impl TransformObject for PartialHalfEdge {
vertices.map(|vertex| { vertices.map(|vertex| {
vertex vertex
.into_partial() .into_partial()
.transform(transform, stores) .transform(transform, objects)
.with_curve(curve.clone()) .with_curve(curve.clone())
.into() .into()
}) })
@ -32,7 +32,7 @@ impl TransformObject for PartialHalfEdge {
let global_form = self.global_form.map(|global_form| { let global_form = self.global_form.map(|global_form| {
global_form global_form
.into_partial() .into_partial()
.transform(transform, stores) .transform(transform, objects)
.with_curve(curve.as_ref().and_then( .with_curve(curve.as_ref().and_then(
|curve: &MaybePartial<Handle<Curve>>| curve.global_form(), |curve: &MaybePartial<Handle<Curve>>| curve.global_form(),
)) ))
@ -49,11 +49,12 @@ impl TransformObject for PartialHalfEdge {
} }
impl TransformObject for PartialGlobalEdge { impl TransformObject for PartialGlobalEdge {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
let curve = let curve = self
self.curve.map(|curve| curve.0.transform(transform, stores)); .curve
.map(|curve| curve.0.transform(transform, objects));
let vertices = self.vertices.map(|vertices| { let vertices = self.vertices.map(|vertices| {
vertices.map(|vertex| vertex.transform(transform, stores)) vertices.map(|vertex| vertex.transform(transform, objects))
}); });
Self { Self {

View File

@ -1,28 +1,27 @@
use fj_math::Transform; use fj_math::Transform;
use crate::{ use crate::{
objects::{Face, Faces}, objects::{Face, Faces, Objects},
partial::HasPartial, partial::HasPartial,
stores::Stores,
}; };
use super::TransformObject; use super::TransformObject;
impl TransformObject for Face { impl TransformObject for Face {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
let surface = self.surface().clone().transform(transform, stores); let surface = self.surface().clone().transform(transform, objects);
let exterior = self let exterior = self
.exterior() .exterior()
.to_partial() .to_partial()
.transform(transform, stores) .transform(transform, objects)
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.build(stores); .build(objects);
let interiors = self.interiors().map(|cycle| { let interiors = self.interiors().map(|cycle| {
cycle cycle
.to_partial() .to_partial()
.transform(transform, stores) .transform(transform, objects)
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.build(stores) .build(objects)
}); });
let color = self.color(); let color = self.color();
@ -34,11 +33,11 @@ impl TransformObject for Face {
} }
impl TransformObject for Faces { impl TransformObject for Faces {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
let mut faces = Faces::new(); let mut faces = Faces::new();
faces.extend( faces.extend(
self.into_iter() self.into_iter()
.map(|face| face.transform(transform, stores)), .map(|face| face.transform(transform, objects)),
); );
faces faces
} }

View File

@ -14,8 +14,8 @@ mod vertex;
use fj_math::{Transform, Vector}; use fj_math::{Transform, Vector};
use crate::{ use crate::{
objects::Objects,
partial::{HasPartial, MaybePartial, Partial}, partial::{HasPartial, MaybePartial, Partial},
stores::Stores,
}; };
/// Transform an object /// Transform an object
@ -30,22 +30,30 @@ use crate::{
pub trait TransformObject: Sized { pub trait TransformObject: Sized {
/// Transform the object /// Transform the object
#[must_use] #[must_use]
fn transform(self, transform: &Transform, stores: &Stores) -> Self; fn transform(self, transform: &Transform, objects: &Objects) -> Self;
/// Translate the object /// Translate the object
/// ///
/// Convenience wrapper around [`TransformObject::transform`]. /// Convenience wrapper around [`TransformObject::transform`].
#[must_use] #[must_use]
fn translate(self, offset: impl Into<Vector<3>>, stores: &Stores) -> Self { fn translate(
self.transform(&Transform::translation(offset), stores) self,
offset: impl Into<Vector<3>>,
objects: &Objects,
) -> Self {
self.transform(&Transform::translation(offset), objects)
} }
/// Rotate the object /// Rotate the object
/// ///
/// Convenience wrapper around [`TransformObject::transform`]. /// Convenience wrapper around [`TransformObject::transform`].
#[must_use] #[must_use]
fn rotate(self, axis_angle: impl Into<Vector<3>>, stores: &Stores) -> Self { fn rotate(
self.transform(&Transform::rotation(axis_angle), stores) self,
axis_angle: impl Into<Vector<3>>,
objects: &Objects,
) -> Self {
self.transform(&Transform::rotation(axis_angle), objects)
} }
} }
@ -54,8 +62,10 @@ where
T: HasPartial, T: HasPartial,
T::Partial: TransformObject, T::Partial: TransformObject,
{ {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
self.to_partial().transform(transform, stores).build(stores) self.to_partial()
.transform(transform, objects)
.build(objects)
} }
} }
@ -64,11 +74,11 @@ where
T: HasPartial + TransformObject, T: HasPartial + TransformObject,
T::Partial: TransformObject, T::Partial: TransformObject,
{ {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
match self { match self {
Self::Full(full) => Self::Full(full.transform(transform, stores)), Self::Full(full) => Self::Full(full.transform(transform, objects)),
Self::Partial(partial) => { Self::Partial(partial) => {
Self::Partial(partial.transform(transform, stores)) Self::Partial(partial.transform(transform, objects))
} }
} }
} }

View File

@ -1,11 +1,11 @@
use fj_math::Transform; use fj_math::Transform;
use crate::{path::GlobalPath, stores::Stores}; use crate::{objects::Objects, path::GlobalPath};
use super::TransformObject; use super::TransformObject;
impl TransformObject for GlobalPath { impl TransformObject for GlobalPath {
fn transform(self, transform: &Transform, _: &Stores) -> Self { fn transform(self, transform: &Transform, _: &Objects) -> Self {
match self { match self {
Self::Circle(curve) => { Self::Circle(curve) => {
Self::Circle(transform.transform_circle(&curve)) Self::Circle(transform.transform_circle(&curve))

View File

@ -1,15 +1,15 @@
use fj_math::Transform; use fj_math::Transform;
use crate::{objects::Shell, stores::Stores}; use crate::objects::{Objects, Shell};
use super::TransformObject; use super::TransformObject;
impl TransformObject for Shell { impl TransformObject for Shell {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
let faces = self let faces = self
.into_faces() .into_faces()
.into_iter() .into_iter()
.map(|face| face.transform(transform, stores)); .map(|face| face.transform(transform, objects));
Self::new().with_faces(faces) Self::new().with_faces(faces)
} }
} }

View File

@ -1,15 +1,15 @@
use fj_math::Transform; use fj_math::Transform;
use crate::{objects::Sketch, stores::Stores}; use crate::objects::{Objects, Sketch};
use super::TransformObject; use super::TransformObject;
impl TransformObject for Sketch { impl TransformObject for Sketch {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
let faces = self let faces = self
.into_faces() .into_faces()
.into_iter() .into_iter()
.map(|face| face.transform(transform, stores)); .map(|face| face.transform(transform, objects));
Self::new().with_faces(faces) Self::new().with_faces(faces)
} }
} }

View File

@ -1,14 +1,14 @@
use fj_math::Transform; use fj_math::Transform;
use crate::{objects::Solid, stores::Stores}; use crate::objects::{Objects, Solid};
use super::TransformObject; use super::TransformObject;
impl TransformObject for Solid { impl TransformObject for Solid {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
let faces = self let faces = self
.into_shells() .into_shells()
.map(|shell| shell.transform(transform, stores)); .map(|shell| shell.transform(transform, objects));
Self::new().with_shells(faces) Self::new().with_shells(faces)
} }
} }

View File

@ -1,16 +1,16 @@
use fj_math::Transform; use fj_math::Transform;
use crate::{ use crate::{
objects::Surface, objects::{Objects, Surface},
stores::{Handle, Stores}, storage::Handle,
}; };
use super::TransformObject; use super::TransformObject;
impl TransformObject for Handle<Surface> { impl TransformObject for Handle<Surface> {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
stores.surfaces.insert(Surface::new( objects.surfaces.insert(Surface::new(
self.u().transform(transform, stores), self.u().transform(transform, objects),
transform.transform_vector(&self.v()), transform.transform_vector(&self.v()),
)) ))
} }

View File

@ -1,24 +1,24 @@
use fj_math::Transform; use fj_math::Transform;
use crate::{ use crate::{
objects::Objects,
partial::{PartialGlobalVertex, PartialSurfaceVertex, PartialVertex}, partial::{PartialGlobalVertex, PartialSurfaceVertex, PartialVertex},
stores::Stores,
}; };
use super::TransformObject; use super::TransformObject;
impl TransformObject for PartialVertex { impl TransformObject for PartialVertex {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
let curve = self.curve.map(|curve| curve.transform(transform, stores)); let curve = self.curve.map(|curve| curve.transform(transform, objects));
let surface_form = self.surface_form.map(|surface_form| { let surface_form = self.surface_form.map(|surface_form| {
surface_form surface_form
.into_partial() .into_partial()
.transform(transform, stores) .transform(transform, objects)
.into() .into()
}); });
let global_form = self let global_form = self
.global_form .global_form
.map(|global_form| global_form.transform(transform, stores)); .map(|global_form| global_form.transform(transform, objects));
// Don't need to transform `self.position`, as that is in curve // Don't need to transform `self.position`, as that is in curve
// coordinates and thus transforming the curve takes care of it. // coordinates and thus transforming the curve takes care of it.
@ -32,13 +32,13 @@ impl TransformObject for PartialVertex {
} }
impl TransformObject for PartialSurfaceVertex { impl TransformObject for PartialSurfaceVertex {
fn transform(self, transform: &Transform, stores: &Stores) -> Self { fn transform(self, transform: &Transform, objects: &Objects) -> Self {
let surface = self let surface = self
.surface .surface
.map(|surface| surface.transform(transform, stores)); .map(|surface| surface.transform(transform, objects));
let global_form = self let global_form = self
.global_form .global_form
.map(|global_form| global_form.transform(transform, stores)); .map(|global_form| global_form.transform(transform, objects));
// Don't need to transform `self.position`, as that is in surface // Don't need to transform `self.position`, as that is in surface
// coordinates and thus transforming the surface takes care of it. // coordinates and thus transforming the surface takes care of it.
@ -51,7 +51,7 @@ impl TransformObject for PartialSurfaceVertex {
} }
impl TransformObject for PartialGlobalVertex { impl TransformObject for PartialGlobalVertex {
fn transform(self, transform: &Transform, _: &Stores) -> Self { fn transform(self, transform: &Transform, _: &Objects) -> Self {
let position = self let position = self
.position .position
.map(|position| transform.transform_point(&position)); .map(|position| transform.transform_point(&position));

View File

@ -84,23 +84,22 @@ mod tests {
use crate::{ use crate::{
algorithms::approx::{Approx, Tolerance}, algorithms::approx::{Approx, Tolerance},
objects::{Face, Surface}, objects::{Face, Objects, Surface},
stores::Stores,
}; };
use super::Triangulate; use super::Triangulate;
#[test] #[test]
fn simple() -> anyhow::Result<()> { fn simple() -> anyhow::Result<()> {
let stores = Stores::new(); let objects = Objects::new();
let a = [0., 0.]; let a = [0., 0.];
let b = [2., 0.]; let b = [2., 0.];
let c = [2., 2.]; let c = [2., 2.];
let d = [0., 1.]; let d = [0., 1.];
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([a, b, c, d]) .with_exterior_polygon_from_points([a, b, c, d])
.build(); .build();
@ -121,7 +120,7 @@ mod tests {
#[test] #[test]
fn simple_hole() -> anyhow::Result<()> { fn simple_hole() -> anyhow::Result<()> {
let stores = Stores::new(); let objects = Objects::new();
let a = [0., 0.]; let a = [0., 0.];
let b = [4., 0.]; let b = [4., 0.];
@ -133,8 +132,8 @@ mod tests {
let g = [3., 3.]; let g = [3., 3.];
let h = [3., 1.]; let h = [3., 1.];
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface.clone()) let face = Face::builder(&objects, surface.clone())
.with_exterior_polygon_from_points([a, b, c, d]) .with_exterior_polygon_from_points([a, b, c, d])
.with_interior_polygon_from_points([e, f, g, h]) .with_interior_polygon_from_points([e, f, g, h])
.build(); .build();
@ -172,7 +171,7 @@ mod tests {
#[ignore] #[ignore]
#[test] #[test]
fn sharp_concave_shape() -> anyhow::Result<()> { fn sharp_concave_shape() -> anyhow::Result<()> {
let stores = Stores::new(); let objects = Objects::new();
// //
// c // c
@ -193,8 +192,8 @@ mod tests {
let d = [0.1, 0.1]; let d = [0.1, 0.1];
let e = [0., 0.8]; let e = [0., 0.8];
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface.clone()) let face = Face::builder(&objects, surface.clone())
.with_exterior_polygon_from_points([a, b, c, d, e]) .with_exterior_polygon_from_points([a, b, c, d, e])
.build(); .build();

View File

@ -36,21 +36,19 @@ pub trait Validate: Sized {
/// ``` rust /// ``` rust
/// # use fj_kernel::{ /// # use fj_kernel::{
/// # algorithms::validate::{Validate, ValidationConfig}, /// # algorithms::validate::{Validate, ValidationConfig},
/// # objects::GlobalVertex, /// # objects::{GlobalVertex, Objects},
/// # stores::Stores,
/// # }; /// # };
/// # let stores = Stores::new(); /// # let objects = Objects::new();
/// # let object = GlobalVertex::from_position([0., 0., 0.], &stores); /// # let object = GlobalVertex::from_position([0., 0., 0.], &objects);
/// object.validate(); /// object.validate();
/// ``` /// ```
/// ``` rust /// ``` rust
/// # use fj_kernel::{ /// # use fj_kernel::{
/// # algorithms::validate::{Validate, ValidationConfig}, /// # algorithms::validate::{Validate, ValidationConfig},
/// # objects::GlobalVertex, /// # objects::{GlobalVertex, Objects},
/// # stores::Stores,
/// # }; /// # };
/// # let stores = Stores::new(); /// # let objects = Objects::new();
/// # let object = GlobalVertex::from_position([0., 0., 0.], &stores); /// # let object = GlobalVertex::from_position([0., 0., 0.], &objects);
/// object.validate_with_config(&ValidationConfig::default()); /// object.validate_with_config(&ValidationConfig::default());
/// ``` /// ```
fn validate(self) -> Result<Validated<Self>, ValidationError> { fn validate(self) -> Result<Validated<Self>, ValidationError> {
@ -168,32 +166,31 @@ mod tests {
use crate::{ use crate::{
algorithms::validate::{Validate, ValidationConfig, ValidationError}, algorithms::validate::{Validate, ValidationConfig, ValidationError},
objects::{ objects::{
Curve, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Surface, Curve, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Objects,
SurfaceVertex, Vertex, Surface, SurfaceVertex, Vertex,
}, },
partial::HasPartial, partial::HasPartial,
path::SurfacePath, path::SurfacePath,
stores::Stores,
}; };
#[test] #[test]
fn coherence_edge() { fn coherence_edge() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let points_surface = [[0., 0.], [1., 0.]]; let points_surface = [[0., 0.], [1., 0.]];
let points_global = [[0., 0., 0.], [1., 0., 0.]]; let points_global = [[0., 0., 0.], [1., 0., 0.]];
let curve = { let curve = {
let path = SurfacePath::line_from_points(points_surface); let path = SurfacePath::line_from_points(points_surface);
let global_form = GlobalCurve::new(&stores); let global_form = GlobalCurve::new(&objects);
Curve::new(surface.clone(), path, global_form, &stores) Curve::new(surface.clone(), path, global_form, &objects)
}; };
let [a_global, b_global] = points_global let [a_global, b_global] = points_global
.map(|point| GlobalVertex::from_position(point, &stores)); .map(|point| GlobalVertex::from_position(point, &objects));
let [a_surface, b_surface] = { let [a_surface, b_surface] = {
// Can be cleaned up, once `zip` is stable: // Can be cleaned up, once `zip` is stable:
@ -223,7 +220,7 @@ mod tests {
let global_edge = GlobalEdge::partial() let global_edge = GlobalEdge::partial()
.from_curve_and_vertices(&curve, &vertices) .from_curve_and_vertices(&curve, &vertices)
.build(&stores); .build(&objects);
let half_edge = HalfEdge::new(vertices, global_edge); let half_edge = HalfEdge::new(vertices, global_edge);
let result = let result =
@ -242,7 +239,7 @@ mod tests {
#[test] #[test]
fn uniqueness_vertex() -> anyhow::Result<()> { fn uniqueness_vertex() -> anyhow::Result<()> {
let stores = Stores::new(); let objects = Objects::new();
let mut shape = Vec::new(); let mut shape = Vec::new();
let deviation = Scalar::from_f64(0.25); let deviation = Scalar::from_f64(0.25);
@ -258,11 +255,11 @@ mod tests {
}; };
// Adding a vertex should work. // Adding a vertex should work.
shape.push(GlobalVertex::from_position(a, &stores)); shape.push(GlobalVertex::from_position(a, &objects));
shape.clone().validate_with_config(&config)?; shape.clone().validate_with_config(&config)?;
// Adding a second vertex that is considered identical should fail. // Adding a second vertex that is considered identical should fail.
shape.push(GlobalVertex::from_position(b, &stores)); shape.push(GlobalVertex::from_position(b, &objects));
let result = shape.validate_with_config(&config); let result = shape.validate_with_config(&config);
assert!(matches!(result, Err(ValidationError::Uniqueness(_)))); assert!(matches!(result, Err(ValidationError::Uniqueness(_))));

View File

@ -1,9 +1,9 @@
use fj_math::Point; use fj_math::Point;
use crate::{ use crate::{
objects::{Cycle, Face, Surface}, objects::{Cycle, Face, Objects, Surface},
partial::HasPartial, partial::HasPartial,
stores::{Handle, Stores}, storage::Handle,
}; };
/// API for building a [`Face`] /// API for building a [`Face`]
@ -11,7 +11,7 @@ use crate::{
/// Also see [`Face::builder`]. /// Also see [`Face::builder`].
pub struct FaceBuilder<'a> { pub struct FaceBuilder<'a> {
/// The stores that the created objects are put in /// The stores that the created objects are put in
pub stores: &'a Stores, pub objects: &'a Objects,
/// The surface that the [`Face`] is defined in /// The surface that the [`Face`] is defined in
pub surface: Handle<Surface>, pub surface: Handle<Surface>,
@ -37,7 +37,7 @@ impl<'a> FaceBuilder<'a> {
.with_surface(Some(self.surface.clone())) .with_surface(Some(self.surface.clone()))
.with_poly_chain_from_points(points) .with_poly_chain_from_points(points)
.close_with_line_segment() .close_with_line_segment()
.build(self.stores), .build(self.objects),
); );
self self
} }
@ -52,7 +52,7 @@ impl<'a> FaceBuilder<'a> {
.with_surface(Some(self.surface.clone())) .with_surface(Some(self.surface.clone()))
.with_poly_chain_from_points(points) .with_poly_chain_from_points(points)
.close_with_line_segment() .close_with_line_segment()
.build(self.stores), .build(self.objects),
); );
self self
} }

View File

@ -3,10 +3,11 @@ use fj_math::Scalar;
use crate::{ use crate::{
algorithms::transform::TransformObject, algorithms::transform::TransformObject,
objects::{ objects::{
Curve, Cycle, Face, HalfEdge, Shell, Surface, SurfaceVertex, Vertex, Curve, Cycle, Face, HalfEdge, Objects, Shell, Surface, SurfaceVertex,
Vertex,
}, },
partial::HasPartial, partial::HasPartial,
stores::{Handle, Stores}, storage::Handle,
}; };
/// API for building a [`Shell`] /// API for building a [`Shell`]
@ -14,7 +15,7 @@ use crate::{
/// Also see [`Shell::builder`]. /// Also see [`Shell::builder`].
pub struct ShellBuilder<'a> { pub struct ShellBuilder<'a> {
/// The stores that the created objects are put in /// The stores that the created objects are put in
pub stores: &'a Stores, pub objects: &'a Objects,
} }
impl<'a> ShellBuilder<'a> { impl<'a> ShellBuilder<'a> {
@ -31,12 +32,12 @@ impl<'a> ShellBuilder<'a> {
let bottom = { let bottom = {
let surface = self let surface = self
.stores .objects
.surfaces .surfaces
.insert(Surface::xy_plane()) .insert(Surface::xy_plane())
.translate([Z, Z, -h], self.stores); .translate([Z, Z, -h], self.objects);
Face::builder(self.stores, surface) Face::builder(self.objects, surface)
.with_exterior_polygon_from_points([ .with_exterior_polygon_from_points([
[-h, -h], [-h, -h],
[h, -h], [h, -h],
@ -57,7 +58,7 @@ impl<'a> ShellBuilder<'a> {
.map(|vertex| vertex.global_form().position()); .map(|vertex| vertex.global_form().position());
let c = a + [Z, Z, edge_length]; let c = a + [Z, Z, edge_length];
self.stores self.objects
.surfaces .surfaces
.insert(Surface::plane_from_points([a, b, c])) .insert(Surface::plane_from_points([a, b, c]))
}) })
@ -72,7 +73,7 @@ impl<'a> ShellBuilder<'a> {
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.with_global_form(Some(half_edge.global_form().clone())) .with_global_form(Some(half_edge.global_form().clone()))
.as_line_segment_from_points([[Z, Z], [edge_length, Z]]) .as_line_segment_from_points([[Z, Z], [edge_length, Z]])
.build(self.stores) .build(self.objects)
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -94,7 +95,7 @@ impl<'a> ShellBuilder<'a> {
Vertex::partial().with_surface_form(Some(to)), Vertex::partial().with_surface_form(Some(to)),
])) ]))
.as_line_segment() .as_line_segment()
.build(self.stores) .build(self.objects)
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -131,7 +132,7 @@ impl<'a> ShellBuilder<'a> {
Vertex::partial().with_surface_form(Some(to)), Vertex::partial().with_surface_form(Some(to)),
])) ]))
.as_line_segment() .as_line_segment()
.build(self.stores) .build(self.objects)
}) })
.collect::<Vec<_>>() .collect::<Vec<_>>()
}; };
@ -159,7 +160,7 @@ impl<'a> ShellBuilder<'a> {
HalfEdge::partial() HalfEdge::partial()
.with_vertices(Some([from, to])) .with_vertices(Some([from, to]))
.as_line_segment() .as_line_segment()
.build(self.stores) .build(self.objects)
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -173,7 +174,7 @@ impl<'a> ShellBuilder<'a> {
let cycle = Cycle::partial() let cycle = Cycle::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.with_half_edges([bottom, side_up, top, side_down]) .with_half_edges([bottom, side_up, top, side_down])
.build(self.stores); .build(self.objects);
Face::from_exterior(cycle) Face::from_exterior(cycle)
}); });
@ -183,10 +184,10 @@ impl<'a> ShellBuilder<'a> {
let top = { let top = {
let surface = self let surface = self
.stores .objects
.surfaces .surfaces
.insert(Surface::xy_plane()) .insert(Surface::xy_plane())
.translate([Z, Z, h], self.stores); .translate([Z, Z, h], self.objects);
let points = [[-h, -h], [-h, h], [h, h], [h, -h], [-h, -h]]; let points = [[-h, -h], [-h, h], [h, h], [h, -h], [-h, -h]];
@ -211,7 +212,7 @@ impl<'a> ShellBuilder<'a> {
.with_global_form(Some( .with_global_form(Some(
vertex.global_form().clone(), vertex.global_form().clone(),
)) ))
.build(self.stores); .build(self.objects);
Vertex::partial() Vertex::partial()
.with_position(Some(vertex.position())) .with_position(Some(vertex.position()))
.with_surface_form(Some(surface_form)) .with_surface_form(Some(surface_form))
@ -223,7 +224,7 @@ impl<'a> ShellBuilder<'a> {
.with_vertices(Some(vertices)) .with_vertices(Some(vertices))
.with_global_form(Some(edge.global_form().clone())) .with_global_form(Some(edge.global_form().clone()))
.as_line_segment() .as_line_segment()
.build(self.stores), .build(self.objects),
); );
} }

View File

@ -1,8 +1,8 @@
use fj_math::Point; use fj_math::Point;
use crate::{ use crate::{
objects::{Face, Sketch, Surface}, objects::{Face, Objects, Sketch, Surface},
stores::{Handle, Stores}, storage::Handle,
}; };
/// API for building a [`Sketch`] /// API for building a [`Sketch`]
@ -10,7 +10,7 @@ use crate::{
/// Also see [`Sketch::builder`]. /// Also see [`Sketch::builder`].
pub struct SketchBuilder<'a> { pub struct SketchBuilder<'a> {
/// The stores that the created objects are put in /// The stores that the created objects are put in
pub stores: &'a Stores, pub objects: &'a Objects,
/// The surface that the [`Sketch`] is defined in /// The surface that the [`Sketch`] is defined in
pub surface: Handle<Surface>, pub surface: Handle<Surface>,
@ -22,7 +22,7 @@ impl<'a> SketchBuilder<'a> {
self, self,
points: impl IntoIterator<Item = impl Into<Point<2>>>, points: impl IntoIterator<Item = impl Into<Point<2>>>,
) -> Sketch { ) -> Sketch {
let face = Face::builder(self.stores, self.surface) let face = Face::builder(self.objects, self.surface)
.with_exterior_polygon_from_points(points) .with_exterior_polygon_from_points(points)
.build(); .build();
Sketch::new().with_faces([face]) Sketch::new().with_faces([face])

View File

@ -1,16 +1,13 @@
use fj_math::Scalar; use fj_math::Scalar;
use crate::{ use crate::objects::{Objects, Shell, Solid};
objects::{Shell, Solid},
stores::Stores,
};
/// API for building a [`Solid`] /// API for building a [`Solid`]
/// ///
/// Also see [`Solid::builder`]. /// Also see [`Solid::builder`].
pub struct SolidBuilder<'a> { pub struct SolidBuilder<'a> {
/// The stores that the created objects are put in /// The stores that the created objects are put in
pub stores: &'a Stores, pub objects: &'a Objects,
} }
impl<'a> SolidBuilder<'a> { impl<'a> SolidBuilder<'a> {
@ -19,7 +16,7 @@ impl<'a> SolidBuilder<'a> {
self, self,
edge_length: impl Into<Scalar>, edge_length: impl Into<Scalar>,
) -> Solid { ) -> Solid {
let shell = Shell::builder(self.stores) let shell = Shell::builder(self.objects)
.build_cube_from_edge_length(edge_length); .build_cube_from_edge_length(edge_length);
Solid::new().with_shells([shell]) Solid::new().with_shells([shell])
} }

View File

@ -7,7 +7,7 @@ use crate::{
Curve, Cycle, Face, GlobalCurve, GlobalVertex, HalfEdge, Shell, Sketch, Curve, Cycle, Face, GlobalCurve, GlobalVertex, HalfEdge, Shell, Sketch,
Solid, Surface, Vertex, Solid, Surface, Vertex,
}, },
stores::Handle, storage::Handle,
}; };
/// Access iterators over all objects of a shape, or part of it /// Access iterators over all objects of a shape, or part of it
@ -361,24 +361,24 @@ impl<T> Iterator for Iter<T> {
mod tests { mod tests {
use crate::{ use crate::{
objects::{ objects::{
Curve, Cycle, Face, GlobalCurve, GlobalVertex, HalfEdge, Shell, Curve, Cycle, Face, GlobalCurve, GlobalVertex, HalfEdge, Objects,
Sketch, Solid, Surface, SurfaceVertex, Vertex, Shell, Sketch, Solid, Surface, SurfaceVertex, Vertex,
}, },
partial::HasPartial, partial::HasPartial,
stores::{Handle, Stores}, storage::Handle,
}; };
use super::ObjectIters as _; use super::ObjectIters as _;
#[test] #[test]
fn curve() { fn curve() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let object = Handle::<Curve>::partial() let object = Handle::<Curve>::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.as_u_axis() .as_u_axis()
.build(&stores); .build(&objects);
assert_eq!(1, object.curve_iter().count()); assert_eq!(1, object.curve_iter().count());
assert_eq!(0, object.cycle_iter().count()); assert_eq!(0, object.cycle_iter().count());
@ -395,14 +395,14 @@ mod tests {
#[test] #[test]
fn cycle() { fn cycle() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let object = Cycle::partial() let object = Cycle::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.with_poly_chain_from_points([[0., 0.], [1., 0.], [0., 1.]]) .with_poly_chain_from_points([[0., 0.], [1., 0.], [0., 1.]])
.close_with_line_segment() .close_with_line_segment()
.build(&stores); .build(&objects);
assert_eq!(3, object.curve_iter().count()); assert_eq!(3, object.curve_iter().count());
assert_eq!(1, object.cycle_iter().count()); assert_eq!(1, object.cycle_iter().count());
@ -419,10 +419,10 @@ mod tests {
#[test] #[test]
fn face() { fn face() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let object = Face::builder(&stores, surface) let object = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]]) .with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]])
.build(); .build();
@ -441,9 +441,9 @@ mod tests {
#[test] #[test]
fn global_curve() { fn global_curve() {
let stores = Stores::new(); let objects = Objects::new();
let object = GlobalCurve::new(&stores); let object = GlobalCurve::new(&objects);
assert_eq!(0, object.curve_iter().count()); assert_eq!(0, object.curve_iter().count());
assert_eq!(0, object.cycle_iter().count()); assert_eq!(0, object.cycle_iter().count());
@ -460,9 +460,9 @@ mod tests {
#[test] #[test]
fn global_vertex() { fn global_vertex() {
let stores = Stores::new(); let objects = Objects::new();
let object = GlobalVertex::from_position([0., 0., 0.], &stores); let object = GlobalVertex::from_position([0., 0., 0.], &objects);
assert_eq!(0, object.curve_iter().count()); assert_eq!(0, object.curve_iter().count());
assert_eq!(0, object.cycle_iter().count()); assert_eq!(0, object.cycle_iter().count());
@ -479,12 +479,12 @@ mod tests {
#[test] #[test]
fn half_edge() { fn half_edge() {
let stores = Stores::new(); let objects = Objects::new();
let object = HalfEdge::partial() let object = HalfEdge::partial()
.with_surface(Some(stores.surfaces.insert(Surface::xy_plane()))) .with_surface(Some(objects.surfaces.insert(Surface::xy_plane())))
.as_line_segment_from_points([[0., 0.], [1., 0.]]) .as_line_segment_from_points([[0., 0.], [1., 0.]])
.build(&stores); .build(&objects);
assert_eq!(1, object.curve_iter().count()); assert_eq!(1, object.curve_iter().count());
assert_eq!(0, object.cycle_iter().count()); assert_eq!(0, object.cycle_iter().count());
@ -501,9 +501,9 @@ mod tests {
#[test] #[test]
fn shell() { fn shell() {
let stores = Stores::new(); let objects = Objects::new();
let object = Shell::builder(&stores).build_cube_from_edge_length(1.); let object = Shell::builder(&objects).build_cube_from_edge_length(1.);
assert_eq!(24, object.curve_iter().count()); assert_eq!(24, object.curve_iter().count());
assert_eq!(6, object.cycle_iter().count()); assert_eq!(6, object.cycle_iter().count());
@ -520,10 +520,10 @@ mod tests {
#[test] #[test]
fn sketch() { fn sketch() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let face = Face::builder(&stores, surface) let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]]) .with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]])
.build(); .build();
let object = Sketch::new().with_faces([face]); let object = Sketch::new().with_faces([face]);
@ -543,9 +543,9 @@ mod tests {
#[test] #[test]
fn solid() { fn solid() {
let stores = Stores::new(); let objects = Objects::new();
let object = Solid::builder(&stores).build_cube_from_edge_length(1.); let object = Solid::builder(&objects).build_cube_from_edge_length(1.);
assert_eq!(24, object.curve_iter().count()); assert_eq!(24, object.curve_iter().count());
assert_eq!(6, object.cycle_iter().count()); assert_eq!(6, object.cycle_iter().count());
@ -562,9 +562,9 @@ mod tests {
#[test] #[test]
fn surface() { fn surface() {
let stores = Stores::new(); let objects = Objects::new();
let object = stores.surfaces.insert(Surface::xy_plane()); let object = objects.surfaces.insert(Surface::xy_plane());
assert_eq!(0, object.curve_iter().count()); assert_eq!(0, object.curve_iter().count());
assert_eq!(0, object.cycle_iter().count()); assert_eq!(0, object.cycle_iter().count());
@ -581,14 +581,14 @@ mod tests {
#[test] #[test]
fn vertex() { fn vertex() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let curve = Handle::<Curve>::partial() let curve = Handle::<Curve>::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_u_axis() .as_u_axis()
.build(&stores); .build(&objects);
let global_vertex = GlobalVertex::from_position([0., 0., 0.], &stores); let global_vertex = GlobalVertex::from_position([0., 0., 0.], &objects);
let surface_vertex = let surface_vertex =
SurfaceVertex::new([0., 0.], surface, global_vertex); SurfaceVertex::new([0., 0.], surface, global_vertex);
let object = Vertex::new([0.], curve, surface_vertex); let object = Vertex::new([0.], curve, surface_vertex);

View File

@ -93,4 +93,4 @@ pub mod iter;
pub mod objects; pub mod objects;
pub mod partial; pub mod partial;
pub mod path; pub mod path;
pub mod stores; pub mod storage;

View File

@ -1,9 +1,9 @@
use crate::{ use crate::{
path::SurfacePath, path::SurfacePath,
stores::{Handle, HandleWrapper, Stores}, storage::{Handle, HandleWrapper},
}; };
use super::Surface; use super::{Objects, Surface};
/// A curve, defined in local surface coordinates /// A curve, defined in local surface coordinates
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
@ -19,9 +19,9 @@ impl Curve {
surface: Handle<Surface>, surface: Handle<Surface>,
path: SurfacePath, path: SurfacePath,
global_form: impl Into<HandleWrapper<GlobalCurve>>, global_form: impl Into<HandleWrapper<GlobalCurve>>,
stores: &Stores, objects: &Objects,
) -> Handle<Self> { ) -> Handle<Self> {
stores.curves.insert(Self { objects.curves.insert(Self {
surface, surface,
path, path,
global_form: global_form.into(), global_form: global_form.into(),
@ -50,7 +50,7 @@ pub struct GlobalCurve;
impl GlobalCurve { impl GlobalCurve {
/// Construct a new instance of `Handle` and add it to the store /// Construct a new instance of `Handle` and add it to the store
pub fn new(stores: &Stores) -> Handle<Self> { pub fn new(objects: &Objects) -> Handle<Self> {
stores.global_curves.insert(GlobalCurve) objects.global_curves.insert(GlobalCurve)
} }
} }

View File

@ -1,7 +1,7 @@
use fj_math::{Scalar, Winding}; use fj_math::{Scalar, Winding};
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use crate::{path::SurfacePath, stores::Handle}; use crate::{path::SurfacePath, storage::Handle};
use super::{HalfEdge, Surface}; use super::{HalfEdge, Surface};

View File

@ -2,7 +2,7 @@ use std::fmt;
use pretty_assertions::{assert_eq, assert_ne}; use pretty_assertions::{assert_eq, assert_ne};
use crate::stores::{Handle, HandleWrapper}; use crate::storage::{Handle, HandleWrapper};
use super::{Curve, GlobalCurve, GlobalVertex, Vertex}; use super::{Curve, GlobalCurve, GlobalVertex, Vertex};
@ -172,15 +172,18 @@ impl VerticesInNormalizedOrder {
mod tests { mod tests {
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use crate::{objects::Surface, partial::HasPartial, stores::Stores}; use crate::{
objects::{Objects, Surface},
partial::HasPartial,
};
use super::HalfEdge; use super::HalfEdge;
#[test] #[test]
fn global_edge_equality() { fn global_edge_equality() {
let stores = Stores::new(); let objects = Objects::new();
let surface = stores.surfaces.insert(Surface::xy_plane()); let surface = objects.surfaces.insert(Surface::xy_plane());
let a = [0., 0.]; let a = [0., 0.];
let b = [1., 0.]; let b = [1., 0.];
@ -188,11 +191,11 @@ mod tests {
let a_to_b = HalfEdge::partial() let a_to_b = HalfEdge::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_line_segment_from_points([a, b]) .as_line_segment_from_points([a, b])
.build(&stores); .build(&objects);
let b_to_a = HalfEdge::partial() let b_to_a = HalfEdge::partial()
.with_surface(Some(surface)) .with_surface(Some(surface))
.as_line_segment_from_points([b, a]) .as_line_segment_from_points([b, a])
.build(&stores); .build(&objects);
assert_eq!(a_to_b.global_form(), b_to_a.global_form()); assert_eq!(a_to_b.global_form(), b_to_a.global_form());
} }

View File

@ -3,12 +3,9 @@ use std::collections::{btree_set, BTreeSet};
use fj_interop::mesh::Color; use fj_interop::mesh::Color;
use fj_math::Winding; use fj_math::Winding;
use crate::{ use crate::{builder::FaceBuilder, storage::Handle};
builder::FaceBuilder,
stores::{Handle, Stores},
};
use super::{Cycle, Surface}; use super::{Cycle, Objects, Surface};
/// A face of a shape /// A face of a shape
/// ///
@ -44,9 +41,9 @@ pub struct Face {
impl Face { impl Face {
/// Build a `Face` using [`FaceBuilder`] /// Build a `Face` using [`FaceBuilder`]
pub fn builder(stores: &Stores, surface: Handle<Surface>) -> FaceBuilder { pub fn builder(objects: &Objects, surface: Handle<Surface>) -> FaceBuilder {
FaceBuilder { FaceBuilder {
stores, objects,
surface, surface,
exterior: None, exterior: None,
interiors: Vec::new(), interiors: Vec::new(),

View File

@ -58,7 +58,7 @@
//! ## How Identity Works //! ## How Identity Works
//! //!
//! We can exactly determine the identity of an object, thanks to [centralized //! We can exactly determine the identity of an object, thanks to [centralized
//! object storage][`Stores`]. If objects are created at different times, //! object storage][`Objects`]. If objects are created at different times,
//! potentially by different code, they end up being stored at different memory //! potentially by different code, they end up being stored at different memory
//! locations, regardless of their (non-)equality. //! locations, regardless of their (non-)equality.
//! //!
@ -70,8 +70,7 @@
//! As of this writing, most objects are not managed in the centralized object //! As of this writing, most objects are not managed in the centralized object
//! storage. Changing this is an ongoing effort ([#1021]). //! storage. Changing this is an ongoing effort ([#1021]).
//! //!
//! [`Stores`]: crate::stores::Stores //! [`Handle`]: crate::storage::Handle
//! [`Handle`]: crate::stores::Handle
//! [#1021]: https://github.com/hannobraun/Fornjot/issues/1021 //! [#1021]: https://github.com/hannobraun/Fornjot/issues/1021
mod curve; mod curve;
@ -84,6 +83,8 @@ mod solid;
mod surface; mod surface;
mod vertex; mod vertex;
use crate::storage::Store;
pub use self::{ pub use self::{
curve::{Curve, GlobalCurve}, curve::{Curve, GlobalCurve},
cycle::Cycle, cycle::Cycle,
@ -95,3 +96,33 @@ pub use self::{
surface::Surface, surface::Surface,
vertex::{GlobalVertex, SurfaceVertex, Vertex}, vertex::{GlobalVertex, SurfaceVertex, Vertex},
}; };
/// The available object stores
///
/// # Implementation Note
///
/// The intention is to eventually manage all objects in here. Making this
/// happen is simply a case of putting in the required work. See [#1021].
///
/// [#1021]: https://github.com/hannobraun/Fornjot/issues/1021
#[derive(Debug, Default)]
pub struct Objects {
/// Store for curves
pub curves: Store<Curve>,
/// Store for global curves
pub global_curves: Store<GlobalCurve>,
/// Store for global vertices
pub global_vertices: Store<GlobalVertex>,
/// Store for surfaces
pub surfaces: Store<Surface>,
}
impl Objects {
/// Construct a new instance of `Stores`
pub fn new() -> Self {
Self::default()
}
}

View File

@ -1,6 +1,6 @@
use crate::{builder::ShellBuilder, stores::Stores}; use crate::builder::ShellBuilder;
use super::{face::Faces, Face}; use super::{face::Faces, Face, Objects};
/// A 3-dimensional closed shell /// A 3-dimensional closed shell
/// ///
@ -15,8 +15,8 @@ pub struct Shell {
impl Shell { impl Shell {
/// Build a `Shell` using [`ShellBuilder`] /// Build a `Shell` using [`ShellBuilder`]
pub fn builder(stores: &Stores) -> ShellBuilder { pub fn builder(objects: &Objects) -> ShellBuilder {
ShellBuilder { stores } ShellBuilder { objects }
} }
/// Construct an empty instance of `Shell` /// Construct an empty instance of `Shell`

View File

@ -1,9 +1,6 @@
use crate::{ use crate::{builder::SketchBuilder, storage::Handle};
builder::SketchBuilder,
stores::{Handle, Stores},
};
use super::{face::Faces, Face, Surface}; use super::{face::Faces, Face, Objects, Surface};
/// A 2-dimensional shape /// A 2-dimensional shape
/// ///
@ -18,8 +15,11 @@ pub struct Sketch {
impl Sketch { impl Sketch {
/// Build a `Sketch` using [`SketchBuilder`] /// Build a `Sketch` using [`SketchBuilder`]
pub fn builder(stores: &Stores, surface: Handle<Surface>) -> SketchBuilder { pub fn builder(
SketchBuilder { stores, surface } objects: &Objects,
surface: Handle<Surface>,
) -> SketchBuilder {
SketchBuilder { objects, surface }
} }
/// Construct an empty instance of `Sketch` /// Construct an empty instance of `Sketch`

View File

@ -1,8 +1,8 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use crate::{builder::SolidBuilder, stores::Stores}; use crate::builder::SolidBuilder;
use super::{Face, Shell}; use super::{Face, Objects, Shell};
/// A 3-dimensional shape /// A 3-dimensional shape
/// ///
@ -17,8 +17,8 @@ pub struct Solid {
impl Solid { impl Solid {
/// Build a `Solid` using [`SolidBuilder`] /// Build a `Solid` using [`SolidBuilder`]
pub fn builder(stores: &Stores) -> SolidBuilder { pub fn builder(objects: &Objects) -> SolidBuilder {
SolidBuilder { stores } SolidBuilder { objects }
} }
/// Construct an empty instance of `Solid` /// Construct an empty instance of `Solid`

View File

@ -1,9 +1,9 @@
use fj_math::Point; use fj_math::Point;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use crate::stores::{Handle, Stores}; use crate::storage::Handle;
use super::{Curve, Surface}; use super::{Curve, Objects, Surface};
/// A vertex /// A vertex
/// ///
@ -129,10 +129,10 @@ impl GlobalVertex {
/// Construct a `GlobalVertex` from a position /// Construct a `GlobalVertex` from a position
pub fn from_position( pub fn from_position(
position: impl Into<Point<3>>, position: impl Into<Point<3>>,
stores: &Stores, objects: &Objects,
) -> Handle<Self> { ) -> Handle<Self> {
let position = position.into(); let position = position.into();
stores.global_vertices.insert(Self { position }) objects.global_vertices.insert(Self { position })
} }
/// Access the position of the vertex /// Access the position of the vertex

View File

@ -2,10 +2,10 @@ use fj_math::Point;
use crate::{ use crate::{
objects::{ objects::{
Curve, GlobalCurve, GlobalEdge, HalfEdge, Surface, SurfaceVertex, Curve, GlobalCurve, GlobalEdge, HalfEdge, Objects, Surface,
Vertex, SurfaceVertex, Vertex,
}, },
stores::{Handle, Stores}, storage::Handle,
}; };
use super::{HasPartial, Partial}; use super::{HasPartial, Partial};
@ -48,9 +48,9 @@ impl<T: HasPartial> MaybePartial<T> {
/// ///
/// If this already is a full object, it is returned. If this is a partial /// If this already is a full object, it is returned. If this is a partial
/// object, the full object is built from it, using [`Partial::build`]. /// object, the full object is built from it, using [`Partial::build`].
pub fn into_full(self, stores: &Stores) -> T { pub fn into_full(self, objects: &Objects) -> T {
match self { match self {
Self::Partial(partial) => partial.build(stores), Self::Partial(partial) => partial.build(objects),
Self::Full(full) => full, Self::Full(full) => full,
} }
} }

View File

@ -1,9 +1,9 @@
use fj_math::{Point, Scalar, Vector}; use fj_math::{Point, Scalar, Vector};
use crate::{ use crate::{
objects::{Curve, GlobalCurve, Surface}, objects::{Curve, GlobalCurve, Objects, Surface},
path::SurfacePath, path::SurfacePath,
stores::{Handle, HandleWrapper, Stores}, storage::{Handle, HandleWrapper},
}; };
/// A partial [`Curve`] /// A partial [`Curve`]
@ -83,16 +83,16 @@ impl PartialCurve {
} }
/// Build a full [`Curve`] from the partial curve /// Build a full [`Curve`] from the partial curve
pub fn build(self, stores: &Stores) -> Handle<Curve> { pub fn build(self, objects: &Objects) -> Handle<Curve> {
let path = self.path.expect("Can't build `Curve` without path"); let path = self.path.expect("Can't build `Curve` without path");
let surface = let surface =
self.surface.expect("Can't build `Curve` without surface"); self.surface.expect("Can't build `Curve` without surface");
let global_form = self let global_form = self
.global_form .global_form
.unwrap_or_else(|| GlobalCurve::new(stores).into()); .unwrap_or_else(|| GlobalCurve::new(objects).into());
Curve::new(surface, path, global_form, stores) Curve::new(surface, path, global_form, objects)
} }
} }

View File

@ -1,9 +1,11 @@
use fj_math::Point; use fj_math::Point;
use crate::{ use crate::{
objects::{Curve, Cycle, HalfEdge, Surface, SurfaceVertex, Vertex}, objects::{
Curve, Cycle, HalfEdge, Objects, Surface, SurfaceVertex, Vertex,
},
partial::{HasPartial, MaybePartial}, partial::{HasPartial, MaybePartial},
stores::{Handle, Stores}, storage::Handle,
}; };
/// A partial [`Cycle`] /// A partial [`Cycle`]
@ -154,7 +156,7 @@ impl PartialCycle {
} }
/// Build a full [`Cycle`] from the partial cycle /// Build a full [`Cycle`] from the partial cycle
pub fn build(self, stores: &Stores) -> Cycle { pub fn build(self, objects: &Objects) -> Cycle {
let surface = self.surface.expect("Need surface to build `Cycle`"); let surface = self.surface.expect("Need surface to build `Cycle`");
let surface_for_edges = surface.clone(); let surface_for_edges = surface.clone();
let half_edges = self.half_edges.into_iter().map(|half_edge| { let half_edges = self.half_edges.into_iter().map(|half_edge| {
@ -162,7 +164,7 @@ impl PartialCycle {
.update_partial(|half_edge| { .update_partial(|half_edge| {
half_edge.with_surface(Some(surface_for_edges.clone())) half_edge.with_surface(Some(surface_for_edges.clone()))
}) })
.into_full(stores) .into_full(objects)
}); });
Cycle::new(surface, half_edges) Cycle::new(surface, half_edges)

View File

@ -2,11 +2,11 @@ use fj_math::{Point, Scalar};
use crate::{ use crate::{
objects::{ objects::{
Curve, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Surface, Curve, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Objects,
SurfaceVertex, Vertex, Surface, SurfaceVertex, Vertex,
}, },
partial::{HasPartial, MaybePartial, PartialCurve}, partial::{HasPartial, MaybePartial, PartialCurve},
stores::{Handle, HandleWrapper, Stores}, storage::{Handle, HandleWrapper},
}; };
/// A partial [`HalfEdge`] /// A partial [`HalfEdge`]
@ -181,13 +181,13 @@ impl PartialHalfEdge {
} }
/// Build a full [`HalfEdge`] from the partial half-edge /// Build a full [`HalfEdge`] from the partial half-edge
pub fn build(self, stores: &Stores) -> HalfEdge { pub fn build(self, objects: &Objects) -> HalfEdge {
let surface = self.surface; let surface = self.surface;
let curve = self let curve = self
.curve .curve
.expect("Can't build `HalfEdge` without curve") .expect("Can't build `HalfEdge` without curve")
.update_partial(|curve| curve.with_surface(surface)) .update_partial(|curve| curve.with_surface(surface))
.into_full(stores); .into_full(objects);
let vertices = self let vertices = self
.vertices .vertices
.expect("Can't build `HalfEdge` without vertices") .expect("Can't build `HalfEdge` without vertices")
@ -196,7 +196,7 @@ impl PartialHalfEdge {
.update_partial(|vertex| { .update_partial(|vertex| {
vertex.with_curve(Some(curve.clone())) vertex.with_curve(Some(curve.clone()))
}) })
.into_full(stores) .into_full(objects)
}); });
let global_form = self let global_form = self
@ -206,7 +206,7 @@ impl PartialHalfEdge {
.from_curve_and_vertices(&curve, &vertices) .from_curve_and_vertices(&curve, &vertices)
.into() .into()
}) })
.into_full(stores); .into_full(objects);
HalfEdge::new(vertices, global_form) HalfEdge::new(vertices, global_form)
} }
@ -272,7 +272,7 @@ impl PartialGlobalEdge {
} }
/// Build a full [`GlobalEdge`] from the partial global edge /// Build a full [`GlobalEdge`] from the partial global edge
pub fn build(self, _: &Stores) -> GlobalEdge { pub fn build(self, _: &Objects) -> GlobalEdge {
let curve = self let curve = self
.curve .curve
.expect("Can't build `GlobalEdge` without `GlobalCurve`"); .expect("Can't build `GlobalEdge` without `GlobalCurve`");

View File

@ -5,9 +5,10 @@ pub mod vertex;
use crate::{ use crate::{
objects::{ objects::{
Curve, Cycle, GlobalEdge, GlobalVertex, HalfEdge, SurfaceVertex, Vertex, Curve, Cycle, GlobalEdge, GlobalVertex, HalfEdge, Objects,
SurfaceVertex, Vertex,
}, },
stores::{Handle, Stores}, storage::Handle,
}; };
use super::{ use super::{
@ -26,8 +27,8 @@ macro_rules! impl_traits {
impl Partial for $partial { impl Partial for $partial {
type Full = $full; type Full = $full;
fn build(self, stores: &Stores) -> Self::Full { fn build(self, objects: &Objects) -> Self::Full {
self.build(stores) self.build(objects)
} }
} }

View File

@ -1,9 +1,9 @@
use fj_math::Point; use fj_math::Point;
use crate::{ use crate::{
objects::{Curve, GlobalVertex, Surface, SurfaceVertex, Vertex}, objects::{Curve, GlobalVertex, Objects, Surface, SurfaceVertex, Vertex},
partial::{HasPartial, MaybePartial}, partial::{HasPartial, MaybePartial},
stores::{Handle, Stores}, storage::Handle,
}; };
/// A partial [`Vertex`] /// A partial [`Vertex`]
@ -86,14 +86,14 @@ impl PartialVertex {
/// Panics, if no position has been provided. /// Panics, if no position has been provided.
/// ///
/// Panics, if no curve has been provided. /// Panics, if no curve has been provided.
pub fn build(self, stores: &Stores) -> Vertex { pub fn build(self, objects: &Objects) -> Vertex {
let position = self let position = self
.position .position
.expect("Cant' build `Vertex` without position"); .expect("Cant' build `Vertex` without position");
let curve = self let curve = self
.curve .curve
.expect("Can't build `Vertex` without `Curve`") .expect("Can't build `Vertex` without `Curve`")
.into_full(stores); .into_full(objects);
let surface_form = self let surface_form = self
.surface_form .surface_form
@ -108,7 +108,7 @@ impl PartialVertex {
.with_surface(Some(curve.surface().clone())) .with_surface(Some(curve.surface().clone()))
.with_global_form(self.global_form) .with_global_form(self.global_form)
}) })
.into_full(stores); .into_full(objects);
Vertex::new(position, curve, surface_form) Vertex::new(position, curve, surface_form)
} }
@ -185,7 +185,7 @@ impl PartialSurfaceVertex {
/// Panics, if no position has been provided. /// Panics, if no position has been provided.
/// ///
/// Panics, if no surface has been provided. /// Panics, if no surface has been provided.
pub fn build(self, stores: &Stores) -> SurfaceVertex { pub fn build(self, objects: &Objects) -> SurfaceVertex {
let position = self let position = self
.position .position
.expect("Can't build `SurfaceVertex` without position"); .expect("Can't build `SurfaceVertex` without position");
@ -200,7 +200,7 @@ impl PartialSurfaceVertex {
.from_surface_and_position(&surface, position) .from_surface_and_position(&surface, position)
.into() .into()
}) })
.into_full(stores); .into_full(objects);
SurfaceVertex::new(position, surface, global_form) SurfaceVertex::new(position, surface, global_form)
} }
@ -269,12 +269,12 @@ impl PartialGlobalVertex {
} }
/// Build a full [`GlobalVertex`] from the partial global vertex /// Build a full [`GlobalVertex`] from the partial global vertex
pub fn build(self, stores: &Stores) -> Handle<GlobalVertex> { pub fn build(self, objects: &Objects) -> Handle<GlobalVertex> {
let position = self let position = self
.position .position
.expect("Can't build a `GlobalVertex` without a position"); .expect("Can't build a `GlobalVertex` without a position");
GlobalVertex::from_position(position, stores) GlobalVertex::from_position(position, objects)
} }
} }

View File

@ -1,4 +1,4 @@
use crate::stores::Stores; use crate::objects::Objects;
/// Implemented for objects that a partial object type exists for /// Implemented for objects that a partial object type exists for
/// ///
@ -77,5 +77,5 @@ pub trait Partial: Default + for<'a> From<&'a Self::Full> {
/// Calling `build` on a partial object that can't infer its missing parts /// Calling `build` on a partial object that can't infer its missing parts
/// is considered a programmer error, hence why this method doesn't return a /// is considered a programmer error, hence why this method doesn't return a
/// [`Result`]. /// [`Result`].
fn build(self, stores: &Stores) -> Self::Full; fn build(self, objects: &Objects) -> Self::Full;
} }

View File

@ -0,0 +1,10 @@
//! Append-only object storage
mod blocks;
mod handle;
mod store;
pub use self::{
handle::{Handle, HandleWrapper, ObjectId},
store::{Iter, Reservation, Store},
};

View File

@ -1,42 +0,0 @@
//! Append-only object storage
mod blocks;
mod handle;
mod store;
use crate::objects::{Curve, GlobalCurve, GlobalVertex, Surface};
pub use self::{
handle::{Handle, HandleWrapper, ObjectId},
store::{Iter, Reservation, Store},
};
/// The available object stores
///
/// # Implementation Note
///
/// The intention is to eventually manage all objects in here. Making this
/// happen is simply a case of putting in the required work. See [#1021].
///
/// [#1021]: https://github.com/hannobraun/Fornjot/issues/1021
#[derive(Debug, Default)]
pub struct Stores {
/// Store for curves
pub curves: Store<Curve>,
/// Store for global curves
pub global_curves: Store<GlobalCurve>,
/// Store for global vertices
pub global_vertices: Store<GlobalVertex>,
/// Store for surfaces
pub surfaces: Store<Surface>,
}
impl Stores {
/// Construct a new instance of `Stores`
pub fn new() -> Self {
Self::default()
}
}

View File

@ -5,8 +5,7 @@ use fj_kernel::{
validate::{Validate, Validated, ValidationConfig, ValidationError}, validate::{Validate, Validated, ValidationConfig, ValidationError},
}, },
iter::ObjectIters, iter::ObjectIters,
objects::{Face, Sketch}, objects::{Face, Objects, Sketch},
stores::Stores,
}; };
use fj_math::Aabb; use fj_math::Aabb;
@ -20,7 +19,7 @@ impl Shape for fj::Difference2d {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig, config: &ValidationConfig,
stores: &Stores, objects: &Objects,
planes: &Planes, planes: &Planes,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Validated<Self::Brep>, ValidationError> { ) -> Result<Validated<Self::Brep>, ValidationError> {
@ -37,7 +36,7 @@ impl Shape for fj::Difference2d {
// - https://doc.rust-lang.org/std/primitive.array.html#method.try_map // - https://doc.rust-lang.org/std/primitive.array.html#method.try_map
let [a, b] = self.shapes(); let [a, b] = self.shapes();
let [a, b] = [a, b].map(|shape| { let [a, b] = [a, b].map(|shape| {
shape.compute_brep(config, stores, planes, debug_info) shape.compute_brep(config, objects, planes, debug_info)
}); });
let [a, b] = [a?, b?]; let [a, b] = [a?, b?];

View File

@ -3,8 +3,7 @@ use fj_kernel::{
algorithms::validate::{ algorithms::validate::{
Validate, Validated, ValidationConfig, ValidationError, Validate, Validated, ValidationConfig, ValidationError,
}, },
objects::Faces, objects::{Faces, Objects},
stores::Stores,
}; };
use fj_math::Aabb; use fj_math::Aabb;
@ -18,14 +17,14 @@ impl Shape for fj::Group {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig, config: &ValidationConfig,
stores: &Stores, objects: &Objects,
planes: &Planes, planes: &Planes,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Validated<Self::Brep>, ValidationError> { ) -> Result<Validated<Self::Brep>, ValidationError> {
let mut faces = Faces::new(); let mut faces = Faces::new();
let a = self.a.compute_brep(config, stores, planes, debug_info)?; let a = self.a.compute_brep(config, objects, planes, debug_info)?;
let b = self.b.compute_brep(config, stores, planes, debug_info)?; let b = self.b.compute_brep(config, objects, planes, debug_info)?;
faces.extend(a.into_inner()); faces.extend(a.into_inner());
faces.extend(b.into_inner()); faces.extend(b.into_inner());

View File

@ -32,8 +32,7 @@ use fj_kernel::{
algorithms::validate::{ algorithms::validate::{
Validate, Validated, ValidationConfig, ValidationError, Validate, Validated, ValidationConfig, ValidationError,
}, },
objects::{Faces, Sketch}, objects::{Faces, Objects, Sketch},
stores::Stores,
}; };
use fj_math::Aabb; use fj_math::Aabb;
@ -46,7 +45,7 @@ pub trait Shape {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig, config: &ValidationConfig,
stores: &Stores, objects: &Objects,
planes: &Planes, planes: &Planes,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Validated<Self::Brep>, ValidationError>; ) -> Result<Validated<Self::Brep>, ValidationError>;
@ -64,21 +63,21 @@ impl Shape for fj::Shape {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig, config: &ValidationConfig,
stores: &Stores, objects: &Objects,
planes: &Planes, planes: &Planes,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Validated<Self::Brep>, ValidationError> { ) -> Result<Validated<Self::Brep>, ValidationError> {
match self { match self {
Self::Shape2d(shape) => shape Self::Shape2d(shape) => shape
.compute_brep(config, stores, planes, debug_info)? .compute_brep(config, objects, planes, debug_info)?
.into_inner() .into_inner()
.into_faces() .into_faces()
.validate_with_config(config), .validate_with_config(config),
Self::Group(shape) => { Self::Group(shape) => {
shape.compute_brep(config, stores, planes, debug_info) shape.compute_brep(config, objects, planes, debug_info)
} }
Self::Sweep(shape) => shape Self::Sweep(shape) => shape
.compute_brep(config, stores, planes, debug_info)? .compute_brep(config, objects, planes, debug_info)?
.into_inner() .into_inner()
.into_shells() .into_shells()
.map(|shell| shell.into_faces()) .map(|shell| shell.into_faces())
@ -89,7 +88,7 @@ impl Shape for fj::Shape {
.unwrap_or_default() .unwrap_or_default()
.validate_with_config(config), .validate_with_config(config),
Self::Transform(shape) => { Self::Transform(shape) => {
shape.compute_brep(config, stores, planes, debug_info) shape.compute_brep(config, objects, planes, debug_info)
} }
} }
} }
@ -110,16 +109,16 @@ impl Shape for fj::Shape2d {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig, config: &ValidationConfig,
stores: &Stores, objects: &Objects,
planes: &Planes, planes: &Planes,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Validated<Self::Brep>, ValidationError> { ) -> Result<Validated<Self::Brep>, ValidationError> {
match self { match self {
Self::Difference(shape) => { Self::Difference(shape) => {
shape.compute_brep(config, stores, planes, debug_info) shape.compute_brep(config, objects, planes, debug_info)
} }
Self::Sketch(shape) => { Self::Sketch(shape) => {
shape.compute_brep(config, stores, planes, debug_info) shape.compute_brep(config, objects, planes, debug_info)
} }
} }
} }

View File

@ -1,6 +1,6 @@
use fj_kernel::{ use fj_kernel::{
objects::Surface, objects::{Objects, Surface},
stores::{Handle, Stores}, storage::Handle,
}; };
/// The static planes /// The static planes
@ -25,10 +25,10 @@ impl Planes {
/// ///
/// Create one instance of this struct, then share it everywhere it's /// Create one instance of this struct, then share it everywhere it's
/// needed. /// needed.
pub fn new(stores: &Stores) -> Self { pub fn new(objects: &Objects) -> Self {
let xy = stores.surfaces.insert(Surface::xy_plane()); let xy = objects.surfaces.insert(Surface::xy_plane());
let xz = stores.surfaces.insert(Surface::xz_plane()); let xz = objects.surfaces.insert(Surface::xz_plane());
let yz = stores.surfaces.insert(Surface::yz_plane()); let yz = objects.surfaces.insert(Surface::yz_plane());
Self { xy, xz, yz } Self { xy, xz, yz }
} }

View File

@ -7,7 +7,7 @@ use fj_kernel::{
triangulate::Triangulate, triangulate::Triangulate,
validate::{ValidationConfig, ValidationError}, validate::{ValidationConfig, ValidationError},
}, },
stores::Stores, objects::Objects,
}; };
use fj_math::Scalar; use fj_math::Scalar;
@ -43,11 +43,11 @@ impl ShapeProcessor {
}; };
let config = ValidationConfig::default(); let config = ValidationConfig::default();
let stores = Stores::new(); let objects = Objects::new();
let planes = Planes::new(&stores); let planes = Planes::new(&objects);
let mut debug_info = DebugInfo::new(); let mut debug_info = DebugInfo::new();
let shape = let shape =
shape.compute_brep(&config, &stores, &planes, &mut debug_info)?; shape.compute_brep(&config, &objects, &planes, &mut debug_info)?;
let mesh = (&shape.into_inner(), tolerance).triangulate(); let mesh = (&shape.into_inner(), tolerance).triangulate();
Ok(ProcessedShape { Ok(ProcessedShape {

View File

@ -3,9 +3,8 @@ use fj_kernel::{
algorithms::validate::{ algorithms::validate::{
Validate, Validated, ValidationConfig, ValidationError, Validate, Validated, ValidationConfig, ValidationError,
}, },
objects::{Cycle, Face, HalfEdge, Sketch}, objects::{Cycle, Face, HalfEdge, Objects, Sketch},
partial::HasPartial, partial::HasPartial,
stores::Stores,
}; };
use fj_math::{Aabb, Point}; use fj_math::{Aabb, Point};
@ -19,7 +18,7 @@ impl Shape for fj::Sketch {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig, config: &ValidationConfig,
stores: &Stores, objects: &Objects,
planes: &Planes, planes: &Planes,
_: &mut DebugInfo, _: &mut DebugInfo,
) -> Result<Validated<Self::Brep>, ValidationError> { ) -> Result<Validated<Self::Brep>, ValidationError> {
@ -33,7 +32,7 @@ impl Shape for fj::Sketch {
let half_edge = HalfEdge::partial() let half_edge = HalfEdge::partial()
.with_surface(Some(surface.clone())) .with_surface(Some(surface.clone()))
.as_circle_from_radius(circle.radius()) .as_circle_from_radius(circle.radius())
.build(stores); .build(objects);
let cycle = Cycle::new(surface, [half_edge]); let cycle = Cycle::new(surface, [half_edge]);
Face::from_exterior(cycle).with_color(Color(self.color())) Face::from_exterior(cycle).with_color(Color(self.color()))
@ -42,7 +41,7 @@ impl Shape for fj::Sketch {
let points = let points =
poly_chain.to_points().into_iter().map(Point::from); poly_chain.to_points().into_iter().map(Point::from);
Face::builder(stores, surface) Face::builder(objects, surface)
.with_exterior_polygon_from_points(points) .with_exterior_polygon_from_points(points)
.build() .build()
.with_color(Color(self.color())) .with_color(Color(self.color()))

View File

@ -4,8 +4,7 @@ use fj_kernel::{
sweep::Sweep, sweep::Sweep,
validate::{Validate, Validated, ValidationConfig, ValidationError}, validate::{Validate, Validated, ValidationConfig, ValidationError},
}, },
objects::Solid, objects::{Objects, Solid},
stores::Stores,
}; };
use fj_math::{Aabb, Vector}; use fj_math::{Aabb, Vector};
@ -19,16 +18,16 @@ impl Shape for fj::Sweep {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig, config: &ValidationConfig,
stores: &Stores, objects: &Objects,
planes: &Planes, planes: &Planes,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Validated<Self::Brep>, ValidationError> { ) -> Result<Validated<Self::Brep>, ValidationError> {
let sketch = self let sketch = self
.shape() .shape()
.compute_brep(config, stores, planes, debug_info)?; .compute_brep(config, objects, planes, debug_info)?;
let path = Vector::from(self.path()); let path = Vector::from(self.path());
let solid = sketch.into_inner().sweep(path, stores); let solid = sketch.into_inner().sweep(path, objects);
solid.validate_with_config(config) solid.validate_with_config(config)
} }

View File

@ -4,8 +4,7 @@ use fj_kernel::{
transform::TransformObject, transform::TransformObject,
validate::{Validate, Validated, ValidationConfig, ValidationError}, validate::{Validate, Validated, ValidationConfig, ValidationError},
}, },
objects::Faces, objects::{Faces, Objects},
stores::Stores,
}; };
use fj_math::{Aabb, Transform, Vector}; use fj_math::{Aabb, Transform, Vector};
@ -19,15 +18,15 @@ impl Shape for fj::Transform {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig, config: &ValidationConfig,
stores: &Stores, objects: &Objects,
planes: &Planes, planes: &Planes,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Validated<Self::Brep>, ValidationError> { ) -> Result<Validated<Self::Brep>, ValidationError> {
let faces = self let faces = self
.shape .shape
.compute_brep(config, stores, planes, debug_info)? .compute_brep(config, objects, planes, debug_info)?
.into_inner() .into_inner()
.transform(&make_transform(self), stores); .transform(&make_transform(self), objects);
faces.validate_with_config(config) faces.validate_with_config(config)
} }