mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-25 01:40:57 +00:00
Rib: accept a Project feature as its sketch ref
Rib guarded with `sk.type != CadFeatureType::Sketch`, while every other sketch consumer — Extrude, SurfaceExtrude, SurfaceRevolve, the loft paths — tests `!= Sketch && != Project`. A Project feature carries a plane and Line entities, which is all a rib reads, so the guard blocked "project a body edge, then rib along it" for no stated reason. The picker in the Design tab offered Sketch features only, so it is widened to match: a kernel that accepts Project refs and a GUI that never lists them would have left the path unreachable anyway. Worth recording for whoever hits this next: Rib also needs a sketch carrying EXPLICIT entities. A parametric Rectangle sketch (add_sketch with width/height) has an empty entities vector — build_sketch_wire synthesises its profile on demand — so rib_entity 0 is out of range there and it fails with "rib: bad entity". That is why Rib could not be driven headlessly at all before this change; a Project feature is now the one programmatic way to produce a ribbable line. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
1cb80f7f9f
commit
b25335e1b3
@@ -4048,6 +4048,30 @@ TEST_CASE("rib adds material to a box", "[CadDocument][rib]")
|
||||
REQUIRE_FALSE(bad.recompute());
|
||||
}
|
||||
|
||||
TEST_CASE("rib accepts a Project feature as its sketch ref", "[CadDocument][rib]")
|
||||
{
|
||||
// Project carries plane + Line entities, which is all a rib reads. Every other consumer
|
||||
// (Extrude, SurfaceExtrude, SurfaceRevolve) already accepts it; Rib used to reject it,
|
||||
// which made "project a body edge, then rib along it" unreachable.
|
||||
CadDocument doc;
|
||||
int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 40, 40, 10, "Box");
|
||||
doc.add_extrude(sk, 10.0, false, BooleanMode::New, "Extrude");
|
||||
REQUIRE(doc.recompute());
|
||||
double Vbox = double(doc.display_mesh.volume());
|
||||
|
||||
// Project the whole body onto XY: the 4 top and 4 bottom edges survive as Lines.
|
||||
int proj = doc.add_project_edges(0, {}, -1, SketchPlane::XY(), "Proj");
|
||||
REQUIRE(proj >= 0);
|
||||
REQUIRE(doc.recompute());
|
||||
REQUIRE(doc.features[proj].entities.size() == 8);
|
||||
|
||||
int fi = doc.add_rib(proj, 0, 3.0, 12.0, 0, "RibFromProjection");
|
||||
REQUIRE(fi >= 0);
|
||||
REQUIRE(doc.recompute());
|
||||
REQUIRE(doc.error.empty());
|
||||
REQUIRE(double(doc.display_mesh.volume()) > Vbox);
|
||||
}
|
||||
|
||||
TEST_CASE("rib non-line entity rejected safely", "[CadDocument][rib]")
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user