mod curve;
mod cycle;
mod edge;
mod face;
mod path;
mod shell;
mod sketch;
mod solid;
mod surface;
mod vertex;
use fj_math::{Transform, Vector};
use crate::{
partial::{HasPartial, MaybePartial, Partial},
stores::Stores,
};
pub trait TransformObject: Sized {
#[must_use]
fn transform(self, transform: &Transform, stores: &Stores) -> Self;
#[must_use]
fn translate(self, offset: impl Into<Vector<3>>, stores: &Stores) -> Self {
self.transform(&Transform::translation(offset), stores)
}
#[must_use]
fn rotate(self, axis_angle: impl Into<Vector<3>>, stores: &Stores) -> Self {
self.transform(&Transform::rotation(axis_angle), stores)
}
}
impl<T> TransformObject for T
where
T: HasPartial,
T::Partial: TransformObject,
{
fn transform(self, transform: &Transform, stores: &Stores) -> Self {
self.to_partial().transform(transform, stores).build(stores)
}
}
impl<T> TransformObject for MaybePartial<T>
where
T: HasPartial + TransformObject,
T::Partial: TransformObject,
{
fn transform(self, transform: &Transform, stores: &Stores) -> Self {
match self {
Self::Full(full) => Self::Full(full.transform(transform, stores)),
Self::Partial(partial) => {
Self::Partial(partial.transform(transform, stores))
}
}
}
}