Repository navigation
Standard primitives: slot prism, rounded box, pipe segment, polysolid and three wires - #54
Merged
Merged
Conversation
The primitive module was at 589 of 600 lines and build_primitive at 77 of 80, with seven new kinds about to land from two lanes. Solid builders move to solids.rs, wire builders and their checks to a new wires.rs, the shared check_arc to sizes.rs, and the Primitive enum with its body_type to kind.rs so the children do not import their parent. build_primitive now picks build_solid or build_wire by body type, so new solid and wire arms land in different files. No behaviour change.
The documents said wedges and curves other than lines, circles and arcs have no replacement in 3.0. A wedge builds today as a five-face polyhedron or an extruded triangle, and the 2.0 Curve was a polyline through its control points, which OG_PRIMITIVE_POLYLINE makes. The elliptical arc has no replacement, and 3.0 has no spline, ellipse or elliptical arc; the text keeps saying so. The migration page gains a checked example for each replacement, the 2.5 guide moves Wedge and Curve to "Partly replaced", and the variable holding a cylinder sector is no longer called wedge.
Each kind extrudes an outline of lines and arcs with the arc-edged extrusion, standing on its plane like the cuboid (the pipe segment placed and angled like the cylinder sector). The outlines are pure functions so the wire kinds can reuse them. Bad sizes, a corner radius at or past half the width or depth, a sweep of zero or a full turn, and an inner radius at or past the outer one return InvalidParameter naming the value. The SDK gains the three kind constants, params helpers and types; the docs, examples, changelog and README list them; the golden file gains the three new builder keys only. A slot width too narrow for its end arcs is refused as a bad width too.
A polysolid is a wall of constant width and height along a path in the plane. The builder strokes the path with the mitred polyline offset and extrudes the single region it gives, with the hole of a closed loop. Justify left or right shifts the path by half the width first. Arc segments, short or zero-length legs, a crossing path and a stroke that is not one region are refused with InvalidParameter, so the stroke never drops points without telling the user. The SDK gets the kind constant, its params helper and type, with docs, an example page and changelog lines. Left and right justify bevel the shifted path at the stroke's mitre limit, so a sharp corner cannot push the wall past it. Path checks return InvalidParameter; errors from the stroke and the extrusion pass through as they are.
The regular polygon is a closed polyline of 3 to 1024 corners on a circle, the first on +u. The slot and rounded rectangle are closed profile wires built from the slot prism and rounded box outlines, so each extrudes into the matching solid. Bad sides, sizes and corner radii return InvalidParameter naming the value. The SDK gains the constants, helpers and types; the docs, an example page, the changelog and README list them; the golden file gains the three new wire keys only.
A polysolid path may now hold arc segments. Each joint that involves an arc must be tangent; a line that does not continue an arc, or an arc that does not continue the segment before it, is refused with InvalidParameter naming the joint. Paths with arcs are built from a direct offset outline: lines offset to parallel lines, arcs to concentric arcs, straight corners mitred or bevelled at the stroke's limit, then extruded with its hole for a closed path. The 2D curved union of the stroke cannot do this today. The path checks run in the builder, shared by both routes. A wall that overlaps itself, a leg folded back by its mitre and an offset radius at or below the tolerance are refused with InvalidParameter naming the segments. Straight paths keep the stroke route unchanged. The guide, the example page, the changelog and the README describe arc paths; the golden file gains two new keys only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the standard primitives that pass the full bar today: subtract, union and intersect with a box tool and a cylinder tool, shell, STEP export, valid and closed, exact volume. Each ships with its SDK constant, typed parameters, docs and an example page. All changes are additive; no existing kind, field, default or golden key changes.
Solids
OG_PRIMITIVE_SLOT_PRISM { length, width, height }: a stadium outline extruded along the normal.OG_PRIMITIVE_ROUNDED_BOX { width, height, depth, radius }: a cuboid with its four upright edges rounded.OG_PRIMITIVE_PIPE_SEGMENT { outerRadius, innerRadius, height, startAngle, sweepAngle }: a ring sector, placed and angled like the cylinder sector.OG_PRIMITIVE_POLYSOLID { path, width, height, justify? }: a wall of constant width and height along a path of straight legs and tangent arcs. Justify'centre','left'or'right'. Straight corners are mitred, bevelled above a mitre limit of 4. A closed path makes a ring wall.Wires
OG_PRIMITIVE_REGULAR_POLYGON { sides, radius }: 3 to 1024 corners on a circle, the first on +u.OG_PRIMITIVE_SLOT { length, width }andOG_PRIMITIVE_ROUNDED_RECTANGLE { width, breadth, radius }: the outlines of the slot prism and rounded box, so each extrudes into the matching solid.Bad values return
InvalidParameternaming the value. A polysolid joint where an arc meets a segment at an angle, a wall that overlaps itself, or a leg folded back by its mitre is refused and the message names the segments.Also in this PR
kind.rs,solids.rs,wires.rs,sizes.rs) so new solid and wire kinds land in separate files. No behaviour change.Curve(a polyline wire through its points).Commits
One commit per change, in merge order:
Verification
npm run checkgreen after every commit;npm run check:full(with both browser suites) green after commits 3 to 6.shapes/slot-prism,rounded-box,pipe-segment,polysolid,wire-kinds) and the docs pages load in a browser with no console errors.Known limit
The straight-leg polysolid keeps collinear split faces from the stroke (the L wall has 10 faces rather than 8). Merging them would move golden values, so it is left for a follow-up.