Skip to content
Engineering File Tools

Calculation Methodology, Tolerances and Testing

Published November 30, 2026Last reviewed November 30, 20266 min read
Verified against:cad-core-ts v0.1.0ezdxf 1.4.5occt-import-js 0.0.23

Engineering File Tools runs two deterministic analysis engines—cad-core-ts in the browser and cad-worker-py on the batch server—under a single shared output contract (version 0.1.0). Rather than treating geometry metrics as a black box, this page documents every formula, deflection setting, graph rule, and measured benchmark so mechanical engineers, estimators, and buyers know exactly what was computed before quoting or cutting parts.

1. DXF Path Length & Transform Rules

All DXF calculations operate strictly on Model Space. Paper Space entities (group code 67 = 1 or *Paper_Space* blocks) are ignored and flagged with paper_space_ignored. Text (TEXT, MTEXT, DIMENSION, ACAD_TABLE) and non-path entities (HATCH, 3DFACE, MESH, SOLID, 3DSOLID) are excluded from path lengths and reported separately.

Exact Geometric Primitives

EntityFormula / MethodError Bound
LINEEuclidean distance √(Δx² + Δy²)Exact (IEEE 754 float64)
CIRCLECircumference 2πrExact
ARCCircular arc length `r ·Δθ
LWPOLYLINE / POLYLINE bulgeChord c = ‖P2 − P1‖, sweep `θ = 4 · atan(b

Numerical Integration (ELLIPSE, SPLINE, Non-Uniform INSERT)

  • ELLIPSE: Arc length ∫ √((a · sin t)² + (b · cos t)²) dt from t₁ to t₂ is integrated via adaptive Gauss-Legendre / Simpson quadrature to relative error < 10⁻⁷.
  • SPLINE: Evaluated from knots, control points, and rational weights (De Boor / NURBS derivative) and integrated numerically. If only fit points exist, a cubic spline without end tangents is interpolated and flagged with spline_approximated.
  • INSERT & MINSERT: Expanded recursively up to depth 16 applying translation, rotation, uniform/non-uniform scaling (including negative scale mirroring), and MINSERT row/column grids. Entities on block layer 0 inherit the INSERT layer per DXF rules. When an INSERT applies non-uniform scaling (|sx| ≠ |sy|) to a CIRCLE or ARC, it becomes an elliptical arc and is integrated numerically (non_uniform_scale warning).

Units Policy

If $INSUNITS is 1 (in), 2 (ft), 4 (mm), 5 (cm), or 6 (m), results use that unit. If $INSUNITS is missing or 0 (unitless), we never silently assume millimetres: the UI flags unknown_units, withholds a pass verdict, and prompts you to select the true drawing unit.

2. Open Contour & Duplicate Detection

Endpoint Graph & Clustering

  1. Path endpoints from the selected cutting layers are indexed into a spatial grid at cell size tolerance (default 0.01 drawing units).
  2. Closed primitives (CIRCLE, closed LWPOLYLINE/POLYLINE, full ELLIPSE, closed SPLINE) are counted directly as closed contours.
  3. Connected components of open segments are classified by node degree:
    • All nodes degree 2 → closed contour (multi-entity loops such as 4 LINEs or slot LINE+ARCs are recognised as closed).
    • Any node degree 1 → open contour, emitting open_endpoint. If another degree 1 endpoint lies within 10 × tolerance, a gap issue with the measured distance is reported.
    • Any node degree ≥ 3 → needs review (branch issue).

Exact & Near Duplicates

Each segment/polyline is canonicalised (ignoring reversal on LINE and reversing/rotating vertex rings on LWPOLYLINE) and bucketed in a spatial hash:

  • Exact: identical geometry within 10⁻⁹ relative tolerance.
  • Near: identical topology within user tolerance.
  • Not checked: Partial collinear overlaps (e.g., a 20 mm line resting on top of a 100 mm line), mid-span T-junctions, and crossing contours.

3. STEP Tessellation & STL Export

STEP (.step/.stp, ISO 10303-21) files are parsed and tessellated in-browser by OpenCascade via occt-import-js (0.0.23, LGPL-2.1). OCCT converts the file's SI_UNIT or CONVERSION_BASED_UNIT to millimetres on import (linearUnit: "millimeter").

Quality PresetDeflection TypeLinear Deflection RatioAngular Deflection
lowbounding_box_ratio0.0040.5 rad
standardbounding_box_ratio0.0010.3 rad
highbounding_box_ratio0.00020.1 rad

Because curved B-Rep surfaces are approximated by flat triangles, the bounding box displayed in the STEP Viewer is always approximate (mesh-derived) and never claimed as exact B-Rep metrology. STL export verifies triangle counts and bounding boxes before and after writing the binary (84 + 50 × n bytes) or ASCII payload.

4. Measured Benchmark & Corpus Verification

Every engine release is verified against deterministic analytic baselines and public real-world CAD corpora rather than toy smoke checks:

STEP Mesh Accuracy vs. Exact CAD Primitives (occt-import-js 0.0.23)

Synthetic CAD ModelPresetTrianglesVolume ErrorMax BBox Shortfall
cube_10mm, box_100x50x20 (mm / inch / AP203 / AP242)low / standard / high120.0000%0.0000 mm
cylinder_r10_h30standard260-0.1510%0.0113 mm
cylinder_r10_h30high580-0.0309%0.0023 mm
sphere_r25standard5,008-0.288%0.024 mm
plate_100x60x10_two_holes_d10high1,028+0.001%0.0000 mm
assembly_two_partshigh512-0.0068%0.0016 mm

Real-World & Adversarial Corpus Runs

  • STEP Real Corpus (113 public AP203/AP214/AP242 files): 112 parsed cleanly, 101 produced meshes, 1 zero-byte file returned invalid_file, 11 external-reference assembly roots returned empty_result, 0 crashes.
  • STEP Robustness Stress Test (266 malformed/adversarial files): 0 crashes or hangs; malformed inputs fail cleanly with typed error codes.
  • DXF Golden & Real-World Corpus: 49 analytic golden scenarios (147/147 TypeScript checks and 49/49 Python checks passing) plus 1,528 public DXF files (ezdxf, dxf-parser, LibreCAD) parsed in ~3.1 s with cross-engine TS-vs-Python parity verified under a < 2% discrepancy threshold.
  • Batch Server Throughput: 25 DXF files preflighted end-to-end into PDF, XLSX, CSV, and JSON in 4.78 s (191 ms/file, 51.8 MB peak child RSS).

5. Changelog

  • 2026-11-30 (0.1.0): Initial release of cad-core-ts and cad-worker-py, STEP Viewer, STEP to STL, DXF Viewer, Cutting Length, Open Contour, Duplicate Checker, and DXF Batch Preflight Report.