Skip to content

Commit

Permalink
Define curve geometry in BuildHalfEdge
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Apr 26, 2024
1 parent 23684c2 commit d97582c
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions crates/fj-core/src/operations/build/half_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use fj_interop::ext::ArrayExt;
use fj_math::{Arc, Point, Scalar};

use crate::{
geometry::{HalfEdgeGeom, SurfacePath},
geometry::{CurveGeom, HalfEdgeGeom, SurfacePath},
operations::{geometry::UpdateHalfEdgeGeometry, insert::Insert},
storage::Handle,
topology::{Curve, HalfEdge, Surface, Vertex},
Expand Down Expand Up @@ -46,7 +46,7 @@ pub trait BuildHalfEdge {
start: impl Into<Point<2>>,
end: impl Into<Point<2>>,
angle_rad: impl Into<Scalar>,
_: Handle<Surface>,
surface: Handle<Surface>,
core: &mut Core,
) -> Handle<HalfEdge> {
let angle_rad = angle_rad.into();
Expand All @@ -62,6 +62,11 @@ pub trait BuildHalfEdge {
[arc.start_angle, arc.end_angle].map(|coord| Point::from([coord]));

let half_edge = HalfEdge::unjoined(core).insert(core);

core.layers.geometry.define_curve(
half_edge.curve().clone(),
CurveGeom::from_path_and_surface(path, surface),
);
core.layers.geometry.define_half_edge(
half_edge.clone(),
HalfEdgeGeom {
Expand All @@ -77,14 +82,19 @@ pub trait BuildHalfEdge {
fn circle(
center: impl Into<Point<2>>,
radius: impl Into<Scalar>,
_: Handle<Surface>,
surface: Handle<Surface>,
core: &mut Core,
) -> Handle<HalfEdge> {
let path = SurfacePath::circle_from_center_and_radius(center, radius);
let boundary =
[Scalar::ZERO, Scalar::TAU].map(|coord| Point::from([coord]));

let half_edge = HalfEdge::unjoined(core).insert(core);

core.layers.geometry.define_curve(
half_edge.curve().clone(),
CurveGeom::from_path_and_surface(path, surface),
);
core.layers.geometry.define_half_edge(
half_edge.clone(),
HalfEdgeGeom {
Expand All @@ -100,7 +110,7 @@ pub trait BuildHalfEdge {
fn line_segment(
points_surface: [impl Into<Point<2>>; 2],
boundary: Option<[Point<1>; 2]>,
_: Handle<Surface>,
surface: Handle<Surface>,
core: &mut Core,
) -> Handle<HalfEdge> {
let boundary =
Expand All @@ -111,6 +121,10 @@ pub trait BuildHalfEdge {

let half_edge = HalfEdge::unjoined(core).insert(core);

core.layers.geometry.define_curve(
half_edge.curve().clone(),
CurveGeom::from_path_and_surface(path, surface),
);
core.layers.geometry.define_half_edge(
half_edge.clone(),
HalfEdgeGeom {
Expand Down

0 comments on commit d97582c

Please sign in to comment.