Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename fj_core::Instance to Core #2218

Merged
merged 3 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/fj-core/src/algorithms/approx/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ mod tests {
geometry::{CurveBoundary, GlobalPath, SurfaceGeometry, SurfacePath},
objects::{Curve, Surface},
operations::insert::Insert,
Instance,
Core,
};

#[test]
fn approx_line_on_flat_surface() {
let mut core = Instance::new();
let mut core = Core::new();

let curve = Curve::new().insert(&mut core);
let (surface_path, boundary) =
Expand All @@ -203,7 +203,7 @@ mod tests {

#[test]
fn approx_line_on_curved_surface_but_not_along_curve() {
let mut core = Instance::new();
let mut core = Core::new();

let curve = Curve::new().insert(&mut core);
let (surface_path, boundary) =
Expand All @@ -223,7 +223,7 @@ mod tests {

#[test]
fn approx_line_on_curved_surface_along_curve() {
let mut core = Instance::new();
let mut core = Core::new();

let global_path = GlobalPath::circle_from_radius(1.);
let curve = Curve::new().insert(&mut core);
Expand Down Expand Up @@ -257,7 +257,7 @@ mod tests {

#[test]
fn approx_circle_on_flat_surface() {
let mut core = Instance::new();
let mut core = Core::new();

let curve = Curve::new().insert(&mut core);
let surface_path =
Expand Down
10 changes: 5 additions & 5 deletions crates/fj-core/src/algorithms/intersect/curve_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ mod tests {

use crate::{
geometry::SurfacePath, objects::HalfEdge,
operations::build::BuildHalfEdge, Instance,
operations::build::BuildHalfEdge, Core,
};

use super::CurveEdgeIntersection;

#[test]
fn compute_edge_in_front_of_curve_origin() {
let mut core = Instance::new();
let mut core = Core::new();

let path = SurfacePath::u_axis();
let edge =
Expand All @@ -98,7 +98,7 @@ mod tests {

#[test]
fn compute_edge_behind_curve_origin() {
let mut core = Instance::new();
let mut core = Core::new();

let path = SurfacePath::u_axis();
let edge =
Expand All @@ -116,7 +116,7 @@ mod tests {

#[test]
fn compute_edge_parallel_to_curve() {
let mut core = Instance::new();
let mut core = Core::new();

let path = SurfacePath::u_axis();
let edge =
Expand All @@ -129,7 +129,7 @@ mod tests {

#[test]
fn compute_edge_on_curve() {
let mut core = Instance::new();
let mut core = Core::new();

let path = SurfacePath::u_axis();
let edge =
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-core/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ mod tests {
build::{BuildCycle, BuildFace},
update::{UpdateFace, UpdateRegion},
},
Instance,
Core,
};

use super::CurveFaceIntersection;

#[test]
fn compute() {
let mut core = Instance::new();
let mut core = Core::new();

let (path, _) = SurfacePath::line_from_points([[-3., 0.], [-2., 0.]]);

Expand Down
6 changes: 3 additions & 3 deletions crates/fj-core/src/algorithms/intersect/face_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ mod tests {
build::{BuildCycle, BuildFace},
update::{UpdateFace, UpdateRegion},
},
Instance,
Core,
};

use super::FaceFaceIntersection;

#[test]
fn compute_no_intersection() {
let mut core = Instance::new();
let mut core = Core::new();

#[rustfmt::skip]
let points = [
Expand Down Expand Up @@ -106,7 +106,7 @@ mod tests {

#[test]
fn compute_one_intersection() {
let mut core = Instance::new();
let mut core = Core::new();

#[rustfmt::skip]
let points = [
Expand Down
18 changes: 9 additions & 9 deletions crates/fj-core/src/algorithms/intersect/face_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ mod tests {
build::{BuildCycle, BuildFace},
update::{UpdateFace, UpdateRegion},
},
Instance,
Core,
};

#[test]
fn point_is_outside_face() {
let mut core = Instance::new();
let mut core = Core::new();

let face =
Face::unbound(core.layers.objects.surfaces.xy_plane(), &mut core)
Expand All @@ -171,7 +171,7 @@ mod tests {

#[test]
fn ray_hits_vertex_while_passing_outside() {
let mut core = Instance::new();
let mut core = Core::new();

let face =
Face::unbound(core.layers.objects.surfaces.xy_plane(), &mut core)
Expand Down Expand Up @@ -200,7 +200,7 @@ mod tests {

#[test]
fn ray_hits_vertex_at_cycle_seam() {
let mut core = Instance::new();
let mut core = Core::new();

let face =
Face::unbound(core.layers.objects.surfaces.xy_plane(), &mut core)
Expand Down Expand Up @@ -229,7 +229,7 @@ mod tests {

#[test]
fn ray_hits_vertex_while_staying_inside() {
let mut core = Instance::new();
let mut core = Core::new();

let face =
Face::unbound(core.layers.objects.surfaces.xy_plane(), &mut core)
Expand Down Expand Up @@ -258,7 +258,7 @@ mod tests {

#[test]
fn ray_hits_parallel_edge_and_leaves_face_at_vertex() {
let mut core = Instance::new();
let mut core = Core::new();

let face =
Face::unbound(core.layers.objects.surfaces.xy_plane(), &mut core)
Expand Down Expand Up @@ -287,7 +287,7 @@ mod tests {

#[test]
fn ray_hits_parallel_edge_and_does_not_leave_face_there() {
let mut core = Instance::new();
let mut core = Core::new();

let face =
Face::unbound(core.layers.objects.surfaces.xy_plane(), &mut core)
Expand Down Expand Up @@ -322,7 +322,7 @@ mod tests {

#[test]
fn point_is_coincident_with_edge() {
let mut core = Instance::new();
let mut core = Core::new();

let face =
Face::unbound(core.layers.objects.surfaces.xy_plane(), &mut core)
Expand Down Expand Up @@ -359,7 +359,7 @@ mod tests {

#[test]
fn point_is_coincident_with_vertex() {
let mut core = Instance::new();
let mut core = Core::new();

let face =
Face::unbound(core.layers.objects.surfaces.xy_plane(), &mut core)
Expand Down
16 changes: 8 additions & 8 deletions crates/fj-core/src/algorithms/intersect/ray_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ mod tests {
transform::TransformObject,
update::{UpdateFace, UpdateRegion},
},
Instance,
Core,
};

#[test]
fn ray_misses_whole_surface() {
let mut core = Instance::new();
let mut core = Core::new();

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

Expand Down Expand Up @@ -191,7 +191,7 @@ mod tests {

#[test]
fn ray_hits_face() {
let mut core = Instance::new();
let mut core = Core::new();

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

Expand Down Expand Up @@ -226,7 +226,7 @@ mod tests {

#[test]
fn ray_hits_surface_but_misses_face() {
let mut core = Instance::new();
let mut core = Core::new();

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

Expand Down Expand Up @@ -258,7 +258,7 @@ mod tests {

#[test]
fn ray_hits_edge() {
let mut core = Instance::new();
let mut core = Core::new();

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

Expand Down Expand Up @@ -300,7 +300,7 @@ mod tests {

#[test]
fn ray_hits_vertex() {
let mut core = Instance::new();
let mut core = Core::new();

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

Expand Down Expand Up @@ -343,7 +343,7 @@ mod tests {

#[test]
fn ray_is_parallel_to_surface_and_hits() {
let mut core = Instance::new();
let mut core = Core::new();

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

Expand Down Expand Up @@ -377,7 +377,7 @@ mod tests {

#[test]
fn ray_is_parallel_to_surface_and_misses() {
let mut core = Instance::new();
let mut core = Core::new();

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

Expand Down
4 changes: 2 additions & 2 deletions crates/fj-core/src/algorithms/intersect/surface_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ mod tests {
use pretty_assertions::assert_eq;

use crate::{
geometry::SurfacePath, operations::transform::TransformObject, Instance,
geometry::SurfacePath, operations::transform::TransformObject, Core,
};

use super::SurfaceSurfaceIntersection;

#[test]
fn plane_plane() {
let mut core = Instance::new();
let mut core = Core::new();

let xy = core.layers.objects.surfaces.xy_plane();
let xz = core.layers.objects.surfaces.xz_plane();
Expand Down
8 changes: 4 additions & 4 deletions crates/fj-core/src/algorithms/triangulate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ mod tests {
build::{BuildCycle, BuildFace},
update::{UpdateFace, UpdateRegion},
},
Instance,
Core,
};

use super::Triangulate;

#[test]
fn simple() -> anyhow::Result<()> {
let mut core = Instance::new();
let mut core = Core::new();

let a = [0., 0.];
let b = [2., 0.];
Expand Down Expand Up @@ -127,7 +127,7 @@ mod tests {

#[test]
fn simple_hole() -> anyhow::Result<()> {
let mut core = Instance::new();
let mut core = Core::new();

let a = [0., 0.];
let b = [4., 0.];
Expand Down Expand Up @@ -185,7 +185,7 @@ mod tests {

#[test]
fn sharp_concave_shape() -> anyhow::Result<()> {
let mut core = Instance::new();
let mut core = Core::new();

// e c
// |\ /|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
//! Main entry point to the `fj-core` API
//!
//! See [`Instance`].
//! See [`Core`].

use crate::{layers::Layers, validate::ValidationConfig};

/// An instance of the Fornjot core
///
/// This is the main entry point to `fj-core`'s API.
#[derive(Default)]
pub struct Instance {
pub struct Core {
/// The layers of data that make up the state of a core instance
pub layers: Layers,
}

impl Instance {
impl Core {
/// Construct an instance of `Instance`
pub fn new() -> Self {
Self::default()
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ pub mod queries;
pub mod storage;
pub mod validate;

mod instance;
mod core;

pub use self::instance::Instance;
pub use self::core::Core;
6 changes: 3 additions & 3 deletions crates/fj-core/src/operations/build/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use itertools::Itertools;
use crate::{
objects::{Cycle, HalfEdge},
operations::{build::BuildHalfEdge, insert::Insert, update::UpdateCycle},
Instance,
Core,
};

/// Build a [`Cycle`]
Expand All @@ -22,14 +22,14 @@ pub trait BuildCycle {
fn circle(
center: impl Into<Point<2>>,
radius: impl Into<Scalar>,
core: &mut Instance,
core: &mut Core,
) -> Cycle {
let circle = HalfEdge::circle(center, radius, core);
Cycle::empty().add_half_edges([circle], core)
}

/// Build a polygon
fn polygon<P, Ps>(points: Ps, core: &mut Instance) -> Cycle
fn polygon<P, Ps>(points: Ps, core: &mut Core) -> Cycle
where
P: Into<Point<2>>,
Ps: IntoIterator<Item = P>,
Expand Down
Loading