Set curve geometry in SweepHalfEdge

This commit is contained in:
Hanno Braun 2024-05-07 13:36:18 +02:00
parent 55cf57ba8d
commit d7c546f606

View File

@ -2,16 +2,16 @@ use fj_interop::{ext::ArrayExt, Color};
use fj_math::{Point, Scalar, Vector}; use fj_math::{Point, Scalar, Vector};
use crate::{ use crate::{
geometry::CurveBoundary, geometry::{CurveBoundary, HalfEdgeGeom},
operations::{ operations::{
build::{BuildCycle, BuildHalfEdge}, build::{BuildCycle, BuildHalfEdge},
geometry::UpdateHalfEdgeGeometry, geometry::{UpdateCurveGeometry, UpdateHalfEdgeGeometry},
insert::Insert, insert::Insert,
presentation::SetColor, presentation::SetColor,
update::{UpdateCycle, UpdateHalfEdge}, update::{UpdateCycle, UpdateHalfEdge},
}, },
storage::Handle, storage::Handle,
topology::{Cycle, Face, HalfEdge, Region, Surface, Vertex}, topology::{Curve, Cycle, Face, HalfEdge, Region, Surface, Vertex},
Core, Core,
}; };
@ -121,27 +121,35 @@ impl SweepHalfEdge for Handle<HalfEdge> {
.map(|((((boundary, start), end), start_vertex), curve)| { .map(|((((boundary, start), end), start_vertex), curve)| {
let boundary = CurveBoundary { inner: boundary }; let boundary = CurveBoundary { inner: boundary };
let half_edge = { let curve = curve
let line_segment = HalfEdge::line_segment( .unwrap_or_else(|| Curve::new().insert(core))
.make_line_on_surface(
[start, end], [start, end],
Some(boundary), Some(boundary),
surface.clone(), surface.clone(),
core,
);
let half_edge = line_segment
.update_start_vertex(|_, _| start_vertex, core);
let half_edge = if let Some(curve) = curve {
half_edge.update_curve(|_, _| curve, core)
} else {
half_edge
};
half_edge.insert(core).set_geometry(
*core.layers.geometry.of_half_edge(&line_segment),
&mut core.layers.geometry, &mut core.layers.geometry,
) );
};
let half_edge = HalfEdge::unjoined(core)
.update_start_vertex(|_, _| start_vertex, core)
.update_curve(|_, _| curve.clone(), core)
.insert(core)
.set_geometry(
HalfEdgeGeom {
path: core
.layers
.geometry
.of_curve(&curve)
.expect(
"Curve geometry was just \
defined in same function",
)
.local_on(&surface)
.path,
boundary,
},
&mut core.layers.geometry,
);
exterior = exterior.add_half_edges([half_edge.clone()], core); exterior = exterior.add_half_edges([half_edge.clone()], core);