Skip to content

Data Exchange, GLTF - fix saving edges when Merge Faces is enabled#554

Merged
dpasukhi merged 6 commits intoOpen-Cascade-SAS:IRfrom
Bananaz-ai:CR548
May 23, 2025
Merged

Data Exchange, GLTF - fix saving edges when Merge Faces is enabled#554
dpasukhi merged 6 commits intoOpen-Cascade-SAS:IRfrom
Bananaz-ai:CR548

Conversation

@elias-bananaz
Copy link
Copy Markdown
Contributor

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 Lines for LineStrip works 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.

Comment on lines -290 to -301
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:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@dpasukhi dpasukhi requested review from Copilot and mzernova May 21, 2025 07:58
@dpasukhi dpasukhi added 2. Bug Something isn't working 1. Data Exchange Import/Export or iterating of the CAD data labels May 21, 2025
@dpasukhi dpasukhi added this to the Release 8.0 milestone May 21, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

Comment thread src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafWriter.cxx
Comment thread src/DataExchange/TKDEGLTF/RWGltf/RWGltf_CafWriter.cxx
@github-project-automation github-project-automation bot moved this from Todo to Integration in Maintenance May 23, 2025
@dpasukhi dpasukhi linked an issue May 23, 2025 that may be closed by this pull request
@dpasukhi dpasukhi merged commit 4f2d4c1 into Open-Cascade-SAS:IR May 23, 2025
66 of 68 checks passed
@github-project-automation github-project-automation bot moved this from Integration to Done in Maintenance May 23, 2025
@elias-bananaz elias-bananaz deleted the CR548 branch May 25, 2025 07:40
elias-bananaz added a commit to Bananaz-ai/OCCT that referenced this pull request May 25, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1. Data Exchange Import/Export or iterating of the CAD data 2. Bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

GLTF Export - saving edges not working together with Merge Faces

3 participants