Add ReverseCurveCoordinateSystems::Reversed

This is preparation for some other changes to make the trait more
flexible.
This commit is contained in:
Hanno Braun 2024-05-08 13:39:26 +02:00
parent 53db1db8e9
commit 9db2e6a389
5 changed files with 31 additions and 5 deletions

View File

@ -34,7 +34,12 @@ impl Reverse for Cycle {
}
impl ReverseCurveCoordinateSystems for Cycle {
fn reverse_curve_coordinate_systems(&self, core: &mut Core) -> Self {
type Reversed = Cycle;
fn reverse_curve_coordinate_systems(
&self,
core: &mut Core,
) -> Self::Reversed {
let edges = self
.half_edges()
.iter()

View File

@ -43,7 +43,12 @@ impl<const D: usize> Reverse for Polygon<D, IsInsertedYes> {
}
impl ReverseCurveCoordinateSystems for Face {
fn reverse_curve_coordinate_systems(&self, core: &mut Core) -> Self {
type Reversed = Face;
fn reverse_curve_coordinate_systems(
&self,
core: &mut Core,
) -> Self::Reversed {
let region = self
.region()
.reverse_curve_coordinate_systems(core)

View File

@ -8,7 +8,12 @@ use crate::{
use super::ReverseCurveCoordinateSystems;
impl ReverseCurveCoordinateSystems for Handle<HalfEdge> {
fn reverse_curve_coordinate_systems(&self, core: &mut Core) -> Self {
type Reversed = Handle<HalfEdge>;
fn reverse_curve_coordinate_systems(
&self,
core: &mut Core,
) -> Self::Reversed {
let mut half_edge_geom = *core.layers.geometry.of_half_edge(self);
half_edge_geom.path = half_edge_geom.path.reverse();
half_edge_geom.boundary = half_edge_geom.boundary.reverse();

View File

@ -16,9 +16,15 @@ pub trait Reverse {
/// Reverse the direction of the curve coordinate systems within an object
pub trait ReverseCurveCoordinateSystems {
/// The type of the reversed object
type Reversed;
/// Reverse the direction of the curve coordinate systems within an object
///
/// This will not have any effect on object positions in global coordinates.
#[must_use]
fn reverse_curve_coordinate_systems(&self, core: &mut Core) -> Self;
fn reverse_curve_coordinate_systems(
&self,
core: &mut Core,
) -> Self::Reversed;
}

View File

@ -22,7 +22,12 @@ impl Reverse for Region {
}
impl ReverseCurveCoordinateSystems for Region {
fn reverse_curve_coordinate_systems(&self, core: &mut Core) -> Self {
type Reversed = Region;
fn reverse_curve_coordinate_systems(
&self,
core: &mut Core,
) -> Self::Reversed {
let exterior = self
.exterior()
.reverse_curve_coordinate_systems(core)