Skip to content

Commit e23bf9f

Browse files
committed
more work on tests
1 parent 7dc00f2 commit e23bf9f

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/main.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ fn main() {
624624
);
625625
let _ = fs::write("stl/spur_cycloid.stl", spur_cycloid.to_stl_ascii("spur_cycloid"));
626626

627+
/*
627628
let helical = CSG::helical_involute_gear(
628629
2.0, // module
629630
20, // z
@@ -635,6 +636,50 @@ fn main() {
635636
None,
636637
);
637638
let _ = fs::write("stl/helical.stl", helical.to_stl_ascii("helical"));
639+
*/
640+
641+
// ---------------------------------------------------------------------
642+
// Bézier curve demo ----------------------------------------------------
643+
let bezier_ctrl = &[
644+
[0.0, 0.0], // P0
645+
[1.0, 2.0], // P1
646+
[3.0, 3.0], // P2
647+
[4.0, 0.0], // P3
648+
];
649+
let bezier_2d = CSG::bezier(bezier_ctrl, 128, None);
650+
let _ = fs::write(
651+
"stl/bezier_2d.stl",
652+
bezier_2d.to_stl_ascii("bezier_2d"),
653+
);
654+
655+
// give it a little “body” so we can see it in a solid viewer
656+
let bezier_3d = bezier_2d.extrude(0.25);
657+
let _ = fs::write(
658+
"stl/bezier_extruded.stl",
659+
bezier_3d.to_stl_ascii("bezier_extruded"),
660+
);
661+
662+
// ---------------------------------------------------------------------
663+
// B-spline demo --------------------------------------------------------
664+
let bspline_ctrl = &[
665+
[0.0, 0.0],
666+
[1.0, 2.5],
667+
[3.0, 3.0],
668+
[5.0, 0.0],
669+
[6.0, -1.5],
670+
];
671+
let bspline_2d = CSG::bspline(bspline_ctrl, /* degree p = */ 3, /* seg/span */ 32, None);
672+
let _ = fs::write(
673+
"stl/bspline_2d.stl",
674+
bspline_2d.to_stl_ascii("bspline_2d"),
675+
);
676+
677+
// a quick thickening just like the Bézier
678+
//let bspline_3d = bspline_2d.extrude(0.25);
679+
//let _ = fs::write(
680+
// "stl/bspline_extruded.stl",
681+
// bspline_3d.to_stl_ascii("bspline_extruded"),
682+
//);
638683

639684
// Done!
640685
println!("All scenes have been created and written to the 'stl' folder (where applicable).");

src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn test_degenerate_polygon_after_clipping() {
117117
];
118118

119119
let polygon: Polygon<()> = Polygon::new(vertices.clone(), None);
120-
let plane = Plane::from_normal(Vector3::new(0.0, 0.0, 0.0), 0.0);
120+
let plane = Plane::from_normal(Vector3::new(0.0, 0.0, 1.0), 0.0);
121121

122122
eprintln!("Original polygon: {:?}", polygon);
123123
eprintln!("Clipping plane: {:?}", plane);

0 commit comments

Comments
 (0)