-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct face orientation fixes #506 #628
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,18 @@ pub fn sweep_shape( | |
let translation = Transform::translation(path); | ||
|
||
let (mut bottom, source_to_bottom) = source.clone_shape(); | ||
bottom | ||
.update() | ||
.update_all(|surface: &mut Surface| *surface = surface.reverse()) | ||
.validate()?; | ||
|
||
let (mut top, source_to_top) = source.clone_shape(); | ||
|
||
if path.dot(&Vector::from([0., 0., 1.])) >= fj_math::Scalar::from_f64(0.) { | ||
bottom | ||
.update() | ||
.update_all(|surface: &mut Surface| *surface = surface.reverse()) | ||
.validate()?; | ||
} else { | ||
top.update() | ||
.update_all(|surface: &mut Surface| *surface = surface.reverse()) | ||
.validate()?; | ||
} | ||
transform_shape(&mut top, &translation); | ||
|
||
let mut target = Shape::new(); | ||
|
@@ -118,11 +124,22 @@ pub fn sweep_shape( | |
let top_edge = | ||
source_to_top.edges().get(&edge_source).unwrap().clone(); | ||
|
||
let surface = | ||
let surface = if path.dot(&Vector::from([0., 0., 1.])) | ||
>= fj_math::Scalar::from_f64(0.) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that |
||
{ | ||
target.insert(Surface::SweptCurve(SweptCurve { | ||
curve: bottom_edge.get().curve(), | ||
path, | ||
}))?; | ||
}))? | ||
} else { | ||
target.insert( | ||
Surface::SweptCurve(SweptCurve { | ||
curve: bottom_edge.get().curve(), | ||
path, | ||
}) | ||
.reverse(), //////////////////////////////////// | ||
Comment on lines
+135
to
+140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be a bit nicer to reduce some duplication here. Something like this: let mut surface = Surface::SweptCurve(...);
if sweep_along_negative_direction {
surface = surface.reverse();
}
let surface = target.insert(surface)?; |
||
)? | ||
}; | ||
|
||
let cycle = target.merge(Cycle::new(vec![ | ||
bottom_edge, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nicer, if that check happened only once, and the result was stored into a variable with a descriptive name (
sweep_along_negative_direction
, or something like that).With two separate checks, it becomes easy to miss one, once they need to change.