Skip to content

Share vertex entities between triangles so edge loops are topologically closed - #18

Merged
slugdev merged 2 commits into
masterfrom
copilot/slugdev-fix-kompas-reading-error
Aug 1, 2026
Merged

Share vertex entities between triangles so edge loops are topologically closed#18
slugdev merged 2 commits into
masterfrom
copilot/slugdev-fix-kompas-reading-error

Conversation

Copilot AI commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

STEP files produced from STL meshes are rejected by strict readers (KOMPAS: "Link list is empty OR contains more than 2 items / corrupt file structure").

build_tri_body shared EDGE_CURVE entities between neighbouring triangles via edge_map, but created three fresh VERTEX_POINT entities per triangle. When triangle B reused an edge curve created by triangle A, that edge's endpoints were A's vertices while B's remaining edges used B's own vertices — so the EDGE_LOOP only closed by coordinate, never by entity identity.

On the model attached to the issue (194,886 triangles): 152,171 of 194,859 loops were disconnected, and the file held 584,577 VERTEX_POINT entities for 97,443 distinct locations.

#26 = ORIENTED_EDGE('',*,*,#15,.T.);   /* #15 = EDGE_CURVE('', #6, #8, ...) - triangle A's vertices */
#27 = ORIENTED_EDGE('',*,*,#20,.T.);   /* #20 = EDGE_CURVE('', #17,#19,...) - #17 duplicates #8   */
#34 = EDGE_LOOP('', (#26,#27,#28));    /* #15 ends at #8, #20 starts at #17: chain is broken      */

Changes

  • StepKernel::build_tri_body: vertices are looked up in a coordinate-keyed std::map and reused, mirroring what build_tri_body_merged already does. Edges meeting at a point now reference one shared VERTEX_POINT.
  • test/check_vertex_sharing.cmake + vertex_sharing ctest: converts cube.stl without mergeplanar, asserts exactly 8 VERTEX_POINT entities, and walks every EDGE_LOOP checking end-vertex id == next start-vertex id.

After the change the issue's model yields 0 disconnected loops and 97,443 vertices (one per unique point); output size drops from 258 MB to 209 MB.

Not addressed

27 degenerate triangles in that model are still dropped, leaving 79 free edges. The shell is emitted as an OPEN_SHELL inside a SHELL_BASED_SURFACE_MODEL, so this remains schema-valid and is left as-is.

Copilot AI linked an issue Aug 1, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix issue with KOMPAS.exe reading step result error Share vertex entities between triangles so edge loops are topologically closed Aug 1, 2026
Copilot AI requested a review from slugdev August 1, 2026 17:07
@slugdev
slugdev marked this pull request as ready for review August 1, 2026 17:26
@slugdev
slugdev merged commit 43b8f16 into master Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KOMPAS.exe can not read step result

2 participants