mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-11 02:37:00 +00:00
Merge pull request #2339 from hannobraun/geometry
Set curve geometry when transforming curve
This commit is contained in:
commit
5f648b031a
@ -108,10 +108,8 @@ impl Geometry {
|
|||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
/// Panics, if the geometry of the curve is not defined.
|
/// Panics, if the geometry of the curve is not defined.
|
||||||
pub fn of_curve(&self, curve: &Handle<Curve>) -> &CurveGeom {
|
pub fn of_curve(&self, curve: &Handle<Curve>) -> Option<&CurveGeom> {
|
||||||
self.curve
|
self.curve.get(curve)
|
||||||
.get(curve)
|
|
||||||
.expect("Expected geometry of half-edge to be defined")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Access the geometry of the provided half-edge
|
/// # Access the geometry of the provided half-edge
|
||||||
|
@ -133,6 +133,7 @@ pub trait BuildHalfEdge {
|
|||||||
.layers
|
.layers
|
||||||
.geometry
|
.geometry
|
||||||
.of_curve(half_edge.curve())
|
.of_curve(half_edge.curve())
|
||||||
|
.expect("Curve geometry was just defined in same function")
|
||||||
.local_on(&surface)
|
.local_on(&surface)
|
||||||
.path,
|
.path,
|
||||||
boundary: boundary.unwrap_or_default(),
|
boundary: boundary.unwrap_or_default(),
|
||||||
|
@ -107,6 +107,10 @@ pub trait BuildShell {
|
|||||||
.layers
|
.layers
|
||||||
.geometry
|
.geometry
|
||||||
.of_curve(&curve)
|
.of_curve(&curve)
|
||||||
|
.expect(
|
||||||
|
"Curve geometry was just \
|
||||||
|
defined in same function",
|
||||||
|
)
|
||||||
.local_on(&surface)
|
.local_on(&surface)
|
||||||
.path,
|
.path,
|
||||||
boundary,
|
boundary,
|
||||||
|
@ -1,19 +1,41 @@
|
|||||||
use fj_math::Transform;
|
use fj_math::Transform;
|
||||||
|
|
||||||
use crate::{topology::Curve, Core};
|
use crate::{
|
||||||
|
operations::insert::Insert, storage::Handle, topology::Curve, Core,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{TransformCache, TransformObject};
|
use super::{TransformCache, TransformObject};
|
||||||
|
|
||||||
impl TransformObject for Curve {
|
impl TransformObject for Handle<Curve> {
|
||||||
fn transform_with_cache(
|
fn transform_with_cache(
|
||||||
&self,
|
&self,
|
||||||
_: &Transform,
|
_: &Transform,
|
||||||
_: &mut Core,
|
core: &mut Core,
|
||||||
_: &mut TransformCache,
|
cache: &mut TransformCache,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// There's nothing to actually transform here, as `Curve` holds no data.
|
cache
|
||||||
// We still need this implementation though, as a new `Curve` object
|
.entry(self)
|
||||||
// must be created to represent the new and transformed curve.
|
.or_insert_with(|| {
|
||||||
Self::new()
|
// We don't actually need to transform the curve, as its
|
||||||
|
// 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
|
||||||
|
})
|
||||||
|
.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user