mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-14 14:58:29 +00:00
Provide surface to Cycle::winding
This commit is contained in:
parent
e33d43b058
commit
61f246213f
@ -42,7 +42,7 @@ impl SweepSketch for Sketch {
|
|||||||
// clockwise. Let's check that real quick.
|
// clockwise. Let's check that real quick.
|
||||||
assert!(region
|
assert!(region
|
||||||
.exterior()
|
.exterior()
|
||||||
.winding(&core.layers.geometry)
|
.winding(&core.layers.geometry, self.surface())
|
||||||
.is_ccw());
|
.is_ccw());
|
||||||
|
|
||||||
let is_negative_sweep = {
|
let is_negative_sweep = {
|
||||||
|
@ -6,6 +6,8 @@ use crate::{
|
|||||||
topology::{HalfEdge, ObjectSet},
|
topology::{HalfEdge, ObjectSet},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::surface::Surface;
|
||||||
|
|
||||||
/// A cycle of connected edges
|
/// A cycle of connected edges
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Cycle {
|
pub struct Cycle {
|
||||||
@ -29,7 +31,7 @@ impl Cycle {
|
|||||||
/// Please note that this is not *the* winding of the cycle, only one of the
|
/// 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
|
/// two possible windings, depending on the direction you look at the
|
||||||
/// surface that the cycle is defined on from.
|
/// 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
|
// 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
|
// case, the winding of the cycle is determined by the winding of the
|
||||||
// first circle.
|
// first circle.
|
||||||
|
@ -63,7 +63,7 @@ impl Face {
|
|||||||
/// back sides. The front side is the side, where the face's exterior cycle
|
/// back sides. The front side is the side, where the face's exterior cycle
|
||||||
/// is wound counter-clockwise.
|
/// is wound counter-clockwise.
|
||||||
pub fn coord_handedness(&self, geometry: &Geometry) -> Handedness {
|
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::Ccw => Handedness::RightHanded,
|
||||||
Winding::Cw => Handedness::LeftHanded,
|
Winding::Cw => Handedness::LeftHanded,
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ impl SketchValidationError {
|
|||||||
) {
|
) {
|
||||||
sketch.regions().iter().for_each(|region| {
|
sketch.regions().iter().for_each(|region| {
|
||||||
let cycle = region.exterior();
|
let cycle = region.exterior();
|
||||||
if cycle.winding(geometry) == Winding::Cw {
|
if cycle.winding(geometry, sketch.surface()) == Winding::Cw {
|
||||||
errors.push(ValidationError::Sketch(
|
errors.push(ValidationError::Sketch(
|
||||||
SketchValidationError::ClockwiseExteriorCycle {
|
SketchValidationError::ClockwiseExteriorCycle {
|
||||||
cycle: cycle.clone(),
|
cycle: cycle.clone(),
|
||||||
@ -97,7 +97,9 @@ impl SketchValidationError {
|
|||||||
region
|
region
|
||||||
.interiors()
|
.interiors()
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|interior| interior.winding(geometry) == Winding::Ccw)
|
.filter(|interior| {
|
||||||
|
interior.winding(geometry, sketch.surface()) == Winding::Ccw
|
||||||
|
})
|
||||||
.for_each(|cycle| {
|
.for_each(|cycle| {
|
||||||
errors.push(ValidationError::Sketch(
|
errors.push(ValidationError::Sketch(
|
||||||
SketchValidationError::CounterClockwiseInteriorCycle {
|
SketchValidationError::CounterClockwiseInteriorCycle {
|
||||||
|
@ -53,8 +53,8 @@ impl ValidationCheck<Face> for InteriorCycleHasInvalidWinding {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let exterior_winding = exterior.winding(geometry);
|
let exterior_winding = exterior.winding(geometry, object.surface());
|
||||||
let interior_winding = interior.winding(geometry);
|
let interior_winding = interior.winding(geometry, object.surface());
|
||||||
|
|
||||||
if exterior_winding == interior_winding {
|
if exterior_winding == interior_winding {
|
||||||
return Some(InteriorCycleHasInvalidWinding {
|
return Some(InteriorCycleHasInvalidWinding {
|
||||||
|
Loading…
Reference in New Issue
Block a user