Repository navigation
Parametric: IGES export and import - #259
Merged
Merged
Conversation
Export writes every face as an exact trimmed NURBS surface (144/128) with each boundary in model space and in the surface's parameter space; assemblies become named, coloured groups. Import reads trimmed, bounded, analytic and untrimmed surfaces, B-rep solids and subfigures, hands the faces to the kernel's STEP reader, sews them into solids (inner shells become hollows) and recovers planes, cylinders, cones, spheres, tori, lines and arcs from B-splines. No change to the WebAssembly kernel. The STEP read/write helpers move to kernel/stepfile.ts and FeatureError to kernel/errors.ts so the IGES module can share them.
Shelling a smooth loft outwards leaves zero-area sliver faces where the rounds meet; an exported part carried them, and the importer read them back as stray surface bodies and specks of solid (with a 'does not close into a solid' warning) instead of one hollow solid.
Whether a closed shell lies inside another was decided by intersecting the two solids, and each hollow was cut out with a boolean. On spline surfaces each boolean took seconds (an outward-shelled loft took 7 s to import, almost all of it in two booleans) and the cut lost accuracy; a multi-body file with parts inside a larger body's box paid one boolean per part. Nesting is now decided from a few of the inner shell's vertices (a distance of zero to the outer solid), and a hollow is the outer shell with the inner one turned inwards, checked by volume, with the boolean kept as the fallback.
When the tenfold steps from the file's resolution ended exactly on the coarsest tolerance (0.1 mm, or 0.1% of a model whose size is a power of ten of the resolution), a model that stayed open was sewn at it a second time, which is the slowest step of reading a large open model.
…spheres A B-spline surface read as a plane, cylinder, cone, sphere or torus took the exact surface's axis from the order of a few sample points, so its normal could be the other way round from the B-spline's. Boundaries run counterclockwise about the file's surface, so the kernel then kept the rest of the surface instead of the face: harmless on open surfaces, but on a torus or sphere the rest is a valid face too. The swelling handle of a public sample hammer came in as two whole tori 270 m across (volume 1.2e16 mm3 instead of 2.06e11). Each recognised surface's normal is compared with the B-spline's, and a face on one turned the other way is written with its sense reversed (B-rep faces too).
…tive The check on a B-spline curve's weights could never be true (it ran only when the curve had no weights), and surfaces had none. A single curve or surface with a zero or negative weight wrote NaN into the converted model, and the whole file failed with 'The STEP file contains no geometry'. Such a face is now skipped and counted in the import warning, and the rest comes in.
…does Inserting an IGES file as an assembly component dropped the import's notes: a file whose surfaces do not close into a solid became a surface component with no word, while Open and Import warned. It also showed nothing while the file was read. The insert now shows 'Reading <file>...' and the same warning, from one shared message.
… part The fine tolerance came from the file's resolution (at least 0.1 micrometre, at most 0.01 mm) whatever the model's size, and the coarse one took the size as at least 1 mm. A part a fraction of a millimetre across lost faces: a public bearing sample (0.1 mm) came in with 211 of its 213 faces, and the same part exported and read again with 49, in 30 pieces, because its file's resolution (0.0009 mm) is close to the length of its smaller edges. Both tolerances are now at most 0.1% of the model's real size; parts of 10 mm and more are read as before.
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.
Adds IGES export and import to Parametric, in response to a user asking whether Parametric can write IGES.
No change to the geometry kernel's WebAssembly: the bundled OpenCascade build has no IGES translator, so the translator is written in TypeScript on top of the bindings already there. The download grows only by the new JavaScript.
Export (File › Export IGES…, parts and assemblies)
Import (Open, Import…, Insert Component, drag and drop:
.igs/.iges)Refactor
build.tstokernel/stepfile.ts, andFeatureErrormoved tokernel/errors.ts, so the IGES module can use them without a circular import.build.tsre-exports both, and STEP behaviour is unchanged.Testing
tests/iges.test.ts(24 tests) covers:Dexponents.tsc --noEmitand the full unit suite pass.Not included: writing B-rep solids (186) on export. Trimmed surfaces are what most CAD systems read and write by default.