ricosjp / truck

Truck is a Rust CAD Kernel.
Apache License 2.0
992 stars 53 forks source link

RSweep problem with pivot rotate line #52

Closed SalmanBruce closed 7 months ago

SalmanBruce commented 1 year ago

Here's the rsweep issuse case, this cylinder can't be tessellationed, because the pivot line is aligned with the rotation axis, and the center point is coincide,so the connect_wires method has wrong results.


    let v = builder::vertex(Point3::new(0.0, 0.0, 0.0));
    let e = builder::tsweep(&v, Vector3::unit_x());
    let f = builder::tsweep(&e, Vector3::unit_y());
    let cylinder = builder::rsweep(&f, Point3::origin(), Vector3::unit_y(), Rad(7.0));
    let json = serde_json::to_vec_pretty(&cylinder).unwrap();
    std::fs::write("cylinder.json", json).unwrap();

like this, one side face is not shown.

5eb70d1ccf7abd768830168a4c5879d a7d846811c853f639ac1d9cd49fd47f
ytanimura commented 7 months ago

I am very sorry for the delay in replying.

We have resolved this issue by improving the tessellation.

By the way, builder::rsweep does not simplify the topology even if the end point of the wire is on the rotation axis. Therefore, the code leaves an infinitesimal hole in the center of the cylinder. It is safer to use builder::cone.

let v = builder::vertex(Point3::new(0.0, 0.0, 0.0));
let e0 = builder::tsweep(&v, Vector3::unit_x());
let e1 = builder::tsweep(e0.back(), Vector3::unit_y());
let e2 = builder::tsweep(e1.back(), -Vector3::unit_x());
let w = Wire::from(vec![e0, e1, e2]);
let shell = builder::cone(&w, -Vector3::unit_y(), Rad(7.0));
let cylinder = Solid::new(vec![shell]);
let json = serde_json::to_vec_pretty(&cylinder).unwrap();
std::fs::write("cylinder.json", json).unwrap();