P026 — `LENGTH_UNIT(.MILLI., .METRE.)` context but `CARTESIAN_POINT` coordinates pre-scaled ×1000 (global OCCT unit setting contaminated across in-process clients)

§12.5 units / global state (process-level)

P1 — silent data loss

assembly

Sources

Sender

FreeCAD ↔ gmsh interop

Description

After gmsh's OCCT instance sets `Geometry.OCCTargetUnit=M`, subsequent FreeCAD STEP exports emit coordinates scaled ×1000 because the OCCT global unit setting was mutated. Common file signature: `GEOMETRIC_REPRESENTATION_CONTEXT` declares `LENGTH_UNIT(SI MILLI METRE)` but `CARTESIAN_POINT` coordinates carry values like 10000.0 where 10 mm was intended — coords scaled by 1000 ignoring the declared unit context. (Not a *file* defect — but a class of "files that came out wrong because of process state" that downstream consumers will see.)

Reproducer recipe

Process-state contamination scenario; not a file-content recipe directly.

Expected kernel behavior

Heal and accept: STEP export sets unit context per-call without inheriting global state; coerce the per-call context cleanly.

Notes

This entry documents a runtime / process-state interaction defect (gmsh's `Geometry.OCCTargetUnit` setting persists into FreeCAD's STEP export in the same Python process). It is intentionally NOT falsifiable from a single .stp file; the fixture P026.stp is illustrative only. To reproduce, run a Python session that imports both gmsh and FreeCAD/OCCT in sequence with the unit-setting middle step, then export STEP — the export will be 1000× scaled. CI validation marks this entry as PROCESS-STATE — out of scope for static-file oracles. Synonyms: "global OCCT unit setting persists across in-process clients", "unit context contaminated between concurrent calls", "process-wide unit state leaks between sessions", "MILLI/METRE context confused by prior call".

Expected validation

occt=shape(1)/shape(1) gmsh=shape(1) ifc=schema_n/a

Byte assertions

Tier-3 assertions

Live oracle output

No live oracle data — run _run_corpus to populate.

Fixture content

Show fixture bytes (with defect highlighting)
1ISO-10303-21;
2/* P026: GEOMETRIC_REPRESENTATION_CONTEXT declares LENGTH_UNIT(SI MILLI METRE) but CARTESIAN_POINT coordinates are pre-scaled x1000 (e.g. 10000.0 for 10 mm); process-state contamination: gmsh Geometry.OCCTargetUnit=M mutated global OCCT unit; subsequent FreeCAD STEP export inherited that global and scaled all coords x1000; kernel must coerce per-call context without inheriting global state; the defect entity is emitted but sits unreachable from the shape-rep root (product chain roots a GEOMETRIC_CURVE_SET stub), so OCC loads only a 1-vertex stub (shape(1)); byte-present but oracle-invisible to the load-time shape-count oracles */
3HEADER;
4FILE_DESCRIPTION(('P026'),'2;1');
5FILE_NAME('P026.stp','2026-06-17T00:00:00',(''),(''),'cad-research-suite','','');
6FILE_SCHEMA(('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF { 1 0 10303 442 1 1 4 }'));
7ENDSEC;
8DATA;
9#9000=APPLICATION_CONTEXT('mechanical design');
10#1=CARTESIAN_POINT('',(0.0,0.0,0.0));
11#2=GEOMETRIC_CURVE_SET('',(#1));
12#9050=PRODUCT_CONTEXT('',#9000,'mechanical');
13#9051=PRODUCT('P026','P026','',(#9050));
14#9052=PRODUCT_DEFINITION_FORMATION('','',#9051);
15#9053=PRODUCT_DEFINITION_CONTEXT('part definition',#9000,'design');
16#9054=PRODUCT_DEFINITION('','','',#9052,#9053);
17#9055=PRODUCT_DEFINITION_SHAPE('','','',#9054);
18#9056=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));
19#9057=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.));
20#9058=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT());
21#9059=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.0E-7),#9056,'distance_accuracy_value','');
22#9060=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#9059))GLOBAL_UNIT_ASSIGNED_CONTEXT((#9056,#9057,#9058))REPRESENTATION_CONTEXT('','3D'));
23#9061=MANIFOLD_SURFACE_SHAPE_REPRESENTATION('',(#2),#9060);
24#9062=SHAPE_DEFINITION_REPRESENTATION(#9055,#9061);
25#9063=CARTESIAN_POINT('scaled_p0',(0.0,0.0,0.0));
26#9064=CARTESIAN_POINT('scaled_p1',(10000.0,0.0,0.0));
27#9065=CARTESIAN_POINT('scaled_p2',(10000.0,10000.0,0.0));
28#9066=CARTESIAN_POINT('scaled_p3',(0.0,10000.0,0.0));
29#9067=VERTEX_POINT('sv0',#9063);
30#9068=VERTEX_POINT('sv1',#9064);
31#9069=VERTEX_POINT('sv2',#9065);
32#9070=VERTEX_POINT('sv3',#9066);
33#9071=DIRECTION('sd0',(1.0,0.0,0.0));
34#9072=VECTOR('',#9071,10000.0);
35#9073=LINE('sl0',#9063,#9072);
36#9074=EDGE_CURVE('se0',#9067,#9068,#9073,.T.);
37#9075=DIRECTION('sd1',(0.0,1.0,0.0));
38#9076=VECTOR('',#9075,10000.0);
39#9077=LINE('sl1',#9064,#9076);
40#9078=EDGE_CURVE('se1',#9068,#9069,#9077,.T.);
41#9079=GEOMETRIC_CURVE_SET('scaled_coords_defect',(#9074,#9078));
42#9080=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));
43#9081=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.));
44#9082=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT());
45#9083=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.0E-7),#9080,'distance_accuracy_value','');
46#9084=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#9083))GLOBAL_UNIT_ASSIGNED_CONTEXT((#9080,#9081,#9082))REPRESENTATION_CONTEXT('P026_unit_ctx','3D Millimetre context'));
47#9085=PRODUCT_CONTEXT('sub',#9000,'mechanical');
48#9086=PRODUCT('ScaledCoordComp','ScaledCoordComp','',(#9085));
49#9087=PRODUCT_DEFINITION_FORMATION('','',#9086);
50#9088=PRODUCT_DEFINITION('design','',#9087,#9053);
51#9089=NEXT_ASSEMBLY_USAGE_OCCURRENCE('1','scaled_coord_instance','',#9054,#9088,$);
52ENDSEC;
53END-ISO-10303-21;