Skip to content

vtkSTLWriter fixes - #3754

Merged
finetjul merged 4 commits into
Kitware:masterfrom
daker:stlwriter-fixes
Nov 9, 2026
Merged

finetjul merged 4 commits into
Kitware:masterfrom
daker:stlwriter-fixes

Conversation

@daker

@daker daker commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Context

Fixes #3711
Fixes #3712
Fixes #3713

Results

Changes

PR Checklist

  • GitHub Actions CI passed: semantic-release commit messages, lint, and tests
  • Test coverage added
  • Documentation and TypeScript definitions are updated to match these changes

daker added 2 commits November 6, 2026 17:46
The writer read the point count of a cell, then read exactly three
point ids. For a quad, the writer read the fourth point id as the point
count of the next cell. Thus all the subsequent facets were incorrect,
and the writer could throw an error.

The writer now reads all the point ids of each cell. It splits each
polygon into a triangle fan from its first point.

Fixes Kitware#3713
The writer calculated the binary file size with 50 * polys.length / 4.
This value is correct only when all the cells are triangles. For quads
or larger polygons, the size was a fraction and it was incorrect.

The writer now counts the triangles that it writes, and uses this count
for the buffer size.

Fixes Kitware#3711
The writer wrote polyData.getNumberOfCells() as the facet count. This
value counts all the cell types, also the vertices, lines and strips
that the writer does not write. Thus the count in the header did not
agree with the file body.

The writer now writes the number of triangles that it writes.

Fixes Kitware#3712

@finetjul finetjul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread Sources/IO/Geometry/STLWriter/index.js Resolved
getPoint writes into an output array. The loop makes v1, v2 and v3
one time and does not make new arrays for each triangle.

In a triangle fan, the third point of one triangle is the second
point of the next triangle. The loop swaps v2 and v3, and reads and
transforms one new point for each triangle.
@finetjul
finetjul added this pull request to the merge queue Nov 9, 2026
Merged via the queue into Kitware:master with commit e0dcb50 Nov 9, 2026
4 checks passed
@daker
daker deleted the stlwriter-fixes branch November 9, 2026 14:05
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 38.0.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions Bot added the released Automated label label Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Automated label

Projects

None yet

2 participants