mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-11 02:37:00 +00:00
Merge pull request #2340 from hannobraun/geometry
Set curve geometry in shell validation test
This commit is contained in:
commit
eb6ac63e03
@ -10,6 +10,13 @@ use crate::{
|
||||
|
||||
/// Update the geometry of a [`Curve`]
|
||||
pub trait UpdateCurveGeometry {
|
||||
/// Copy the geometry of the provided curve
|
||||
fn copy_geometry_from(
|
||||
self,
|
||||
curve: &Handle<Curve>,
|
||||
geometry: &mut Layer<Geometry>,
|
||||
) -> Self;
|
||||
|
||||
/// Define the geometry as a path on a surface
|
||||
fn make_path_on_surface(
|
||||
self,
|
||||
@ -35,6 +42,21 @@ pub trait UpdateCurveGeometry {
|
||||
}
|
||||
|
||||
impl UpdateCurveGeometry for Handle<Curve> {
|
||||
fn copy_geometry_from(
|
||||
self,
|
||||
curve: &Handle<Curve>,
|
||||
geometry: &mut Layer<Geometry>,
|
||||
) -> Self {
|
||||
let curve_geom = geometry.of_curve(curve).cloned();
|
||||
if let Some(curve_geom) = curve_geom {
|
||||
for (surface, local_definition) in curve_geom.definitions {
|
||||
geometry.define_curve(self.clone(), surface, local_definition);
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
fn make_path_on_surface(
|
||||
self,
|
||||
path: SurfacePath,
|
||||
|
@ -1,7 +1,10 @@
|
||||
use fj_math::Transform;
|
||||
|
||||
use crate::{
|
||||
operations::insert::Insert, storage::Handle, topology::Curve, Core,
|
||||
operations::{geometry::UpdateCurveGeometry, insert::Insert},
|
||||
storage::Handle,
|
||||
topology::Curve,
|
||||
Core,
|
||||
};
|
||||
|
||||
use super::{TransformCache, TransformObject};
|
||||
@ -20,21 +23,9 @@ impl TransformObject for Handle<Curve> {
|
||||
// geometry is locally defined on a surface. We need to set that
|
||||
// geometry for the new object though, that we created here to
|
||||
// represent the transformed curve.
|
||||
|
||||
let curve = Curve::new().insert(core);
|
||||
|
||||
let curve_geom = core.layers.geometry.of_curve(self).cloned();
|
||||
if let Some(curve_geom) = curve_geom {
|
||||
for (surface, local_definition) in curve_geom.definitions {
|
||||
core.layers.geometry.define_curve(
|
||||
curve.clone(),
|
||||
surface,
|
||||
local_definition,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
curve
|
||||
Curve::new()
|
||||
.insert(core)
|
||||
.copy_geometry_from(self, &mut core.layers.geometry)
|
||||
})
|
||||
.clone()
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ mod tests {
|
||||
assert_contains_err,
|
||||
operations::{
|
||||
build::BuildShell,
|
||||
geometry::UpdateHalfEdgeGeometry,
|
||||
geometry::{UpdateCurveGeometry, UpdateHalfEdgeGeometry},
|
||||
insert::Insert,
|
||||
update::{
|
||||
UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateRegion,
|
||||
@ -539,11 +539,15 @@ mod tests {
|
||||
cycle.update_half_edge(
|
||||
cycle.half_edges().nth_circular(0),
|
||||
|half_edge, core| {
|
||||
let curve = Curve::new()
|
||||
.insert(core)
|
||||
.copy_geometry_from(
|
||||
half_edge.curve(),
|
||||
&mut core.layers.geometry,
|
||||
);
|
||||
|
||||
[half_edge
|
||||
.update_curve(
|
||||
|_, _| Curve::new(),
|
||||
core,
|
||||
)
|
||||
.update_curve(|_, _| curve, core)
|
||||
.insert(core)
|
||||
.set_geometry(
|
||||
*core
|
||||
|
Loading…
Reference in New Issue
Block a user