mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-18 14:16:13 +00:00
Make use of default planes
This commit is contained in:
parent
9a6b7f7d05
commit
895fff5d8b
@ -75,7 +75,7 @@ mod tests {
|
|||||||
use fj_math::Point;
|
use fj_math::Point;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
objects::{Curve, HalfEdge, Objects, Surface},
|
objects::{Curve, HalfEdge, Objects},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
};
|
};
|
||||||
@ -86,7 +86,7 @@ mod tests {
|
|||||||
fn compute_edge_in_front_of_curve_origin() {
|
fn compute_edge_in_front_of_curve_origin() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.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()
|
||||||
@ -110,7 +110,7 @@ mod tests {
|
|||||||
fn compute_edge_behind_curve_origin() {
|
fn compute_edge_behind_curve_origin() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.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()
|
||||||
@ -134,7 +134,7 @@ mod tests {
|
|||||||
fn compute_edge_parallel_to_curve() {
|
fn compute_edge_parallel_to_curve() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.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()
|
||||||
@ -153,7 +153,7 @@ mod tests {
|
|||||||
fn compute_edge_on_curve() {
|
fn compute_edge_on_curve() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.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()
|
||||||
|
@ -156,7 +156,7 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
objects::{Curve, Face, Objects, Surface},
|
objects::{Curve, Face, Objects},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
};
|
};
|
||||||
@ -167,7 +167,7 @@ mod tests {
|
|||||||
fn compute() {
|
fn compute() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
|
|
||||||
let curve = Handle::<Curve>::partial()
|
let curve = Handle::<Curve>::partial()
|
||||||
.with_surface(Some(surface.clone()))
|
.with_surface(Some(surface.clone()))
|
||||||
|
@ -64,7 +64,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::intersect::CurveFaceIntersection,
|
algorithms::intersect::CurveFaceIntersection,
|
||||||
objects::{Curve, Face, Objects, Surface},
|
objects::{Curve, Face, Objects},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
};
|
};
|
||||||
@ -82,9 +82,8 @@ mod tests {
|
|||||||
[2., 2.],
|
[2., 2.],
|
||||||
[1., 2.],
|
[1., 2.],
|
||||||
];
|
];
|
||||||
let [a, b] =
|
let [a, b] = [objects.surfaces.xy_plane(), objects.surfaces.xz_plane()]
|
||||||
[Surface::xy_plane(), Surface::xz_plane()].map(|surface| {
|
.map(|surface| {
|
||||||
let surface = objects.surfaces.insert(surface);
|
|
||||||
Face::builder(&objects, surface)
|
Face::builder(&objects, surface)
|
||||||
.with_exterior_polygon_from_points(points)
|
.with_exterior_polygon_from_points(points)
|
||||||
.build()
|
.build()
|
||||||
@ -106,8 +105,8 @@ mod tests {
|
|||||||
[ 1., 1.],
|
[ 1., 1.],
|
||||||
[-1., 1.],
|
[-1., 1.],
|
||||||
];
|
];
|
||||||
let surfaces = [Surface::xy_plane(), Surface::xz_plane()]
|
let surfaces =
|
||||||
.map(|surface| objects.surfaces.insert(surface));
|
[objects.surfaces.xy_plane(), objects.surfaces.xz_plane()];
|
||||||
let [a, b] = surfaces.clone().map(|surface| {
|
let [a, b] = surfaces.clone().map(|surface| {
|
||||||
Face::builder(&objects, surface)
|
Face::builder(&objects, surface)
|
||||||
.with_exterior_polygon_from_points(points)
|
.with_exterior_polygon_from_points(points)
|
||||||
|
@ -134,14 +134,14 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
algorithms::intersect::{face_point::FacePointIntersection, Intersect},
|
algorithms::intersect::{face_point::FacePointIntersection, Intersect},
|
||||||
iter::ObjectIters,
|
iter::ObjectIters,
|
||||||
objects::{Face, Objects, Surface},
|
objects::{Face, Objects},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn point_is_outside_face() {
|
fn point_is_outside_face() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, 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();
|
||||||
@ -155,7 +155,7 @@ mod tests {
|
|||||||
fn ray_hits_vertex_while_passing_outside() {
|
fn ray_hits_vertex_while_passing_outside() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, 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();
|
||||||
@ -172,7 +172,7 @@ mod tests {
|
|||||||
fn ray_hits_vertex_at_cycle_seam() {
|
fn ray_hits_vertex_at_cycle_seam() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, 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();
|
||||||
@ -189,7 +189,7 @@ mod tests {
|
|||||||
fn ray_hits_vertex_while_staying_inside() {
|
fn ray_hits_vertex_while_staying_inside() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, surface)
|
let face = Face::builder(&objects, surface)
|
||||||
.with_exterior_polygon_from_points([
|
.with_exterior_polygon_from_points([
|
||||||
[0., 0.],
|
[0., 0.],
|
||||||
@ -211,7 +211,7 @@ mod tests {
|
|||||||
fn ray_hits_parallel_edge_and_leaves_face_at_vertex() {
|
fn ray_hits_parallel_edge_and_leaves_face_at_vertex() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, surface)
|
let face = Face::builder(&objects, surface)
|
||||||
.with_exterior_polygon_from_points([
|
.with_exterior_polygon_from_points([
|
||||||
[0., 0.],
|
[0., 0.],
|
||||||
@ -233,7 +233,7 @@ mod tests {
|
|||||||
fn ray_hits_parallel_edge_and_does_not_leave_face_there() {
|
fn ray_hits_parallel_edge_and_does_not_leave_face_there() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, surface)
|
let face = Face::builder(&objects, surface)
|
||||||
.with_exterior_polygon_from_points([
|
.with_exterior_polygon_from_points([
|
||||||
[0., 0.],
|
[0., 0.],
|
||||||
@ -256,7 +256,7 @@ mod tests {
|
|||||||
fn point_is_coincident_with_edge() {
|
fn point_is_coincident_with_edge() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, 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();
|
||||||
@ -282,7 +282,7 @@ mod tests {
|
|||||||
fn point_is_coincident_with_vertex() {
|
fn point_is_coincident_with_vertex() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, 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();
|
||||||
|
@ -152,7 +152,7 @@ mod tests {
|
|||||||
transform::TransformObject,
|
transform::TransformObject,
|
||||||
},
|
},
|
||||||
iter::ObjectIters,
|
iter::ObjectIters,
|
||||||
objects::{Face, Objects, Surface},
|
objects::{Face, Objects},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -161,7 +161,7 @@ mod tests {
|
|||||||
|
|
||||||
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::yz_plane());
|
let surface = objects.surfaces.yz_plane();
|
||||||
let face = Face::builder(&objects, surface)
|
let face = Face::builder(&objects, surface)
|
||||||
.with_exterior_polygon_from_points([
|
.with_exterior_polygon_from_points([
|
||||||
[-1., -1.],
|
[-1., -1.],
|
||||||
@ -181,7 +181,7 @@ mod tests {
|
|||||||
|
|
||||||
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::yz_plane());
|
let surface = objects.surfaces.yz_plane();
|
||||||
let face = Face::builder(&objects, surface)
|
let face = Face::builder(&objects, surface)
|
||||||
.with_exterior_polygon_from_points([
|
.with_exterior_polygon_from_points([
|
||||||
[-1., -1.],
|
[-1., -1.],
|
||||||
@ -204,7 +204,7 @@ mod tests {
|
|||||||
|
|
||||||
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::yz_plane());
|
let surface = objects.surfaces.yz_plane();
|
||||||
let face = Face::builder(&objects, surface)
|
let face = Face::builder(&objects, surface)
|
||||||
.with_exterior_polygon_from_points([
|
.with_exterior_polygon_from_points([
|
||||||
[-1., -1.],
|
[-1., -1.],
|
||||||
@ -224,7 +224,7 @@ mod tests {
|
|||||||
|
|
||||||
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::yz_plane());
|
let surface = objects.surfaces.yz_plane();
|
||||||
let face = Face::builder(&objects, surface)
|
let face = Face::builder(&objects, surface)
|
||||||
.with_exterior_polygon_from_points([
|
.with_exterior_polygon_from_points([
|
||||||
[-1., -1.],
|
[-1., -1.],
|
||||||
@ -255,7 +255,7 @@ mod tests {
|
|||||||
|
|
||||||
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::yz_plane());
|
let surface = objects.surfaces.yz_plane();
|
||||||
let face = Face::builder(&objects, surface)
|
let face = Face::builder(&objects, surface)
|
||||||
.with_exterior_polygon_from_points([
|
.with_exterior_polygon_from_points([
|
||||||
[-1., -1.],
|
[-1., -1.],
|
||||||
@ -284,7 +284,7 @@ mod tests {
|
|||||||
|
|
||||||
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, surface)
|
let face = Face::builder(&objects, surface)
|
||||||
.with_exterior_polygon_from_points([
|
.with_exterior_polygon_from_points([
|
||||||
[-1., -1.],
|
[-1., -1.],
|
||||||
@ -306,7 +306,7 @@ mod tests {
|
|||||||
|
|
||||||
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, surface)
|
let face = Face::builder(&objects, surface)
|
||||||
.with_exterior_polygon_from_points([
|
.with_exterior_polygon_from_points([
|
||||||
[-1., -1.],
|
[-1., -1.],
|
||||||
|
@ -88,7 +88,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::transform::TransformObject,
|
algorithms::transform::TransformObject,
|
||||||
objects::{Curve, Objects, Surface},
|
objects::{Curve, Objects},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
};
|
};
|
||||||
@ -99,8 +99,8 @@ mod tests {
|
|||||||
fn plane_plane() {
|
fn plane_plane() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let xy = objects.surfaces.insert(Surface::xy_plane());
|
let xy = objects.surfaces.xy_plane();
|
||||||
let xz = objects.surfaces.insert(Surface::xz_plane());
|
let xz = objects.surfaces.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!(
|
||||||
|
@ -188,7 +188,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::{reverse::Reverse, sweep::Sweep},
|
algorithms::{reverse::Reverse, sweep::Sweep},
|
||||||
objects::{Cycle, Face, HalfEdge, Objects, Surface},
|
objects::{Cycle, Face, HalfEdge, Objects},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -197,14 +197,14 @@ mod tests {
|
|||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let half_edge = HalfEdge::partial()
|
let half_edge = HalfEdge::partial()
|
||||||
.with_surface(Some(objects.surfaces.insert(Surface::xy_plane())))
|
.with_surface(Some(objects.surfaces.xy_plane()))
|
||||||
.as_line_segment_from_points([[0., 0.], [1., 0.]])
|
.as_line_segment_from_points([[0., 0.], [1., 0.]])
|
||||||
.build(&objects);
|
.build(&objects);
|
||||||
|
|
||||||
let face = (half_edge, Color::default()).sweep([0., 0., 1.], &objects);
|
let face = (half_edge, Color::default()).sweep([0., 0., 1.], &objects);
|
||||||
|
|
||||||
let expected_face = {
|
let expected_face = {
|
||||||
let surface = objects.surfaces.insert(Surface::xz_plane());
|
let surface = objects.surfaces.xz_plane();
|
||||||
|
|
||||||
let bottom = HalfEdge::partial()
|
let bottom = HalfEdge::partial()
|
||||||
.with_surface(Some(surface.clone()))
|
.with_surface(Some(surface.clone()))
|
||||||
|
@ -80,7 +80,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::{reverse::Reverse, transform::TransformObject},
|
algorithms::{reverse::Reverse, transform::TransformObject},
|
||||||
objects::{Face, HalfEdge, Objects, Sketch, Surface},
|
objects::{Face, HalfEdge, Objects, Sketch},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ mod tests {
|
|||||||
fn sweep_up() {
|
fn sweep_up() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let solid = Sketch::builder(&objects, surface.clone())
|
let solid = Sketch::builder(&objects, surface.clone())
|
||||||
.build_polygon_from_points(TRIANGLE)
|
.build_polygon_from_points(TRIANGLE)
|
||||||
.sweep(UP, &objects);
|
.sweep(UP, &objects);
|
||||||
@ -119,9 +119,7 @@ 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(
|
.with_surface(Some(objects.surfaces.xy_plane()))
|
||||||
objects.surfaces.insert(Surface::xy_plane()),
|
|
||||||
))
|
|
||||||
.as_line_segment_from_points([a, b])
|
.as_line_segment_from_points([a, b])
|
||||||
.build(&objects);
|
.build(&objects);
|
||||||
(half_edge, Color::default()).sweep(UP, &objects)
|
(half_edge, Color::default()).sweep(UP, &objects)
|
||||||
@ -134,7 +132,7 @@ mod tests {
|
|||||||
fn sweep_down() {
|
fn sweep_down() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let solid = Sketch::builder(&objects, surface.clone())
|
let solid = Sketch::builder(&objects, surface.clone())
|
||||||
.build_polygon_from_points(TRIANGLE)
|
.build_polygon_from_points(TRIANGLE)
|
||||||
.sweep(DOWN, &objects);
|
.sweep(DOWN, &objects);
|
||||||
@ -159,9 +157,7 @@ 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(
|
.with_surface(Some(objects.surfaces.xy_plane()))
|
||||||
objects.surfaces.insert(Surface::xy_plane()),
|
|
||||||
))
|
|
||||||
.as_line_segment_from_points([a, b])
|
.as_line_segment_from_points([a, b])
|
||||||
.build(&objects)
|
.build(&objects)
|
||||||
.reverse();
|
.reverse();
|
||||||
|
@ -154,7 +154,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::sweep::Sweep,
|
algorithms::sweep::Sweep,
|
||||||
objects::{Curve, HalfEdge, Objects, Surface, Vertex},
|
objects::{Curve, HalfEdge, Objects, Vertex},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
};
|
};
|
||||||
@ -163,7 +163,7 @@ mod tests {
|
|||||||
fn vertex_surface() {
|
fn vertex_surface() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xz_plane());
|
let surface = objects.surfaces.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()
|
||||||
|
@ -84,7 +84,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::approx::{Approx, Tolerance},
|
algorithms::approx::{Approx, Tolerance},
|
||||||
objects::{Face, Objects, Surface},
|
objects::{Face, Objects},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::Triangulate;
|
use super::Triangulate;
|
||||||
@ -98,7 +98,7 @@ mod tests {
|
|||||||
let c = [2., 2.];
|
let c = [2., 2.];
|
||||||
let d = [0., 1.];
|
let d = [0., 1.];
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, 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();
|
||||||
@ -132,7 +132,7 @@ mod tests {
|
|||||||
let g = [3., 3.];
|
let g = [3., 3.];
|
||||||
let h = [3., 1.];
|
let h = [3., 1.];
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, 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])
|
||||||
@ -192,7 +192,7 @@ 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 = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, 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();
|
||||||
|
@ -167,7 +167,7 @@ mod tests {
|
|||||||
algorithms::validate::{Validate, ValidationConfig, ValidationError},
|
algorithms::validate::{Validate, ValidationConfig, ValidationError},
|
||||||
objects::{
|
objects::{
|
||||||
Curve, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Objects,
|
Curve, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Objects,
|
||||||
Surface, SurfaceVertex, Vertex,
|
SurfaceVertex, Vertex,
|
||||||
},
|
},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
path::SurfacePath,
|
path::SurfacePath,
|
||||||
@ -177,7 +177,7 @@ mod tests {
|
|||||||
fn coherence_edge() {
|
fn coherence_edge() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.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.]];
|
||||||
|
@ -34,7 +34,7 @@ impl<'a> ShellBuilder<'a> {
|
|||||||
let surface = self
|
let surface = self
|
||||||
.objects
|
.objects
|
||||||
.surfaces
|
.surfaces
|
||||||
.insert(Surface::xy_plane())
|
.xy_plane()
|
||||||
.translate([Z, Z, -h], self.objects);
|
.translate([Z, Z, -h], self.objects);
|
||||||
|
|
||||||
Face::builder(self.objects, surface)
|
Face::builder(self.objects, surface)
|
||||||
@ -186,7 +186,7 @@ impl<'a> ShellBuilder<'a> {
|
|||||||
let surface = self
|
let surface = self
|
||||||
.objects
|
.objects
|
||||||
.surfaces
|
.surfaces
|
||||||
.insert(Surface::xy_plane())
|
.xy_plane()
|
||||||
.translate([Z, Z, h], self.objects);
|
.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]];
|
||||||
|
@ -362,7 +362,7 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
objects::{
|
objects::{
|
||||||
Curve, Cycle, Face, GlobalCurve, GlobalVertex, HalfEdge, Objects,
|
Curve, Cycle, Face, GlobalCurve, GlobalVertex, HalfEdge, Objects,
|
||||||
Shell, Sketch, Solid, Surface, SurfaceVertex, Vertex,
|
Shell, Sketch, Solid, SurfaceVertex, Vertex,
|
||||||
},
|
},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
@ -374,7 +374,7 @@ mod tests {
|
|||||||
fn curve() {
|
fn curve() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.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()
|
||||||
@ -397,7 +397,7 @@ mod tests {
|
|||||||
fn cycle() {
|
fn cycle() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.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.]])
|
||||||
@ -421,7 +421,7 @@ mod tests {
|
|||||||
fn face() {
|
fn face() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let object = Face::builder(&objects, 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();
|
||||||
@ -482,7 +482,7 @@ mod tests {
|
|||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let object = HalfEdge::partial()
|
let object = HalfEdge::partial()
|
||||||
.with_surface(Some(objects.surfaces.insert(Surface::xy_plane())))
|
.with_surface(Some(objects.surfaces.xy_plane()))
|
||||||
.as_line_segment_from_points([[0., 0.], [1., 0.]])
|
.as_line_segment_from_points([[0., 0.], [1., 0.]])
|
||||||
.build(&objects);
|
.build(&objects);
|
||||||
|
|
||||||
@ -522,7 +522,7 @@ mod tests {
|
|||||||
fn sketch() {
|
fn sketch() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
let face = Face::builder(&objects, 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();
|
||||||
@ -564,7 +564,7 @@ mod tests {
|
|||||||
fn surface() {
|
fn surface() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let object = objects.surfaces.insert(Surface::xy_plane());
|
let object = objects.surfaces.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());
|
||||||
@ -583,7 +583,7 @@ mod tests {
|
|||||||
fn vertex() {
|
fn vertex() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.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()
|
||||||
|
@ -172,10 +172,7 @@ impl VerticesInNormalizedOrder {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use crate::{
|
use crate::{objects::Objects, partial::HasPartial};
|
||||||
objects::{Objects, Surface},
|
|
||||||
partial::HasPartial,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::HalfEdge;
|
use super::HalfEdge;
|
||||||
|
|
||||||
@ -183,7 +180,7 @@ mod tests {
|
|||||||
fn global_edge_equality() {
|
fn global_edge_equality() {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.insert(Surface::xy_plane());
|
let surface = objects.surfaces.xy_plane();
|
||||||
|
|
||||||
let a = [0., 0.];
|
let a = [0., 0.];
|
||||||
let b = [1., 0.];
|
let b = [1., 0.];
|
||||||
|
@ -26,9 +26,9 @@ 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(objects: &Objects) -> Self {
|
pub fn new(objects: &Objects) -> Self {
|
||||||
let xy = objects.surfaces.insert(Surface::xy_plane());
|
let xy = objects.surfaces.xy_plane();
|
||||||
let xz = objects.surfaces.insert(Surface::xz_plane());
|
let xz = objects.surfaces.xz_plane();
|
||||||
let yz = objects.surfaces.insert(Surface::yz_plane());
|
let yz = objects.surfaces.yz_plane();
|
||||||
|
|
||||||
Self { xy, xz, yz }
|
Self { xy, xz, yz }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user