mirror of https://github.com/hannobraun/Fornjot
Simplify `GlobalPath` transforms
It's not an object, so it doesn't make much sense to include it with the transformation infrastructure of objects.
This commit is contained in:
parent
19f802b57e
commit
aaa613ec2e
|
@ -4,7 +4,6 @@ mod curve;
|
|||
mod cycle;
|
||||
mod edge;
|
||||
mod face;
|
||||
mod path;
|
||||
mod shell;
|
||||
mod sketch;
|
||||
mod solid;
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
use fj_math::Transform;
|
||||
|
||||
use crate::{objects::Objects, path::GlobalPath, validate::ValidationError};
|
||||
|
||||
use super::TransformObject;
|
||||
|
||||
impl TransformObject for GlobalPath {
|
||||
fn transform(
|
||||
self,
|
||||
transform: &Transform,
|
||||
_: &Objects,
|
||||
) -> Result<Self, ValidationError> {
|
||||
match self {
|
||||
Self::Circle(curve) => {
|
||||
Ok(Self::Circle(transform.transform_circle(&curve)))
|
||||
}
|
||||
Self::Line(curve) => {
|
||||
Ok(Self::Line(transform.transform_line(&curve)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ impl TransformObject for Handle<Surface> {
|
|||
objects: &Objects,
|
||||
) -> Result<Self, ValidationError> {
|
||||
Ok(objects.surfaces.insert(Surface::new(
|
||||
self.u().transform(transform, objects)?,
|
||||
self.u().transform(transform),
|
||||
transform.transform_vector(&self.v()),
|
||||
))?)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
//! [`Surface`]: crate::objects::Surface
|
||||
//! [#1021]: https://github.com/hannobraun/Fornjot/issues/1021
|
||||
|
||||
use fj_math::{Circle, Line, Point, Scalar, Vector};
|
||||
use fj_math::{Circle, Line, Point, Scalar, Transform, Vector};
|
||||
|
||||
/// A path through surface (2D) space
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||
|
@ -141,4 +141,15 @@ impl GlobalPath {
|
|||
Self::Line(line) => line.vector_from_line_coords(vector),
|
||||
}
|
||||
}
|
||||
|
||||
/// Transform the path
|
||||
#[must_use]
|
||||
pub fn transform(self, transform: &Transform) -> Self {
|
||||
match self {
|
||||
Self::Circle(curve) => {
|
||||
Self::Circle(transform.transform_circle(&curve))
|
||||
}
|
||||
Self::Line(curve) => Self::Line(transform.transform_line(&curve)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue