Open Cascade has glTF writer in their current development branch - RWGltf_CafWriter
I am trying to convert STP to glTF using it and got starting point from this question - Any Open source Libraries to Convert STEP files to glTF file format?
It looks doable, but I am new to Open Cascade technology and have few questions
While calculating triangulation for shapes using BRepMesh_IncrementalMesh, it needs line deflection and angle deflection, what are these and what should be its values?
RWGltf_CafWriter requires TDocStd_Document and TDF_LabelSequence, how do we get these from Shapes?
Thank You
Deflection parameters define the mesh quality. Within specific domain / algorithm, you should probably know in advance applicable deviation of your geometry (like no more than 1 mm). However, in context of visualization and arbitrary CAD model, linear deflection is usually defined relatively to the bounding box of the document.
TDocStd_Document
is an XDE document supported by various file format translators - including STEP and glTF. If at that point you have a singleTopoDS_Shape
from STEP file, then you probably used a simplified STEP translatorSTEPControl_Reader
. To preserve the structure of original document, it is better usingSTEPCAFControl_Reader
filling in an XDE document.Within XDE document, shapes (and not only shapes) are stored as Labels, so that
TDF_LabelSequence
collection is used to pass through the information like a sequence of root shapes (model tree roots in the document), which are called Free Shapes:In Draw Harness the conversion may look like this (the source code of commands can be used as a helpful reference of working code using related OCCT algorithms):