Commit Graph

10 Commits

Author SHA1 Message Date
Ni Jingzhe 654a6d3e33 part: a Part holds exactly one solid (the constructor refuses several; make_part_rpart and Part lose bodies=)
DECISION: the product item `Part` is one solid again. The multi-body Part added on 2026-11-04
(b607c852, design-docs/multi-solid-design.md) is withdrawn. This commit is the C++ half; the Python
consumers, the editor and the docs follow in the later commits of this series, one decision each.

WHY - THE DISCUSSION THIS DECISION COMES FROM (owner and assistant, 2026-11-10)
1. Why a Part was ever allowed several solids (the owner's account). The editor must support several
   solids existing in one notebook with no assembly constraint between them: to pattern a tool and then
   cut, there is necessarily a moment where more than one tool and the body exist together. That is easy
   to understand and it is a real need. At the time the Part was the only product value a notebook could
   end in, so the Part was made to hold several named bodies.
2. Why it is the wrong place (the owner's judgement). It makes assembly hard. The whole design was made
   for a human-friendly editor and it led to a wrong decision: a multi-solid Part. The question put was:
   should we go back to "a Part has exactly one solid" and support the editor some other, better way?
3. The assistant's analysis, which the owner accepted. The solids side by side in the pattern-then-cut
   example are INTERMEDIATE VALUES OF A NOTEBOOK, not product items. A Part is a line of the bill of
   materials and the unit an Assembly places, mates and gives connectors to; "the working set of solids
   while modelling" and "the product" were two levels that got mixed. The editor's need is a PREVIEW /
   notebook-value need (show every open solid), and a deliverable that really is several solids is an
   Assembly of Parts. So: Part = one solid; the editor shows open solids as loose values (later commit).
4. Urgency. The owner asked for the audit and the change at once because the multi-body Part might be a
   malignant bug in the released 2.2.8; its GitHub release was deleted on 2026-11-10 while this was done.

WHAT THE AUDIT FOUND (checked on 2026-11-10 against the code and by running it)
- Connectors on a multi-body Part were refused outright (Part constructor, part.cpp), so no mate, no
  public connector and no ConnectorRef could ever reach one: it could join an assembly only as a rigid
  blob placed by its origin.
- explode_rassembly raised TypeError on any assembly that held one (ops_explode.cpp collect_box called
  Part::body(), which throws for a multi-body Part).
- The scene compiler scene/compiler.py read part.body in four places (compile_scene fails on a
  multi-body Part). Every consumer needed a second code path, and some were missed. Not yet checked:
  joint / constraint solving, interference and MJCF paths (they depend on connectors anyway).

ALTERNATIVE CONSIDERED AND REJECTED: keep multi-body Parts and finish stage 3 of the design (a
connector anchored by body_id + entity). It changes the part-definition contract, the interface and
binding hashes and the entity bindings, and it still leaves a concept that overlaps with Assembly (a
multi-body part is "an assembly without constraints").

WHAT THIS COMMIT DOES
- The invariant is enforced in the lowest layer so that every consumer can rely on it instead of each
  branching on `multi_body`: Part(std::vector<Body>) throws ValueError unless there is exactly one body,
  and the message says what to do (one Part per solid in an Assembly, or union / cut to one solid).
  Part::multi_body() is gone.
- Binding: make_part_rpart(part_id, body, name) and Part(part_id, body, ...) take one Solid, one Body, or
  a list of exactly one piece. `bodies=` is removed (TypeError: unexpected keyword); more than one piece
  is a ValueError with the same guidance. Part(body=Body) is how a body that carries a name / colour /
  opacity survives pickling and copying (it replaces Part(bodies=(Body,))).
- The make_part_rpart(vector<Body>) overload and the mapping / sequence parsing helpers are removed.

KEPT ON PURPOSE: Body (it carries the body's display name, colour and opacity), Part::bodies() (always
one element), body_ids(), get_body(), set_body_appearance_rpart: one-body Parts already use them and
removing them would only churn the one-body path, which did not break.

Verified with the native module directly: a Solid, a one-element list and a Body are accepted; `bodies=`,
two solids and Part(body=[a, b]) are refused with the guidance.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 03:48:34 +08:00
NiJingzhe 4ff66173c5 feat(product): set_body_appearance_rpart: a display colour, opacity and name per body
A Body carries an optional colour (RGB in [0, 1], typed simplecadapi.types.Color,
catalog kind 'color') and opacity. The material colour is the default; a body
colour overrides it for display only (mass never reads it). The op is recorded
(make_set_body_appearance_rpart) and replayed, pickles for the cell cache, and
reaches the live preview (node color/opacity), the legacy scene compiler
(base_color), the part definition (optional 'appearance' block in profiles 2
and 3; a definition without one keeps its bytes), the package scene (node
properties.color/opacity) and STEP (part colour, or a named and coloured XCAF
sub-shape per body). Material.color is typed Color too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 11:12:12 +08:00
NiJingzhe 37e6dd86fe merge research/multi-solid: a Part holds one Solid or several named bodies; a cut that splits a body gives its pieces
On top of the merge: the bindings it touched (cut_rsolid on_split, make_part_rpart body/bodies) take the typed signature
vocabulary; a kind = "part" notebook's implicit Part is made of all its open bodies (named by their variables, the pieces of a
split cut <name>_1..n) and is recorded in the definition (one result node, so its content hash is stable across cache hits);
product values are walked through their own children, not as plain dataclasses; the skill says how bodies and the implicit Part
work; the editor marks every body of the implicit Part as the product.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 05:39:13 +08:00
NiJingzhe 8ffc8c0d4d bindings: one vocabulary for signature types (Renamed<T, Tag>, AnyOf<Tag> and the meanings built from them); every operation's parameters are typed
The three branches had each grown a helper header (Typed/Shown, Renamed/Named, TypedObject/Choice/...); they are one
semantic_types.hpp now, with Length, Angle, Point3, Direction3, Vector3, Count, Choice and the plain-double/Vec3 variants as
names over the two tools. test_catalog now requires that no parameter of any operation reads "object". Stubs and API pages
regenerated. Full suite: 2494 passed, 63 skipped (the 7 collection errors are the untracked stale test files that predate
this work).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 05:20:44 +08:00
NiJingzhe cbebe6f74a catalog: product, assembly and std operations say what every parameter is
The product operators keep taking py::object (they check the type inside the operation), now as
Typed<Name> (typed_args.hpp), which accepts anything as before and prints the type in the signature:
Part, Assembly, Part | Assembly, Placement, ConnectorRef, ScalarLimit | None, str ids, Length
radii (phase_offset is a pitch-circle arc length), Angle drive angles, Point3 / Direction3 frames,
dict[str, Direction3] explode directions. The std factories wrap their double / int arguments as
Shown<T, Name> (converted exactly as T) to read Length, Angle, Count; fastener styles are Literal.
apply_tag_rselection (ShapeSelector | Sequence[AnyShape], Literal enums), load_brep_region (str |
os.PathLike), render_screenshot_rpath and the Python make_ball_bearing_rassembly are annotated with
simplecadapi.types.

catalog.classify: split unions before matching Literal/Sequence (a Literal-first union gave garbage
choices); new kinds path, scalar_limit, <kind>_map, joined union kinds (enum|numbers, query|shape);
str-enum defaults read as their value. SDK_DEFECTS 21-24.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 04:58:19 +08:00
NiJingzhe 9778a8e0a9 feat(product): owner decisions on multi-body parts
- A cut that splits the body is no longer refused: cut_rsolid(on_split="pieces")
  (the default) returns every piece as list[Solid] ordered by centroid, recorded as
  make_cut_rsolid_list with piece_order=centroid and replayed in that order;
  on_split="error" keeps the strict contract. One-piece cuts are unchanged.
- Pieces become bodies: make_part_rpart(body=pieces) -> body_1..n,
  bodies={"bar": pieces} -> bar_1..n.
- Overlapping bodies are allowed and warned: inspect_body_overlaps_rlist and a
  BodyOverlapWarning when the definition is built.
- Multi-body definitions use profile simplecad-part-definition-3 (new schema);
  profile 2 is back to its dev bytes, so profile-2 readers refuse them.
- part_from_bodies: the implicit-Part rule (all open bodies, named by variable).
- Skill pages, API docs, stubs, design doc section 9, SDK defect 24.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 04:46:26 +08:00
NiJingzhe b607c85248 feat(product): multi-body parts: a Part holds one Solid or several named bodies
Spike of design-docs/multi-solid-design.md. make_part_rpart(bodies={id: solid})
keeps several solids apart in one Part (not an assembly): Body values with
stable ids, Part.bodies / get_body / body_ids; Part.body raises on a multi-body
part instead of returning one body. Recorded and replayed, pickled for the cell
cache, previewed as one node per body (node/<part>/body:<id>), packaged with a
BRep and topology snapshot per body (solid_cache.bodies; one-body manifests are
byte-identical), drawn as solid child nodes in the package scene, exported to
STEP as one product holding every solid, flattened into assemblies, and weighed
per body by the new measure_part_mass_rmassreport.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 03:57:27 +08:00
NiJingzhe a4ddd705aa SDK: fillet_corner_rsketch, chamfer_corner_rsketch, project_rsketch and explode_rassembly
fillet_corner/chamfer_corner round or bevel the corner of two lines that share a point (tangent and radius/length constraints keep
it defined); project_rsketch brings geometry from another sketch or from the edges of a shape into a sketch as fixed construction
geometry, which is how sketches in different planes are related; explode_rassembly returns an assembly with the component
placements displaced for an exploded view (factor, centre or axis, per-component directions and weights). C++, bound,
recorded, replayable, stubbed, documented and tested like trim/extend.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 03:18:38 +08:00
NiJingzhe 7edd550f29 style: add .clang-format and format the C++ tree with it
One mechanical pass (clang-format 18.1.8, Google base, 120 columns, T& x, includes untouched). Nothing but whitespace and
line breaks moves; tools/check_format.sh lists what would change and CI runs it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 16:28:29 +08:00
NiJingzhe 8971279494 feat: the geometry engine is C++ on OpenCASCADE, one package, prebuilt wheels
The modeling API (shapes, operators, sketches, products, queries, the reactive graph) is implemented in
C++20 on OpenCASCADE (src/cpp) and ships inside the wheel as simplecadapi._cpp.  The Python layers that stay
Python (runtime, build, artifacts, editor, inspect, exporter, translators, scene) run on it unchanged; the
previous Python test suite passes on the new engine.

Layout: src/cpp and src/simplecadapi side by side, one distribution built by scikit-build-core.
simplecadapi.core, .operators.*, .ql, .std.* and the other legacy modules are real forwarding modules; the
Python adapter layer is simplecadapi/_glue.  OCP is no longer a dependency and nothing imports it.

Release: .github/workflows/release.yml builds wheels for Linux x86_64 and aarch64, macOS arm64 and Windows
x86_64 (Python 3.10-3.13) against one static OCCT, runs the test suite on the Linux wheels and publishes to
GitHub and PyPI; ci.yml caches the static OCCT for the test jobs.

Errors: every message the library writes is English; the tag-validation and semantic-query errors render in
full with possible causes and fixes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 02:55:35 +08:00