Class-A surfacing 3/3: blend curves, curved-edge fillets, the G2 corner and continuity analysis (#1642)
Thanks @midasdf.
This commit is contained in:
1 parent
3126962cd4
commit
bbd4f29ebb
43 files changed
+4753
-132
No files matched your search
@@ -32,7 +32,8 @@ fn segment(s: &Seg2) -> Result<w::Segment> {
|
||||
Seg2::Conic { a, apex, b, w } => w::Segment::Conic { points: [a, apex, b].map(point2), middle_weight: w },
|
||||
Seg2::Bezier { n, p } => {
|
||||
let count = usize::from(n) + 1;
|
||||
if !(5..=8).contains(&count) || p.get(count..).is_none_or(|unused| unused.iter().any(|p| *p != Vec2::ZERO)) {
|
||||
if !(5..=solidcraft_geom::MAX_BEZIER_CTRL).contains(&count) || p.get(count..).is_none_or(|unused| unused.iter().any(|p| *p != Vec2::ZERO))
|
||||
{
|
||||
return Err(invalid("unsupported certificate Bezier layout"));
|
||||
}
|
||||
w::Segment::Bezier { points: p.get(..count).ok_or_else(|| invalid("Bezier count"))?.iter().copied().map(point2).collect() }
|
||||
@@ -46,10 +47,10 @@ fn load_segment(s: w::Segment) -> Result<Seg2> {
|
||||
w::Segment::Cubic { points: [a, b, c, d] } => Seg2::Cubic { p0: p2(a), p1: p2(b), p2: p2(c), p3: p2(d) },
|
||||
w::Segment::Conic { points: [a, apex, b], middle_weight } => Seg2::Conic { a: p2(a), apex: p2(apex), b: p2(b), w: middle_weight },
|
||||
w::Segment::Bezier { points } => {
|
||||
if !(5..=8).contains(&points.len()) {
|
||||
if !(5..=solidcraft_geom::MAX_BEZIER_CTRL).contains(&points.len()) {
|
||||
return Err(invalid("certificate Bezier degree"));
|
||||
}
|
||||
let mut p = [Vec2::ZERO; 8];
|
||||
let mut p = [Vec2::ZERO; solidcraft_geom::MAX_BEZIER_CTRL];
|
||||
let n = (points.len() - 1) as u8;
|
||||
for (slot, value) in p.iter_mut().zip(points) {
|
||||
*slot = p2(value);
|
||||
@@ -324,7 +325,7 @@ mod tests {
|
||||
for value in sources {
|
||||
assert_eq!(value, source(&load_source(value.clone(), 0).unwrap(), 0).unwrap());
|
||||
}
|
||||
assert!(load_segment(w::Segment::Bezier { points: vec![[0., 0.]; 9] }).is_err());
|
||||
assert!(load_segment(w::Segment::Bezier { points: vec![[0., 0.]; solidcraft_geom::MAX_BEZIER_CTRL + 1] }).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user