Skip to content

Commit

Permalink
Merge pull request #1433 from hannobraun/builder
Browse files Browse the repository at this point in the history
Start cleaning up builder API
  • Loading branch information
hannobraun authored Dec 9, 2022
2 parents c72eb99 + 25d22b3 commit aed0b9a
Show file tree
Hide file tree
Showing 14 changed files with 362 additions and 847 deletions.
121 changes: 25 additions & 96 deletions crates/fj-kernel/src/algorithms/intersect/curve_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,11 @@ impl CurveEdgeIntersection {

#[cfg(test)]
mod tests {
use std::array;

use fj_interop::ext::ArrayExt;
use fj_math::Point;

use crate::{
builder::{CurveBuilder, HalfEdgeBuilder},
objects::Vertex,
partial::{
Partial, PartialCurve, PartialGlobalEdge, PartialHalfEdge,
PartialObject,
},
partial::{Partial, PartialCurve, PartialHalfEdge, PartialObject},
services::Services,
};

Expand All @@ -103,29 +96,13 @@ mod tests {
curve.update_as_u_axis();
let curve = curve.build(&mut services.objects);
let half_edge = {
let vertices = array::from_fn(|_| Partial::<Vertex>::new());
let global_curve = {
let [vertex, _] = &vertices;
vertex.read().curve.read().global_form.clone()
};
let global_vertices = vertices.each_ref_ext().map(|vertex| {
vertex.read().surface_form.read().global_form.clone()
});

let half_edge = PartialHalfEdge {
vertices,
global_form: Partial::from_partial(PartialGlobalEdge {
curve: global_curve,
vertices: global_vertices,
}),
};
let mut half_edge = PartialHalfEdge::default();
half_edge.update_as_line_segment_from_points(
surface,
[[1., -1.], [1., 1.]],
);

half_edge
.update_as_line_segment_from_points(
surface,
[[1., -1.], [1., 1.]],
)
.build(&mut services.objects)
half_edge.build(&mut services.objects)
};

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);
Expand All @@ -152,29 +129,13 @@ mod tests {
curve.update_as_u_axis();
let curve = curve.build(&mut services.objects);
let half_edge = {
let vertices = array::from_fn(|_| Partial::<Vertex>::new());
let global_curve = {
let [vertex, _] = &vertices;
vertex.read().curve.read().global_form.clone()
};
let global_vertices = vertices.each_ref_ext().map(|vertex| {
vertex.read().surface_form.read().global_form.clone()
});

let half_edge = PartialHalfEdge {
vertices,
global_form: Partial::from_partial(PartialGlobalEdge {
curve: global_curve,
vertices: global_vertices,
}),
};
let mut half_edge = PartialHalfEdge::default();
half_edge.update_as_line_segment_from_points(
surface,
[[-1., -1.], [-1., 1.]],
);

half_edge
.update_as_line_segment_from_points(
surface,
[[-1., -1.], [-1., 1.]],
)
.build(&mut services.objects)
half_edge.build(&mut services.objects)
};

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);
Expand All @@ -201,29 +162,13 @@ mod tests {
curve.update_as_u_axis();
let curve = curve.build(&mut services.objects);
let half_edge = {
let vertices = array::from_fn(|_| Partial::<Vertex>::new());
let global_curve = {
let [vertex, _] = &vertices;
vertex.read().curve.read().global_form.clone()
};
let global_vertices = vertices.each_ref_ext().map(|vertex| {
vertex.read().surface_form.read().global_form.clone()
});

let half_edge = PartialHalfEdge {
vertices,
global_form: Partial::from_partial(PartialGlobalEdge {
curve: global_curve,
vertices: global_vertices,
}),
};
let mut half_edge = PartialHalfEdge::default();
half_edge.update_as_line_segment_from_points(
surface,
[[-1., -1.], [1., -1.]],
);

half_edge
.update_as_line_segment_from_points(
surface,
[[-1., -1.], [1., -1.]],
)
.build(&mut services.objects)
half_edge.build(&mut services.objects)
};

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);
Expand All @@ -245,29 +190,13 @@ mod tests {
curve.update_as_u_axis();
let curve = curve.build(&mut services.objects);
let half_edge = {
let vertices = array::from_fn(|_| Partial::<Vertex>::new());
let global_curve = {
let [vertex, _] = &vertices;
vertex.read().curve.read().global_form.clone()
};
let global_vertices = vertices.each_ref_ext().map(|vertex| {
vertex.read().surface_form.read().global_form.clone()
});

let half_edge = PartialHalfEdge {
vertices,
global_form: Partial::from_partial(PartialGlobalEdge {
curve: global_curve,
vertices: global_vertices,
}),
};
let mut half_edge = PartialHalfEdge::default();
half_edge.update_as_line_segment_from_points(
surface,
[[-1., 0.], [1., 0.]],
);

half_edge
.update_as_line_segment_from_points(
surface,
[[-1., 0.], [1., 0.]],
)
.build(&mut services.objects)
half_edge.build(&mut services.objects)
};

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

0 comments on commit aed0b9a

Please sign in to comment.