Skip to content

Add MeshSave::toPly overloads for TriMesh#6426

Merged
Fedr merged 1 commit into
masterfrom
trimesh-toply
Jul 16, 2026
Merged

Add MeshSave::toPly overloads for TriMesh#6426
Fedr merged 1 commit into
masterfrom
trimesh-toply

Conversation

@Fedr

@Fedr Fedr commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Adds two new functions for saving TriMesh in .ply format:

MRMESH_API Expected<void> toPly( const TriMesh & mesh, const std::filesystem::path& file, const SaveSettings & settings = {} );
MRMESH_API Expected<void> toPly( const TriMesh & mesh, std::ostream & out, const SaveSettings & settings = {} );

To avoid copy-paste and any conversion between Mesh and TriMesh, the existing toPly implementation is turned into the toPlyImpl function template, and the differences between the two representations are factored into small accessor helpers (getVertRenumber, lastValidVert, hasVert, lastValidFace, numValidFaces, hasFace, getTriVerts). All vertices and triangles of TriMesh are considered valid, so vertex renumbering for it is identity, and SaveSettings::onlyValidPoints / SaveSettings::packPrimitives have no effect on it.

The saved bytes for Mesh are exactly the same as before (only mesh.topology.getTriVerts( f, vs ) call was replaced with the equivalent by-value overload).

New unit test MRMesh.TriMeshSavePly verifies that saving a TriMesh produces byte-identical .ply output to saving the equivalent Mesh, and that the output loads back correctly.

Local verification: MRTest Release x64 — all 306 tests pass.

🤖 Generated with Claude Code

Implement saving of TriMesh in .ply format (both file and stream
variants) sharing the code with Mesh saving via toPlyImpl function
template and small accessor helpers, without converting one mesh
representation into the other.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Fedr
Fedr merged commit f0619bc into master Jul 16, 2026
48 checks passed
@Fedr
Fedr deleted the trimesh-toply branch July 16, 2026 09:25
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.

2 participants