Skip to content

solidcore: a body written to .smb does not always read back the same (2 unreadable, small measure drift) #16922

Open

Description

@brett19

A B-rep written to .smb and read back is not always the same body. Found while checking #16737's moved goldens, which needed the exact bodies the goldens measure.

What was measured

Every body measured by blend.fillet_executive_p3 (mass record), boolean.api_brep and offset.offset_executive_p2 (brep_volume) was written as ASCII .smb, read back with read_brep_from_file, and measured again with the same call. The body was captured just before the measure.

  • Only 66 of 307 bodies read back to a bit-identical record. The rest agree to within 1e-12 of each component's scale, except the case below.
  • 2 bodies do not read back at all. BSplineCurve::read_from_db refuses a curve the writer wrote: InvalidInput { operation: "nurbs::b_spline_curve::p2::BSplineCurve::read_from_db", reason: "NURBS curve control point count is fewer than degree + 1" }. The files are:
    • boolean.api_brep/crossing_creases_union_d1e-05.volume.0.smb
    • boolean.api_brep/issue2177_crescent_on_top_of_rim_measured.volume.0.smb
  • blend.fillet_executive_p3 sweep5-letter_g-e1-r1.0: the read-back body's area is 859.165216536105, where the body that was written measures 859.1654034669216 (2.2e-7 relative). The mass record changes with it.

Observations (MEASURED, not yet a diagnosis):

  • The two unreadable files were written with the case's own kernel by the runner's hook. A Brep::clone_standing_for_self copy of the same body, written with a default Kernel, did read back. So the writer's output seems to depend on the kernel state or on something the copy drops.
  • In 60 fillet bodies and 27 boolean bodies, some edge uses have no UV trim when written, because the measure makes the trims. The reader checks trims rather than making them, which may account for the small differences.

Reproduce

--dump-smb comes from #16737 (branch volume-strips-16735). It writes <dir>/<unit>/<case>.<label>.<n>.smb for every body a runner measures, just before the measure.

cargo run --profile goldens -p goldens -- --unit boolean.api_brep --unit blend.fillet_executive_p3 --goldens --dump-smb /tmp/smb

Then read each file back as solidcore/tests/support/volume_leak.rs::read_smb does (read_brep_from_file, then refresh_cached_topology). The two files above fail. Measuring blend.fillet_executive_p3/sweep5-letter_g-e1-r1.0.mass.0.smb with brep_mass_properties(k, b, 1e-4, 1.0, Vec3::ZERO, ..) gives the area above, not the golden's 859.1654034669216. goldens/tests/issue_16735_golden_mass_moves.rs counts how many bodies round-trip bit-identically (smb_same / smb_differs / smb_unreadable in its summary).

Expected

A body written by write_brep_to_file reads back to a body that measures the same, and the reader accepts everything the writer writes.

Written by Claude Code (Anthropic) on behalf of @brett19.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageno priority yet; a maintainer sorts it with /triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions