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`]
|
/// Update the geometry of a [`Curve`]
|
||||||
pub trait UpdateCurveGeometry {
|
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
|
/// Define the geometry as a path on a surface
|
||||||
fn make_path_on_surface(
|
fn make_path_on_surface(
|
||||||
self,
|
self,
|
||||||
@ -35,6 +42,21 @@ pub trait UpdateCurveGeometry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl UpdateCurveGeometry for Handle<Curve> {
|
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(
|
fn make_path_on_surface(
|
||||||
self,
|
self,
|
||||||
path: SurfacePath,
|
path: SurfacePath,
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
use fj_math::Transform;
|
use fj_math::Transform;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
operations::insert::Insert, storage::Handle, topology::Curve, Core,
|
operations::{geometry::UpdateCurveGeometry, insert::Insert},
|
||||||
|
storage::Handle,
|
||||||
|
topology::Curve,
|
||||||
|
Core,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{TransformCache, TransformObject};
|
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 is locally defined on a surface. We need to set that
|
||||||
// geometry for the new object though, that we created here to
|
// geometry for the new object though, that we created here to
|
||||||
// represent the transformed curve.
|
// represent the transformed curve.
|
||||||
|
Curve::new()
|
||||||
let curve = Curve::new().insert(core);
|
.insert(core)
|
||||||
|
.copy_geometry_from(self, &mut core.layers.geometry)
|
||||||
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
|
|
||||||
})
|
})
|
||||||
.clone()
|
.clone()
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ mod tests {
|
|||||||
assert_contains_err,
|
assert_contains_err,
|
||||||
operations::{
|
operations::{
|
||||||
build::BuildShell,
|
build::BuildShell,
|
||||||
geometry::UpdateHalfEdgeGeometry,
|
geometry::{UpdateCurveGeometry, UpdateHalfEdgeGeometry},
|
||||||
insert::Insert,
|
insert::Insert,
|
||||||
update::{
|
update::{
|
||||||
UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateRegion,
|
UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateRegion,
|
||||||
@ -539,11 +539,15 @@ mod tests {
|
|||||||
cycle.update_half_edge(
|
cycle.update_half_edge(
|
||||||
cycle.half_edges().nth_circular(0),
|
cycle.half_edges().nth_circular(0),
|
||||||
|half_edge, core| {
|
|half_edge, core| {
|
||||||
|
let curve = Curve::new()
|
||||||
|
.insert(core)
|
||||||
|
.copy_geometry_from(
|
||||||
|
half_edge.curve(),
|
||||||
|
&mut core.layers.geometry,
|
||||||
|
);
|
||||||
|
|
||||||
[half_edge
|
[half_edge
|
||||||
.update_curve(
|
.update_curve(|_, _| curve, core)
|
||||||
|_, _| Curve::new(),
|
|
||||||
core,
|
|
||||||
)
|
|
||||||
.insert(core)
|
.insert(core)
|
||||||
.set_geometry(
|
.set_geometry(
|
||||||
*core
|
*core
|
||||||
|
Loading…
Reference in New Issue
Block a user