Skip to content

Commit

Permalink
Merge pull request #1198 from hannobraun/objects
Browse files Browse the repository at this point in the history
Rename `Stores` to `Objects`, move it to `Objects`
  • Loading branch information
hannobraun authored Oct 10, 2022
2 parents bc949b1 + 10839ba commit bbddc4b
Show file tree
Hide file tree
Showing 62 changed files with 552 additions and 528 deletions.
30 changes: 15 additions & 15 deletions crates/fj-kernel/src/algorithms/approx/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::collections::BTreeMap;
use crate::{
objects::{Curve, GlobalCurve},
path::{GlobalPath, SurfacePath},
stores::{Handle, ObjectId},
storage::{Handle, ObjectId},
};

use super::{path::RangeOnPath, Approx, ApproxPoint, Tolerance};
Expand Down Expand Up @@ -197,25 +197,25 @@ mod tests {

use crate::{
algorithms::approx::{path::RangeOnPath, Approx, ApproxPoint},
objects::{Curve, Surface},
objects::{Curve, Objects, Surface},
partial::HasPartial,
path::GlobalPath,
stores::{Handle, Stores},
storage::Handle,
};

use super::CurveApprox;

#[test]
fn approx_line_on_flat_surface() {
let stores = Stores::new();
let objects = Objects::new();

let surface = stores
let surface = objects
.surfaces
.insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.]));
let curve = Handle::<Curve>::partial()
.with_surface(Some(surface))
.as_line_from_points([[1., 1.], [2., 1.]])
.build(&stores);
.build(&objects);
let range = RangeOnPath::from([[0.], [1.]]);

let approx = (&curve, range).approx(1.);
Expand All @@ -225,16 +225,16 @@ mod tests {

#[test]
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.),
[0., 0., 1.],
));
let curve = Handle::<Curve>::partial()
.with_surface(Some(surface))
.as_line_from_points([[1., 1.], [1., 2.]])
.build(&stores);
.build(&objects);
let range = RangeOnPath::from([[0.], [1.]]);

let approx = (&curve, range).approx(1.);
Expand All @@ -244,14 +244,14 @@ mod tests {

#[test]
fn approx_line_on_curved_surface_along_curve() {
let stores = Stores::new();
let objects = Objects::new();

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()
.with_surface(Some(surface.clone()))
.as_line_from_points([[0., 1.], [1., 1.]])
.build(&stores);
.build(&objects);

let range = RangeOnPath::from([[0.], [TAU]]);
let tolerance = 1.;
Expand All @@ -274,15 +274,15 @@ mod tests {

#[test]
fn approx_circle_on_flat_surface() {
let stores = Stores::new();
let objects = Objects::new();

let surface = stores
let surface = objects
.surfaces
.insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.]));
let curve = Handle::<Curve>::partial()
.with_surface(Some(surface))
.as_circle_from_radius(1.)
.build(&stores);
.build(&objects);

let range = RangeOnPath::from([[0.], [TAU]]);
let tolerance = 1.;
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/approx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::{

use fj_math::Point;

use crate::{objects::Curve, stores::Handle};
use crate::{objects::Curve, storage::Handle};

pub use self::tolerance::{InvalidTolerance, Tolerance};

Expand Down
36 changes: 18 additions & 18 deletions crates/fj-kernel/src/algorithms/intersect/curve_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,26 @@ mod tests {
use fj_math::Point;

use crate::{
objects::{Curve, HalfEdge, Surface},
objects::{Curve, HalfEdge, Objects, Surface},
partial::HasPartial,
stores::{Handle, Stores},
storage::Handle,
};

use super::CurveEdgeIntersection;

#[test]
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()
.with_surface(Some(surface.clone()))
.as_u_axis()
.build(&stores);
.build(&objects);
let half_edge = HalfEdge::partial()
.with_surface(Some(surface))
.as_line_segment_from_points([[1., -1.], [1., 1.]])
.build(&stores);
.build(&objects);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

Expand All @@ -108,17 +108,17 @@ mod tests {

#[test]
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()
.with_surface(Some(surface.clone()))
.as_u_axis()
.build(&stores);
.build(&objects);
let half_edge = HalfEdge::partial()
.with_surface(Some(surface))
.as_line_segment_from_points([[-1., -1.], [-1., 1.]])
.build(&stores);
.build(&objects);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

Expand All @@ -132,17 +132,17 @@ mod tests {

#[test]
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()
.with_surface(Some(surface.clone()))
.as_u_axis()
.build(&stores);
.build(&objects);
let half_edge = HalfEdge::partial()
.with_surface(Some(surface))
.as_line_segment_from_points([[-1., -1.], [1., -1.]])
.build(&stores);
.build(&objects);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

Expand All @@ -151,17 +151,17 @@ mod tests {

#[test]
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()
.with_surface(Some(surface.clone()))
.as_u_axis()
.build(&stores);
.build(&objects);
let half_edge = HalfEdge::partial()
.with_surface(Some(surface))
.as_line_segment_from_points([[-1., 0.], [1., 0.]])
.build(&stores);
.build(&objects);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

Expand Down
12 changes: 6 additions & 6 deletions crates/fj-kernel/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,23 +156,23 @@ where
#[cfg(test)]
mod tests {
use crate::{
objects::{Curve, Face, Surface},
objects::{Curve, Face, Objects, Surface},
partial::HasPartial,
stores::{Handle, Stores},
storage::Handle,
};

use super::CurveFaceIntersection;

#[test]
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()
.with_surface(Some(surface.clone()))
.as_line_from_points([[-3., 0.], [-2., 0.]])
.build(&stores);
.build(&objects);

#[rustfmt::skip]
let exterior = [
Expand All @@ -189,7 +189,7 @@ mod tests {
[ 1., -1.],
];

let face = Face::builder(&stores, surface)
let face = Face::builder(&objects, surface)
.with_exterior_polygon_from_points(exterior)
.with_interior_polygon_from_points(interior)
.build();
Expand Down
30 changes: 15 additions & 15 deletions crates/fj-kernel/src/algorithms/intersect/face_face.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
objects::{Curve, Face},
stores::{Handle, Stores},
objects::{Curve, Face, Objects},
storage::Handle,
};

use super::{CurveFaceIntersection, SurfaceSurfaceIntersection};
Expand All @@ -24,11 +24,11 @@ pub struct FaceFaceIntersection {

impl FaceFaceIntersection {
/// 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 intersection_curves =
SurfaceSurfaceIntersection::compute(surfaces, stores)?
SurfaceSurfaceIntersection::compute(surfaces, objects)?
.intersection_curves;

// Can be cleaned up, once `zip` is stable:
Expand Down Expand Up @@ -64,16 +64,16 @@ mod tests {

use crate::{
algorithms::intersect::CurveFaceIntersection,
objects::{Curve, Face, Surface},
objects::{Curve, Face, Objects, Surface},
partial::HasPartial,
stores::{Handle, Stores},
storage::Handle,
};

use super::FaceFaceIntersection;

#[test]
fn compute_no_intersection() {
let stores = Stores::new();
let objects = Objects::new();

#[rustfmt::skip]
let points = [
Expand All @@ -84,20 +84,20 @@ mod tests {
];
let [a, b] =
[Surface::xy_plane(), Surface::xz_plane()].map(|surface| {
let surface = stores.surfaces.insert(surface);
Face::builder(&stores, surface)
let surface = objects.surfaces.insert(surface);
Face::builder(&objects, surface)
.with_exterior_polygon_from_points(points)
.build()
});

let intersection = FaceFaceIntersection::compute([&a, &b], &stores);
let intersection = FaceFaceIntersection::compute([&a, &b], &objects);

assert!(intersection.is_none());
}

#[test]
fn compute_one_intersection() {
let stores = Stores::new();
let objects = Objects::new();

#[rustfmt::skip]
let points = [
Expand All @@ -107,20 +107,20 @@ mod tests {
[-1., 1.],
];
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| {
Face::builder(&stores, surface)
Face::builder(&objects, surface)
.with_exterior_polygon_from_points(points)
.build()
});

let intersection = FaceFaceIntersection::compute([&a, &b], &stores);
let intersection = FaceFaceIntersection::compute([&a, &b], &objects);

let expected_curves = surfaces.map(|surface| {
Handle::<Curve>::partial()
.with_surface(Some(surface))
.as_line_from_points([[0., 0.], [1., 0.]])
.build(&stores)
.build(&objects)
});
let expected_intervals =
CurveFaceIntersection::from_intervals([[[-1.], [1.]]]);
Expand Down
Loading

0 comments on commit bbddc4b

Please sign in to comment.