forked from 1b-agent/opencadstudio-upstream
style: apply cargo fmt across workspace
This commit is contained in:
1 parent
85710e5454
commit
9cf9ff2c5c
531 files changed
+57740
-33906
No files matched your search
+37
-16
@@ -18,7 +18,10 @@ fn puck() -> kernel::brep::Body {
|
||||
));
|
||||
let body = presspull_model::extrusion_body(&entity, [0.0, 0.0, 10.0])
|
||||
.expect("a closed circular profile extrudes");
|
||||
assert!(body.validate().is_empty(), "extrusion produced a valid body");
|
||||
assert!(
|
||||
body.validate().is_empty(),
|
||||
"extrusion produced a valid body"
|
||||
);
|
||||
body
|
||||
}
|
||||
|
||||
@@ -29,10 +32,10 @@ fn puck() -> kernel::brep::Body {
|
||||
fn opposite_faces_report_opposite_outward_normals() {
|
||||
let body = puck();
|
||||
|
||||
let top = solid_model::nearest_planar_face(&body, [0.0, 0.0, 10.0])
|
||||
.expect("the top cap is planar");
|
||||
let bottom = solid_model::nearest_planar_face(&body, [0.0, 0.0, 0.0])
|
||||
.expect("the bottom cap is planar");
|
||||
let top =
|
||||
solid_model::nearest_planar_face(&body, [0.0, 0.0, 10.0]).expect("the top cap is planar");
|
||||
let bottom =
|
||||
solid_model::nearest_planar_face(&body, [0.0, 0.0, 0.0]).expect("the bottom cap is planar");
|
||||
assert_ne!(top, bottom, "the caps are distinct faces");
|
||||
|
||||
let top_normal = solid_model::planar_face_normal(&body, top).expect("top cap has a normal");
|
||||
@@ -81,18 +84,30 @@ fn the_curved_side_is_not_offered_as_a_plane() {
|
||||
|
||||
#[test]
|
||||
fn ucs_pick_command_enables_solid_face_picking() {
|
||||
use OpenCADStudio::command::{CadCommand, CmdResult, UcsPickCommand};
|
||||
use glam::DVec3;
|
||||
use OpenCADStudio::command::{CadCommand, CmdResult, UcsPickCommand};
|
||||
|
||||
let cmd_face = UcsPickCommand { face: true };
|
||||
assert!(cmd_face.needs_entity_pick(), "UCS FACE needs entity pick");
|
||||
assert!(cmd_face.entity_pick_includes_fills(), "UCS FACE must include fills to raycast solid faces");
|
||||
assert!(cmd_face.entity_pick_uses_surface_point(), "UCS FACE must use 3D surface point");
|
||||
assert!(cmd_face.entity_pick_highlights_hover(), "UCS FACE must highlight hovered solid face");
|
||||
assert!(
|
||||
cmd_face.entity_pick_includes_fills(),
|
||||
"UCS FACE must include fills to raycast solid faces"
|
||||
);
|
||||
assert!(
|
||||
cmd_face.entity_pick_uses_surface_point(),
|
||||
"UCS FACE must use 3D surface point"
|
||||
);
|
||||
assert!(
|
||||
cmd_face.entity_pick_highlights_hover(),
|
||||
"UCS FACE must highlight hovered solid face"
|
||||
);
|
||||
|
||||
let cmd_obj = UcsPickCommand { face: false };
|
||||
assert!(cmd_obj.needs_entity_pick());
|
||||
assert!(!cmd_obj.entity_pick_includes_fills(), "UCS OBJECT operates on curves, not fills");
|
||||
assert!(
|
||||
!cmd_obj.entity_pick_includes_fills(),
|
||||
"UCS OBJECT operates on curves, not fills"
|
||||
);
|
||||
assert!(!cmd_obj.entity_pick_uses_surface_point());
|
||||
|
||||
let handle = codec::Handle::new(0x2A);
|
||||
@@ -113,8 +128,8 @@ fn face_ucs_snaps_origin_and_aligns_axes_on_box() {
|
||||
|
||||
// Top face is at Z = +15, bounds X in [-5, 5], Y in [-10, 10].
|
||||
// Pick near corner (5, 10, 15), closer to the edge along -X than the edge along -Y.
|
||||
let face = solid_model::nearest_planar_face(&box_body, [3.0, 9.0, 15.0])
|
||||
.expect("top face found");
|
||||
let face =
|
||||
solid_model::nearest_planar_face(&box_body, [3.0, 9.0, 15.0]).expect("top face found");
|
||||
let ucs = solid_model::planar_face_ucs(&box_body, face, [3.0, 9.0, 15.0])
|
||||
.expect("planar_face_ucs constructed");
|
||||
|
||||
@@ -124,8 +139,11 @@ fn face_ucs_snaps_origin_and_aligns_axes_on_box() {
|
||||
assert!((ucs.origin.z - 15.0).abs() < 1e-6);
|
||||
|
||||
// Z axis must be outward normal (0, 0, 1).
|
||||
let z = glam::DVec3::new(ucs.x_axis.x, ucs.x_axis.y, ucs.x_axis.z)
|
||||
.cross(glam::DVec3::new(ucs.y_axis.x, ucs.y_axis.y, ucs.y_axis.z));
|
||||
let z = glam::DVec3::new(ucs.x_axis.x, ucs.x_axis.y, ucs.x_axis.z).cross(glam::DVec3::new(
|
||||
ucs.y_axis.x,
|
||||
ucs.y_axis.y,
|
||||
ucs.y_axis.z,
|
||||
));
|
||||
assert!((z.z - 1.0).abs() < 1e-6);
|
||||
|
||||
// Closer to edge along -X: X axis must point along (-1, 0, 0).
|
||||
@@ -165,8 +183,11 @@ fn face_ucs_on_puck() {
|
||||
let ucs = solid_model::planar_face_ucs(&body, top_face, [60.0, -25.0, 10.0]).unwrap();
|
||||
|
||||
// Normal Z = (0, 0, 1).
|
||||
let z = glam::DVec3::new(ucs.x_axis.x, ucs.x_axis.y, ucs.x_axis.z)
|
||||
.cross(glam::DVec3::new(ucs.y_axis.x, ucs.y_axis.y, ucs.y_axis.z));
|
||||
let z = glam::DVec3::new(ucs.x_axis.x, ucs.x_axis.y, ucs.x_axis.z).cross(glam::DVec3::new(
|
||||
ucs.y_axis.x,
|
||||
ucs.y_axis.y,
|
||||
ucs.y_axis.z,
|
||||
));
|
||||
assert!((z.z - 1.0).abs() < 1e-6);
|
||||
|
||||
// Orthonormality of X and Y.
|
||||
|
||||
Reference in new issue
Block a user