Provide surface to Cycle::winding

This commit is contained in:
Hanno Braun 2024-03-27 13:30:27 +01:00 committed by Hanno Braun
parent e33d43b058
commit 61f246213f
5 changed files with 11 additions and 7 deletions

View File

@ -42,7 +42,7 @@ impl SweepSketch for Sketch {
// clockwise. Let's check that real quick.
assert!(region
.exterior()
.winding(&core.layers.geometry)
.winding(&core.layers.geometry, self.surface())
.is_ccw());
let is_negative_sweep = {

View File

@ -6,6 +6,8 @@ use crate::{
topology::{HalfEdge, ObjectSet},
};
use super::surface::Surface;
/// A cycle of connected edges
#[derive(Clone, Debug)]
pub struct Cycle {
@ -29,7 +31,7 @@ impl Cycle {
/// Please note that this is not *the* winding of the cycle, only one of the
/// two possible windings, depending on the direction you look at the
/// surface that the cycle is defined on from.
pub fn winding(&self, geometry: &Geometry) -> Winding {
pub fn winding(&self, geometry: &Geometry, _: &Handle<Surface>) -> Winding {
// The cycle could be made up of one or two circles. If that is the
// case, the winding of the cycle is determined by the winding of the
// first circle.

View File

@ -63,7 +63,7 @@ impl Face {
/// back sides. The front side is the side, where the face's exterior cycle
/// is wound counter-clockwise.
pub fn coord_handedness(&self, geometry: &Geometry) -> Handedness {
match self.region.exterior().winding(geometry) {
match self.region.exterior().winding(geometry, self.surface()) {
Winding::Ccw => Handedness::RightHanded,
Winding::Cw => Handedness::LeftHanded,
}

View File

@ -77,7 +77,7 @@ impl SketchValidationError {
) {
sketch.regions().iter().for_each(|region| {
let cycle = region.exterior();
if cycle.winding(geometry) == Winding::Cw {
if cycle.winding(geometry, sketch.surface()) == Winding::Cw {
errors.push(ValidationError::Sketch(
SketchValidationError::ClockwiseExteriorCycle {
cycle: cycle.clone(),
@ -97,7 +97,9 @@ impl SketchValidationError {
region
.interiors()
.iter()
.filter(|interior| interior.winding(geometry) == Winding::Ccw)
.filter(|interior| {
interior.winding(geometry, sketch.surface()) == Winding::Ccw
})
.for_each(|cycle| {
errors.push(ValidationError::Sketch(
SketchValidationError::CounterClockwiseInteriorCycle {

View File

@ -53,8 +53,8 @@ impl ValidationCheck<Face> for InteriorCycleHasInvalidWinding {
return None;
}
let exterior_winding = exterior.winding(geometry);
let interior_winding = interior.winding(geometry);
let exterior_winding = exterior.winding(geometry, object.surface());
let interior_winding = interior.winding(geometry, object.surface());
if exterior_winding == interior_winding {
return Some(InteriorCycleHasInvalidWinding {