Data Exchange, GLTF - fix saving edges when Merge Faces is enabled#554
Data Exchange, GLTF - fix saving edges when Merge Faces is enabled#554dpasukhi merged 6 commits intoOpen-Cascade-SAS:IRfrom
Conversation
| switch (theGltfFace.Shape.ShapeType()) | ||
| TopAbs_ShapeEnum shapeType = getShapeType(theGltfFace.Shape); | ||
|
|
||
| switch (shapeType) | ||
| { | ||
| case TopAbs_COMPOUND: | ||
| case TopAbs_COMPSOLID: | ||
| case TopAbs_SOLID: | ||
| case TopAbs_SHELL: | ||
| case TopAbs_FACE: | ||
| return true; | ||
| case TopAbs_WIRE: | ||
| case TopAbs_EDGE: | ||
| case TopAbs_VERTEX: | ||
| default: |
There was a problem hiding this comment.
When checking the face in theGltfFace, we shouldn't expect anything other than Face, Edge, Vertex or Compound, since these are what the specific iterators (Face, Edge, Vertex) are extracting. And Compound is only added in the case of merged faces.
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue with GLTF exports when merge faces is enabled by ensuring that edge data is saved correctly using Lines instead of LineStrip. Key changes include adjusting primitive mode checks in triangulation and JSON parsing, introducing a virtual getShapeType function, and updating index calculations for edges and vertices.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| RWGltf_TriangulationReader.cxx | Removed check for LineStrip mode to force use of Lines for merged faces |
| RWGltf_GltfJsonParser.cxx | Updated primitive mode checks by removing LineStrip references |
| RWGltf_CafWriter.hxx / RWGltf_CafWriter.cxx | Added getShapeType to correctly determine the underlying shape type from compounds and updated index calculation logic |
…en-Cascade-SAS#554 Removed check for LineStrip mode to force use of Lines for merged faces Updated primitive mode checks by removing LineStrip references Added getShapeType to correctly determine the underlying shape type from compounds and updated index calculation logic
Description
When using
SetMergeFaces(true)with edges, the GLTF exported is invalid. The edges are not saved. Using Draco compression fails as well.The Problem
When a document is saved with merged faces, a Compound is created to group together the different faces. But when checking the type of the shape in several places, it's checked for either edge, vertex or defaults to face. That means that a compound of edges is also treated using the FaceIterator.
The Solution
Look at the underlying shape of a compound. The only possibilities should be: Vertex, Edge, Face, or a Compound that contains exclusively one kind of those.
Note
This PR undoes the change introduced in #535. While exchanging
LinesforLineStripworks for unmerged faces, where each edge is added individually, this breaks when using merge faces. Since all edges are now in the same mesh, they are all joined together, resulting in extra edges appearing between the actual edges.Instead, the approach proposed here is to return to using Lines, but use the indices the fix the gap problem.