OCCT 8.0.1
OCCT documentation

Search guides and API reference

Enter at least two characters.

    Open CASCADE Technology Reference Manual 8.0.1
    RWGltf_CafWriter Class Reference

    glTF writer context from XCAF document. More...

    #include <RWGltf_CafWriter.hxx>

    Inheritance diagram for RWGltf_CafWriter:

    Data Structures

    struct  Mesh
     Mesh. More...
    struct  RWGltf_StyledShape
     Shape + Style pair. More...
    struct  Hasher

    Public Member Functions

     RWGltf_CafWriter (const TCollection_AsciiString &theFile, bool theIsBinary)
     Main constructor.
     ~RWGltf_CafWriter () override
     Destructor.
    const RWMesh_CoordinateSystemConverterCoordinateSystemConverter () const
     Return transformation from OCCT to glTF coordinate system.
    RWMesh_CoordinateSystemConverterChangeCoordinateSystemConverter ()
     Return transformation from OCCT to glTF coordinate system.
    void SetCoordinateSystemConverter (const RWMesh_CoordinateSystemConverter &theConverter)
     Set transformation from OCCT to glTF coordinate system.
    bool IsBinary () const
     Return flag to write into binary glTF format (.glb), specified within class constructor.
    RWGltf_WriterTrsfFormat TransformationFormat () const
     Return preferred transformation format for writing into glTF file; RWGltf_WriterTrsfFormat_Compact by default.
    void SetTransformationFormat (RWGltf_WriterTrsfFormat theFormat)
     Set preferred transformation format for writing into glTF file.
    RWMesh_NameFormat NodeNameFormat () const
     Return name format for exporting Nodes; RWMesh_NameFormat_InstanceOrProduct by default.
    void SetNodeNameFormat (RWMesh_NameFormat theFormat)
     Set name format for exporting Nodes.
    RWMesh_NameFormat MeshNameFormat () const
     Return name format for exporting Meshes; RWMesh_NameFormat_Product by default.
    void SetMeshNameFormat (RWMesh_NameFormat theFormat)
     Set name format for exporting Meshes.
    bool IsForcedUVExport () const
     Return TRUE to export UV coordinates even if there are no mapped texture; FALSE by default.
    void SetForcedUVExport (bool theToForce)
     Set flag to export UV coordinates even if there are no mapped texture; FALSE by default.
    const XCAFPrs_StyleDefaultStyle () const
     Return default material definition to be used for nodes with only color defined.
    void SetDefaultStyle (const XCAFPrs_Style &theStyle)
     Set default material definition to be used for nodes with only color defined.
    bool ToEmbedTexturesInGlb ()
     Return flag to write image textures into GLB file (binary gltf export); TRUE by default. When set to FALSE, texture images will be written as separate files. Has no effect on writing into non-binary format.
    void SetToEmbedTexturesInGlb (bool theToEmbedTexturesInGlb)
     Set flag to write image textures into GLB file (binary gltf export).
    bool ToMergeFaces () const
     Return flag to merge faces within a single part; FALSE by default.
    void SetMergeFaces (bool theToMerge)
     Set flag to merge faces within a single part. May reduce JSON size thanks to smaller number of primitive arrays.
    bool ToSplitIndices16 () const
     Return flag to prefer keeping 16-bit indexes while merging face; FALSE by default.
    void SetSplitIndices16 (bool theToSplit)
     Set flag to prefer keeping 16-bit indexes while merging face. Has effect only with ToMergeFaces() option turned ON. May reduce binary data size thanks to smaller triangle indexes.
    bool ToParallel () const
     Return TRUE if multithreaded optimizations are allowed; FALSE by default.
    void SetParallel (bool theToParallel)
     Setup multithreaded execution.
    const RWGltf_DracoParametersCompressionParameters () const
     Return Draco parameters.
    void SetCompressionParameters (const RWGltf_DracoParameters &theDracoParameters)
     Set Draco parameters.
    virtual bool Perform (const occ::handle< TDocStd_Document > &theDocument, const NCollection_Sequence< TDF_Label > &theRootLabels, const NCollection_Map< TCollection_AsciiString > *theLabelFilter, const NCollection_IndexedDataMap< TCollection_AsciiString, TCollection_AsciiString > &theFileInfo, const Message_ProgressRange &theProgress)
     Write glTF file and associated binary file. Triangulation data should be precomputed within shapes!
    virtual bool Perform (const occ::handle< TDocStd_Document > &theDocument, const NCollection_IndexedDataMap< TCollection_AsciiString, TCollection_AsciiString > &theFileInfo, const Message_ProgressRange &theProgress)
     Write glTF file and associated binary file. Triangulation data should be precomputed within shapes!
    Public Member Functions inherited from Standard_Transient
     Standard_Transient ()
     Empty constructor.
     Standard_Transient (const Standard_Transient &)
     Copy constructor – does nothing.
    Standard_Transientoperator= (const Standard_Transient &)
     Assignment operator, needed to avoid copying reference counter.
    virtual ~Standard_Transient ()=default
     Destructor must be virtual.
    virtual const opencascade::handle< Standard_Type > & DynamicType () const
     Returns a type descriptor about this object.
    bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
     Returns a true value if this is an instance of Type.
    bool IsInstance (const char *const theTypeName) const
     Returns a true value if this is an instance of TypeName.
    bool IsKind (const opencascade::handle< Standard_Type > &theType) const
     Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
    bool IsKind (const char *const theTypeName) const
     Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
    Standard_TransientThis () const
     Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero.
    int GetRefCount () const noexcept
     Get the reference counter of this object.
    void IncrementRefCounter () noexcept
     Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
    int DecrementRefCounter () noexcept
     Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
    virtual void Delete () const
     Memory deallocator for transient classes.

    Protected Types

    typedef NCollection_IndexedDataMap< RWGltf_StyledShape, occ::handle< NCollection_Shared< NCollection_List< occ::handle< RWGltf_GltfFace > > > >, HasherShapeToGltfFaceMap

    Protected Member Functions

    virtual bool writeBinData (const occ::handle< TDocStd_Document > &theDocument, const NCollection_Sequence< TDF_Label > &theRootLabels, const NCollection_Map< TCollection_AsciiString > *theLabelFilter, const Message_ProgressRange &theProgress)
     Write binary data file with triangulation data. Triangulation data should be precomputed within shapes!
    virtual bool writeJson (const occ::handle< TDocStd_Document > &theDocument, const NCollection_Sequence< TDF_Label > &theRootLabels, const NCollection_Map< TCollection_AsciiString > *theLabelFilter, const NCollection_IndexedDataMap< TCollection_AsciiString, TCollection_AsciiString > &theFileInfo, const Message_ProgressRange &theProgress)
     Write JSON file with glTF structure (should be called after writeBinData()).
    virtual TopAbs_ShapeEnum getShapeType (const TopoDS_Shape &theShape) const
     Returns the underlying shape in case of a compound.
    virtual bool toSkipShape (const RWMesh_ShapeIterator &theShapeIter) const
     Return TRUE if face shape should be skipped (e.g. because it is invalid or empty).
    virtual bool hasTriangulation (const RWGltf_GltfFace &theShape) const
     Return TRUE if shape has triangulation (not vertex or edge).
    virtual TCollection_AsciiString formatName (RWMesh_NameFormat theFormat, const TDF_Label &theLabel, const TDF_Label &theRefLabel) const
     Generate name for specified labels.
    virtual void saveNodes (RWGltf_GltfFace &theGltfFace, std::ostream &theBinFile, const RWMesh_ShapeIterator &theShapeIter, int &theAccessorNb, const std::shared_ptr< RWGltf_CafWriter::Mesh > &theMesh) const
     Write mesh nodes into binary file.
    virtual void saveNormals (RWGltf_GltfFace &theGltfFace, std::ostream &theBinFile, const RWMesh_FaceIterator &theFaceIter, int &theAccessorNb, const std::shared_ptr< RWGltf_CafWriter::Mesh > &theMesh) const
     Write mesh normals into binary file.
    virtual void saveTextCoords (RWGltf_GltfFace &theGltfFace, std::ostream &theBinFile, const RWMesh_FaceIterator &theFaceIter, int &theAccessorNb, const std::shared_ptr< RWGltf_CafWriter::Mesh > &theMesh) const
     Write mesh texture UV coordinates into binary file.
    virtual void saveIndices (RWGltf_GltfFace &theGltfFace, std::ostream &theBinFile, const RWMesh_ShapeIterator &theShapeIter, int &theAccessorNb, const std::shared_ptr< RWGltf_CafWriter::Mesh > &theMesh)
     Write mesh indexes into binary file.
    virtual void saveTriangleIndices (RWGltf_GltfFace &theGltfFace, std::ostream &theBinFile, const RWMesh_FaceIterator &theFaceIter, const std::shared_ptr< RWGltf_CafWriter::Mesh > &theMesh)
     Write triangle indexes into binary file.
    virtual void saveEdgeIndices (RWGltf_GltfFace &theGltfFace, std::ostream &theBinFile, const RWMesh_EdgeIterator &theEdgeIter)
     Write edge indexes into binary file.
    virtual void saveVertexIndices (RWGltf_GltfFace &theGltfFace, std::ostream &theBinFile, const RWMesh_VertexIterator &theVertexIter)
     Write vertex indexes into binary file.
    virtual void writePositions (const RWGltf_GltfFace &theGltfFace)
     Write bufferView for vertex positions within RWGltf_GltfRootElement_Accessors section.
    virtual void writeNormals (const RWGltf_GltfFace &theGltfFace)
     Write bufferView for vertex normals within RWGltf_GltfRootElement_Accessors section.
    virtual void writeTextCoords (const RWGltf_GltfFace &theGltfFace)
     Write bufferView for vertex texture coordinates within RWGltf_GltfRootElement_Accessors section.
    virtual void writeIndices (const RWGltf_GltfFace &theGltfFace)
     Write bufferView for triangle indexes within RWGltf_GltfRootElement_Accessors section.
    virtual void writeAccessors (const RWGltf_GltfSceneNodeMap &theSceneNodeMap)
     Write RWGltf_GltfRootElement_Accessors section.
    virtual void writeAnimations ()
     Write RWGltf_GltfRootElement_Animations section (reserved).
    virtual void writeAsset (const NCollection_IndexedDataMap< TCollection_AsciiString, TCollection_AsciiString > &theFileInfo)
     Write RWGltf_GltfRootElement_Asset section.
    virtual void writeBufferViews (const int theBinDataBufferId)
     Write RWGltf_GltfRootElement_BufferViews section.
    virtual void writeBuffers ()
     Write RWGltf_GltfRootElement_Buffers section.
    virtual void writeExtensions ()
     Write RWGltf_GltfRootElement_ExtensionsUsed/RWGltf_GltfRootElement_ExtensionsRequired sections (reserved).
    virtual void writeImages (const RWGltf_GltfSceneNodeMap &theSceneNodeMap)
     Write RWGltf_GltfRootElement_Images section.
    virtual void writeMaterials (const RWGltf_GltfSceneNodeMap &theSceneNodeMap)
     Write RWGltf_GltfRootElement_Materials section.
    virtual void writeMaterial (RWMesh_ShapeIterator &theShapeIter, bool &theIsStarted)
     Write RWGltf_GltfRootElement_Materials section.
    virtual void writeMeshes (const RWGltf_GltfSceneNodeMap &theSceneNodeMap)
     Write RWGltf_GltfRootElement_Meshes section.
    virtual void writePrimArray (const RWGltf_GltfFace &theGltfFace, const TCollection_AsciiString &theName, const int theDracoBufInd, bool &theToStartPrims)
     Write a primitive array to RWGltf_GltfRootElement_Meshes section.
    virtual void writeNodes (const occ::handle< TDocStd_Document > &theDocument, const NCollection_Sequence< TDF_Label > &theRootLabels, const NCollection_Map< TCollection_AsciiString > *theLabelFilter, const RWGltf_GltfSceneNodeMap &theSceneNodeMap, NCollection_Sequence< int > &theSceneRootNodeInds)
     Write RWGltf_GltfRootElement_Nodes section.
    virtual void writeSamplers ()
     Write RWGltf_GltfRootElement_Samplers section.
    virtual void writeScene (const int theDefSceneId)
     Write RWGltf_GltfRootElement_Scene section.
    virtual void writeScenes (const NCollection_Sequence< int > &theSceneRootNodeInds)
     Write RWGltf_GltfRootElement_Scenes section.
    virtual void writeSkins ()
     Write RWGltf_GltfRootElement_Skins section (reserved).
    virtual void writeTextures (const RWGltf_GltfSceneNodeMap &theSceneNodeMap)
     Write RWGltf_GltfRootElement_Textures section.
    virtual void writeExtrasAttributes (const occ::handle< TDataStd_NamedData > &theNamedData)
     Write nodes.extras section with key-value attributes.
    virtual void dispatchShapes (const XCAFPrs_DocumentNode &theDocNode, const Message_ProgressScope &thePSentryBin, NCollection_DataMap< XCAFPrs_Style, occ::handle< RWGltf_GltfFace > > &theMergedFaces, RWMesh_ShapeIterator &theShapeIter)
     Dispatch shapes.
    bool writeShapesToBin (RWGltf_GltfFace &theGltfFace, std::ostream &theBinFile, RWMesh_ShapeIterator &theShapeIter, int &theAccessorNb, const std::shared_ptr< RWGltf_CafWriter::Mesh > &theMesh, const RWGltf_GltfArrayType theArrType, const Message_ProgressScope &thePSentryBin)
     Write shape into binary file.
    virtual void writeShapes (RWMesh_ShapeIterator &theShapeIter, int &theDracoBufInd, bool &theToStartPrims, const TCollection_AsciiString &theNodeName, NCollection_Map< occ::handle< NCollection_Shared< NCollection_List< occ::handle< RWGltf_GltfFace > > > > > &theWrittenShapes, NCollection_IndexedDataMap< int, int > &theDracoBufIndMap)
     Write shapes to RWGltf_GltfRootElement_Meshes section.

    Protected Attributes

    TCollection_AsciiString myFile
     output glTF file
    TCollection_AsciiString myBinFileNameFull
     output file with binary data (full path)
    TCollection_AsciiString myBinFileNameShort
     output file with binary data (short path)
    RWGltf_WriterTrsfFormat myTrsfFormat
     transformation format to write into glTF file
    RWMesh_NameFormat myNodeNameFormat
     name format for exporting Nodes
    RWMesh_NameFormat myMeshNameFormat
     name format for exporting Meshes
    bool myIsBinary
     flag to write into binary glTF format (.glb)
    bool myIsForcedUVExport
     export UV coordinates even if there are no mapped texture
    bool myToEmbedTexturesInGlb
     flag to write image textures into GLB file
    bool myToMergeFaces
     flag to merge faces within a single part
    bool myToSplitIndices16
     flag to prefer keeping 16-bit indexes while merging face
    RWMesh_CoordinateSystemConverter myCSTrsf
     transformation from OCCT to glTF coordinate system
    XCAFPrs_Style myDefaultStyle
     default material definition to be used for nodes with only color defined
    std::shared_ptr< RWGltf_GltfOStreamWritermyWriter
     JSON writer.
    occ::handle< RWGltf_GltfMaterialMapmyMaterialMap
     map of defined materials
    RWGltf_GltfBufferView myBuffViewPos
     current buffer view with nodes positions
    RWGltf_GltfBufferView myBuffViewNorm
     current buffer view with nodes normals
    RWGltf_GltfBufferView myBuffViewTextCoord
     current buffer view with nodes UV coordinates
    RWGltf_GltfBufferView myBuffViewInd
     current buffer view with triangulation indexes
    ShapeToGltfFaceMap myBinDataMap
     map for TopoDS_Face to glTF face (merging duplicates)
    int64_t myBinDataLen64
     length of binary file
    NCollection_LinearVector< RWGltf_GltfBufferViewmyBuffViewsDraco
     vector of buffers view with compression data
    bool myToParallel
     flag to use multithreading; FALSE by default
    RWGltf_DracoParameters myDracoParameters
     Draco parameters.

    Additional Inherited Members

    typedef void base_type
     Returns a type descriptor about this object.
    static constexpr const char * get_type_name ()
     Returns a type descriptor about this object.
    static const opencascade::handle< Standard_Type > & get_type_descriptor ()
     Returns type descriptor of Standard_Transient class.

    Detailed Description

    glTF writer context from XCAF document.

    Member Typedef Documentation

    ◆ ShapeToGltfFaceMap

    Constructor & Destructor Documentation

    ◆ RWGltf_CafWriter()

    RWGltf_CafWriter::RWGltf_CafWriter ( const TCollection_AsciiString & theFile,
    bool theIsBinary )

    Main constructor.

    Parameters
    [in]theFilepath to output glTF file
    [in]theIsBinaryflag to write into binary glTF format (.glb)

    ◆ ~RWGltf_CafWriter()

    RWGltf_CafWriter::~RWGltf_CafWriter ( )
    override

    Destructor.

    Member Function Documentation

    ◆ ChangeCoordinateSystemConverter()

    RWMesh_CoordinateSystemConverter & RWGltf_CafWriter::ChangeCoordinateSystemConverter ( )
    inline

    Return transformation from OCCT to glTF coordinate system.

    ◆ CompressionParameters()

    const RWGltf_DracoParameters & RWGltf_CafWriter::CompressionParameters ( ) const
    inline

    Return Draco parameters.

    ◆ CoordinateSystemConverter()

    const RWMesh_CoordinateSystemConverter & RWGltf_CafWriter::CoordinateSystemConverter ( ) const
    inline

    Return transformation from OCCT to glTF coordinate system.

    ◆ DefaultStyle()

    const XCAFPrs_Style & RWGltf_CafWriter::DefaultStyle ( ) const
    inline

    Return default material definition to be used for nodes with only color defined.

    ◆ dispatchShapes()

    virtual void RWGltf_CafWriter::dispatchShapes ( const XCAFPrs_DocumentNode & theDocNode,
    const Message_ProgressScope & thePSentryBin,
    NCollection_DataMap< XCAFPrs_Style, occ::handle< RWGltf_GltfFace > > & theMergedFaces,
    RWMesh_ShapeIterator & theShapeIter )
    protectedvirtual

    Dispatch shapes.

    Parameters
    [in]theDocNodeDocument node containing shape data
    [in]thePSentryBinProgress scope for the operation
    [in,out]theMergedFacesData map to store merged faces
    [in,out]theShapeIterShape iterator to traverse shapes

    ◆ formatName()

    virtual TCollection_AsciiString RWGltf_CafWriter::formatName ( RWMesh_NameFormat theFormat,
    const TDF_Label & theLabel,
    const TDF_Label & theRefLabel ) const
    protectedvirtual

    Generate name for specified labels.

    Parameters
    [in]theFormatname format to apply
    [in]theLabelinstance label
    [in]theRefLabelproduct label

    ◆ getShapeType()

    virtual TopAbs_ShapeEnum RWGltf_CafWriter::getShapeType ( const TopoDS_Shape & theShape) const
    protectedvirtual

    Returns the underlying shape in case of a compound.

    ◆ hasTriangulation()

    virtual bool RWGltf_CafWriter::hasTriangulation ( const RWGltf_GltfFace & theShape) const
    protectedvirtual

    Return TRUE if shape has triangulation (not vertex or edge).

    ◆ IsBinary()

    bool RWGltf_CafWriter::IsBinary ( ) const
    inline

    Return flag to write into binary glTF format (.glb), specified within class constructor.

    ◆ IsForcedUVExport()

    bool RWGltf_CafWriter::IsForcedUVExport ( ) const
    inline

    Return TRUE to export UV coordinates even if there are no mapped texture; FALSE by default.

    ◆ MeshNameFormat()

    RWMesh_NameFormat RWGltf_CafWriter::MeshNameFormat ( ) const
    inline

    Return name format for exporting Meshes; RWMesh_NameFormat_Product by default.

    ◆ NodeNameFormat()

    RWMesh_NameFormat RWGltf_CafWriter::NodeNameFormat ( ) const
    inline

    Return name format for exporting Nodes; RWMesh_NameFormat_InstanceOrProduct by default.

    ◆ Perform() [1/2]

    virtual bool RWGltf_CafWriter::Perform ( const occ::handle< TDocStd_Document > & theDocument,
    const NCollection_IndexedDataMap< TCollection_AsciiString, TCollection_AsciiString > & theFileInfo,
    const Message_ProgressRange & theProgress )
    virtual

    Write glTF file and associated binary file. Triangulation data should be precomputed within shapes!

    Parameters
    [in]theDocumentinput document
    [in]theFileInfomap with file metadata to put into glTF header section
    [in]theProgressoptional progress indicator
    Returns
    FALSE on file writing failure

    ◆ Perform() [2/2]

    virtual bool RWGltf_CafWriter::Perform ( const occ::handle< TDocStd_Document > & theDocument,
    const NCollection_Sequence< TDF_Label > & theRootLabels,
    const NCollection_Map< TCollection_AsciiString > * theLabelFilter,
    const NCollection_IndexedDataMap< TCollection_AsciiString, TCollection_AsciiString > & theFileInfo,
    const Message_ProgressRange & theProgress )
    virtual

    Write glTF file and associated binary file. Triangulation data should be precomputed within shapes!

    Parameters
    [in]theDocumentinput document
    [in]theRootLabelslist of root shapes to export
    [in]theLabelFilteroptional filter with document nodes to export, with keys defined by XCAFPrs_DocumentExplorer::DefineChildId() and filled recursively (leaves and parent assembly nodes at all levels); when not NULL, all nodes not included into the map will be ignored
    [in]theFileInfomap with file metadata to put into glTF header section
    [in]theProgressoptional progress indicator
    Returns
    FALSE on file writing failure

    ◆ saveEdgeIndices()

    virtual void RWGltf_CafWriter::saveEdgeIndices ( RWGltf_GltfFace & theGltfFace,
    std::ostream & theBinFile,
    const RWMesh_EdgeIterator & theEdgeIter )
    protectedvirtual

    Write edge indexes into binary file.

    Parameters
    [out]theGltfFaceglTF face definition
    [out]theBinFileoutput file to write into
    [in]theEdgeItercurrent edge to write

    ◆ saveIndices()

    virtual void RWGltf_CafWriter::saveIndices ( RWGltf_GltfFace & theGltfFace,
    std::ostream & theBinFile,
    const RWMesh_ShapeIterator & theShapeIter,
    int & theAccessorNb,
    const std::shared_ptr< RWGltf_CafWriter::Mesh > & theMesh )
    protectedvirtual

    Write mesh indexes into binary file.

    Parameters
    [out]theGltfFaceglTF face definition
    [out]theBinFileoutput file to write into
    [in]theShapeItercurrent shape to write
    [in]

    out] theAccessorNb last accessor index

    Parameters
    [in]

    out] theMesh mesh

    ◆ saveNodes()

    virtual void RWGltf_CafWriter::saveNodes ( RWGltf_GltfFace & theGltfFace,
    std::ostream & theBinFile,
    const RWMesh_ShapeIterator & theShapeIter,
    int & theAccessorNb,
    const std::shared_ptr< RWGltf_CafWriter::Mesh > & theMesh ) const
    protectedvirtual

    Write mesh nodes into binary file.

    Parameters
    [out]theGltfFaceglTF face definition
    [out]theBinFileoutput file to write into
    [in]theShapeItercurrent shape to write
    [in]

    out] theAccessorNb last accessor index

    Parameters
    [in]

    out] theMesh mesh

    ◆ saveNormals()

    virtual void RWGltf_CafWriter::saveNormals ( RWGltf_GltfFace & theGltfFace,
    std::ostream & theBinFile,
    const RWMesh_FaceIterator & theFaceIter,
    int & theAccessorNb,
    const std::shared_ptr< RWGltf_CafWriter::Mesh > & theMesh ) const
    protectedvirtual

    Write mesh normals into binary file.

    Parameters
    [out]theGltfFaceglTF face definition
    [out]theBinFileoutput file to write into
    [in]theFaceItercurrent face to write
    [in]

    out] theAccessorNb last accessor index

    Parameters
    [in]

    out] theMesh mesh

    ◆ saveTextCoords()

    virtual void RWGltf_CafWriter::saveTextCoords ( RWGltf_GltfFace & theGltfFace,
    std::ostream & theBinFile,
    const RWMesh_FaceIterator & theFaceIter,
    int & theAccessorNb,
    const std::shared_ptr< RWGltf_CafWriter::Mesh > & theMesh ) const
    protectedvirtual

    Write mesh texture UV coordinates into binary file.

    Parameters
    [out]theGltfFaceglTF face definition
    [out]theBinFileoutput file to write into
    [in]theFaceItercurrent face to write
    [in]

    out] theAccessorNb last accessor index

    Parameters
    [in]

    out] theMesh mesh

    ◆ saveTriangleIndices()

    virtual void RWGltf_CafWriter::saveTriangleIndices ( RWGltf_GltfFace & theGltfFace,
    std::ostream & theBinFile,
    const RWMesh_FaceIterator & theFaceIter,
    const std::shared_ptr< RWGltf_CafWriter::Mesh > & theMesh )
    protectedvirtual

    Write triangle indexes into binary file.

    Parameters
    [out]theGltfFaceglTF face definition
    [out]theBinFileoutput file to write into
    [in]theFaceItercurrent face to write
    [in]

    out] theMesh mesh

    ◆ saveVertexIndices()

    virtual void RWGltf_CafWriter::saveVertexIndices ( RWGltf_GltfFace & theGltfFace,
    std::ostream & theBinFile,
    const RWMesh_VertexIterator & theVertexIter )
    protectedvirtual

    Write vertex indexes into binary file.

    Parameters
    [out]theGltfFaceglTF face definition
    [out]theBinFileoutput file to write into
    [in]theVertexItercurrent vertex to write

    ◆ SetCompressionParameters()

    void RWGltf_CafWriter::SetCompressionParameters ( const RWGltf_DracoParameters & theDracoParameters)
    inline

    Set Draco parameters.

    ◆ SetCoordinateSystemConverter()

    void RWGltf_CafWriter::SetCoordinateSystemConverter ( const RWMesh_CoordinateSystemConverter & theConverter)
    inline

    Set transformation from OCCT to glTF coordinate system.

    ◆ SetDefaultStyle()

    void RWGltf_CafWriter::SetDefaultStyle ( const XCAFPrs_Style & theStyle)
    inline

    Set default material definition to be used for nodes with only color defined.

    ◆ SetForcedUVExport()

    void RWGltf_CafWriter::SetForcedUVExport ( bool theToForce)
    inline

    Set flag to export UV coordinates even if there are no mapped texture; FALSE by default.

    ◆ SetMergeFaces()

    void RWGltf_CafWriter::SetMergeFaces ( bool theToMerge)
    inline

    Set flag to merge faces within a single part. May reduce JSON size thanks to smaller number of primitive arrays.

    ◆ SetMeshNameFormat()

    void RWGltf_CafWriter::SetMeshNameFormat ( RWMesh_NameFormat theFormat)
    inline

    Set name format for exporting Meshes.

    ◆ SetNodeNameFormat()

    void RWGltf_CafWriter::SetNodeNameFormat ( RWMesh_NameFormat theFormat)
    inline

    Set name format for exporting Nodes.

    ◆ SetParallel()

    void RWGltf_CafWriter::SetParallel ( bool theToParallel)
    inline

    Setup multithreaded execution.

    ◆ SetSplitIndices16()

    void RWGltf_CafWriter::SetSplitIndices16 ( bool theToSplit)
    inline

    Set flag to prefer keeping 16-bit indexes while merging face. Has effect only with ToMergeFaces() option turned ON. May reduce binary data size thanks to smaller triangle indexes.

    ◆ SetToEmbedTexturesInGlb()

    void RWGltf_CafWriter::SetToEmbedTexturesInGlb ( bool theToEmbedTexturesInGlb)
    inline

    Set flag to write image textures into GLB file (binary gltf export).

    ◆ SetTransformationFormat()

    void RWGltf_CafWriter::SetTransformationFormat ( RWGltf_WriterTrsfFormat theFormat)
    inline

    Set preferred transformation format for writing into glTF file.

    ◆ ToEmbedTexturesInGlb()

    bool RWGltf_CafWriter::ToEmbedTexturesInGlb ( )
    inline

    Return flag to write image textures into GLB file (binary gltf export); TRUE by default. When set to FALSE, texture images will be written as separate files. Has no effect on writing into non-binary format.

    ◆ ToMergeFaces()

    bool RWGltf_CafWriter::ToMergeFaces ( ) const
    inline

    Return flag to merge faces within a single part; FALSE by default.

    ◆ ToParallel()

    bool RWGltf_CafWriter::ToParallel ( ) const
    inline

    Return TRUE if multithreaded optimizations are allowed; FALSE by default.

    ◆ toSkipShape()

    virtual bool RWGltf_CafWriter::toSkipShape ( const RWMesh_ShapeIterator & theShapeIter) const
    protectedvirtual

    Return TRUE if face shape should be skipped (e.g. because it is invalid or empty).

    ◆ ToSplitIndices16()

    bool RWGltf_CafWriter::ToSplitIndices16 ( ) const
    inline

    Return flag to prefer keeping 16-bit indexes while merging face; FALSE by default.

    ◆ TransformationFormat()

    RWGltf_WriterTrsfFormat RWGltf_CafWriter::TransformationFormat ( ) const
    inline

    Return preferred transformation format for writing into glTF file; RWGltf_WriterTrsfFormat_Compact by default.

    ◆ writeAccessors()

    virtual void RWGltf_CafWriter::writeAccessors ( const RWGltf_GltfSceneNodeMap & theSceneNodeMap)
    protectedvirtual

    Write RWGltf_GltfRootElement_Accessors section.

    Parameters
    [in]theSceneNodeMapordered map of scene nodes

    ◆ writeAnimations()

    virtual void RWGltf_CafWriter::writeAnimations ( )
    protectedvirtual

    Write RWGltf_GltfRootElement_Animations section (reserved).

    ◆ writeAsset()

    virtual void RWGltf_CafWriter::writeAsset ( const NCollection_IndexedDataMap< TCollection_AsciiString, TCollection_AsciiString > & theFileInfo)
    protectedvirtual

    Write RWGltf_GltfRootElement_Asset section.

    Parameters
    [in]theFileInfooptional metadata to write into file header

    ◆ writeBinData()

    virtual bool RWGltf_CafWriter::writeBinData ( const occ::handle< TDocStd_Document > & theDocument,
    const NCollection_Sequence< TDF_Label > & theRootLabels,
    const NCollection_Map< TCollection_AsciiString > * theLabelFilter,
    const Message_ProgressRange & theProgress )
    protectedvirtual

    Write binary data file with triangulation data. Triangulation data should be precomputed within shapes!

    Parameters
    [in]theDocumentinput document
    [in]theRootLabelslist of root shapes to export
    [in]theLabelFilteroptional filter with document nodes to export
    [in]theProgressoptional progress indicator
    Returns
    FALSE on file writing failure

    ◆ writeBuffers()

    virtual void RWGltf_CafWriter::writeBuffers ( )
    protectedvirtual

    Write RWGltf_GltfRootElement_Buffers section.

    ◆ writeBufferViews()

    virtual void RWGltf_CafWriter::writeBufferViews ( const int theBinDataBufferId)
    protectedvirtual

    Write RWGltf_GltfRootElement_BufferViews section.

    Parameters
    [in]theBinDataBufferIdindex of binary buffer with vertex data

    ◆ writeExtensions()

    virtual void RWGltf_CafWriter::writeExtensions ( )
    protectedvirtual

    Write RWGltf_GltfRootElement_ExtensionsUsed/RWGltf_GltfRootElement_ExtensionsRequired sections (reserved).

    ◆ writeExtrasAttributes()

    virtual void RWGltf_CafWriter::writeExtrasAttributes ( const occ::handle< TDataStd_NamedData > & theNamedData)
    protectedvirtual

    Write nodes.extras section with key-value attributes.

    Parameters
    [in]theNamedDataattributes map to process.

    ◆ writeImages()

    virtual void RWGltf_CafWriter::writeImages ( const RWGltf_GltfSceneNodeMap & theSceneNodeMap)
    protectedvirtual

    Write RWGltf_GltfRootElement_Images section.

    Parameters
    [in]theSceneNodeMapordered map of scene nodes
    [out]theMaterialMapmap of materials, filled with image files used by textures

    ◆ writeIndices()

    virtual void RWGltf_CafWriter::writeIndices ( const RWGltf_GltfFace & theGltfFace)
    protectedvirtual

    Write bufferView for triangle indexes within RWGltf_GltfRootElement_Accessors section.

    Parameters
    [in]theGltfFaceface definition to write

    ◆ writeJson()

    virtual bool RWGltf_CafWriter::writeJson ( const occ::handle< TDocStd_Document > & theDocument,
    const NCollection_Sequence< TDF_Label > & theRootLabels,
    const NCollection_Map< TCollection_AsciiString > * theLabelFilter,
    const NCollection_IndexedDataMap< TCollection_AsciiString, TCollection_AsciiString > & theFileInfo,
    const Message_ProgressRange & theProgress )
    protectedvirtual

    Write JSON file with glTF structure (should be called after writeBinData()).

    Parameters
    [in]theDocumentinput document
    [in]theRootLabelslist of root shapes to export
    [in]theLabelFilteroptional filter with document nodes to export
    [in]theFileInfomap with file metadata to put into glTF header section
    [in]theProgressoptional progress indicator
    Returns
    FALSE on file writing failure

    ◆ writeMaterial()

    virtual void RWGltf_CafWriter::writeMaterial ( RWMesh_ShapeIterator & theShapeIter,
    bool & theIsStarted )
    protectedvirtual

    Write RWGltf_GltfRootElement_Materials section.

    Parameters
    [in]theShapeIterShape iterator to traverse shapes
    [out]theIsStartedFlag indicating that writing material has been started

    ◆ writeMaterials()

    virtual void RWGltf_CafWriter::writeMaterials ( const RWGltf_GltfSceneNodeMap & theSceneNodeMap)
    protectedvirtual

    Write RWGltf_GltfRootElement_Materials section.

    Parameters
    [in]theSceneNodeMapordered map of scene nodes
    [out]theMaterialMapmap of materials, filled with materials

    ◆ writeMeshes()

    virtual void RWGltf_CafWriter::writeMeshes ( const RWGltf_GltfSceneNodeMap & theSceneNodeMap)
    protectedvirtual

    Write RWGltf_GltfRootElement_Meshes section.

    Parameters
    [in]theSceneNodeMapordered map of scene nodes
    [in]theMaterialMapmap of materials

    ◆ writeNodes()

    virtual void RWGltf_CafWriter::writeNodes ( const occ::handle< TDocStd_Document > & theDocument,
    const NCollection_Sequence< TDF_Label > & theRootLabels,
    const NCollection_Map< TCollection_AsciiString > * theLabelFilter,
    const RWGltf_GltfSceneNodeMap & theSceneNodeMap,
    NCollection_Sequence< int > & theSceneRootNodeInds )
    protectedvirtual

    Write RWGltf_GltfRootElement_Nodes section.

    Parameters
    [in]theDocumentinput document
    [in]theRootLabelslist of root shapes to export
    [in]theLabelFilteroptional filter with document nodes to export
    [in]theSceneNodeMapordered map of scene nodes
    [out]theSceneRootNodeIndssequence of scene nodes pointing to root shapes (to be used for writeScenes())

    ◆ writeNormals()

    virtual void RWGltf_CafWriter::writeNormals ( const RWGltf_GltfFace & theGltfFace)
    protectedvirtual

    Write bufferView for vertex normals within RWGltf_GltfRootElement_Accessors section.

    Parameters
    [in]theGltfFaceface definition to write

    ◆ writePositions()

    virtual void RWGltf_CafWriter::writePositions ( const RWGltf_GltfFace & theGltfFace)
    protectedvirtual

    Write bufferView for vertex positions within RWGltf_GltfRootElement_Accessors section.

    Parameters
    [in]theGltfFaceface definition to write

    ◆ writePrimArray()

    virtual void RWGltf_CafWriter::writePrimArray ( const RWGltf_GltfFace & theGltfFace,
    const TCollection_AsciiString & theName,
    const int theDracoBufInd,
    bool & theToStartPrims )
    protectedvirtual

    Write a primitive array to RWGltf_GltfRootElement_Meshes section.

    Parameters
    [in]theGltfFaceface to write
    [in]theNameprimitive array name
    [in]theDracoBufInddraco buffer index
    [in,out]theToStartPrimsflag indicating that primitive array has been started

    ◆ writeSamplers()

    virtual void RWGltf_CafWriter::writeSamplers ( )
    protectedvirtual

    Write RWGltf_GltfRootElement_Samplers section.

    ◆ writeScene()

    virtual void RWGltf_CafWriter::writeScene ( const int theDefSceneId)
    protectedvirtual

    Write RWGltf_GltfRootElement_Scene section.

    Parameters
    [in]theDefSceneIdindex of default scene (0)

    ◆ writeScenes()

    virtual void RWGltf_CafWriter::writeScenes ( const NCollection_Sequence< int > & theSceneRootNodeInds)
    protectedvirtual

    Write RWGltf_GltfRootElement_Scenes section.

    Parameters
    [in]theSceneRootNodeIndssequence of scene nodes pointing to root shapes

    ◆ writeShapes()

    virtual void RWGltf_CafWriter::writeShapes ( RWMesh_ShapeIterator & theShapeIter,
    int & theDracoBufInd,
    bool & theToStartPrims,
    const TCollection_AsciiString & theNodeName,
    NCollection_Map< occ::handle< NCollection_Shared< NCollection_List< occ::handle< RWGltf_GltfFace > > > > > & theWrittenShapes,
    NCollection_IndexedDataMap< int, int > & theDracoBufIndMap )
    protectedvirtual

    Write shapes to RWGltf_GltfRootElement_Meshes section.

    Parameters
    [in]theShapeIterShape iterator to traverse shapes
    [in,out]theDracoBufIndDraco buffer index
    [in,out]theToStartPrimsFlag to indicate if primitives should be started
    [in]theNodeNameName of the current node
    [in,out]theWrittenShapesMap to store written shapes
    [in,out]theDracoBufIndMapMap to store Draco buffer indices

    ◆ writeShapesToBin()

    bool RWGltf_CafWriter::writeShapesToBin ( RWGltf_GltfFace & theGltfFace,
    std::ostream & theBinFile,
    RWMesh_ShapeIterator & theShapeIter,
    int & theAccessorNb,
    const std::shared_ptr< RWGltf_CafWriter::Mesh > & theMesh,
    const RWGltf_GltfArrayType theArrType,
    const Message_ProgressScope & thePSentryBin )
    protected

    Write shape into binary file.

    Parameters
    [out]theGltfFaceglTF face definition
    [out]theBinFileOutput file to write into
    [in]theShapeIterCurrent shape iterator
    [in,out]theAccessorNbLast accessor index
    [in,out]theMeshMesh data
    [in]theArrTypeArray type for glTF
    [in]thePSentryBinProgress scope for the operation
    Returns
    True if shapes were successfully written to the binary file, false otherwise

    ◆ writeSkins()

    virtual void RWGltf_CafWriter::writeSkins ( )
    protectedvirtual

    Write RWGltf_GltfRootElement_Skins section (reserved).

    ◆ writeTextCoords()

    virtual void RWGltf_CafWriter::writeTextCoords ( const RWGltf_GltfFace & theGltfFace)
    protectedvirtual

    Write bufferView for vertex texture coordinates within RWGltf_GltfRootElement_Accessors section.

    Parameters
    [in]theGltfFaceface definition to write

    ◆ writeTextures()

    virtual void RWGltf_CafWriter::writeTextures ( const RWGltf_GltfSceneNodeMap & theSceneNodeMap)
    protectedvirtual

    Write RWGltf_GltfRootElement_Textures section.

    Parameters
    [in]theSceneNodeMapordered map of scene nodes
    [out]theMaterialMapmap of materials, filled with textures

    Field Documentation

    ◆ myBinDataLen64

    int64_t RWGltf_CafWriter::myBinDataLen64
    protected

    length of binary file

    ◆ myBinDataMap

    ShapeToGltfFaceMap RWGltf_CafWriter::myBinDataMap
    protected

    map for TopoDS_Face to glTF face (merging duplicates)

    ◆ myBinFileNameFull

    TCollection_AsciiString RWGltf_CafWriter::myBinFileNameFull
    protected

    output file with binary data (full path)

    ◆ myBinFileNameShort

    TCollection_AsciiString RWGltf_CafWriter::myBinFileNameShort
    protected

    output file with binary data (short path)

    ◆ myBuffViewInd

    RWGltf_GltfBufferView RWGltf_CafWriter::myBuffViewInd
    protected

    current buffer view with triangulation indexes

    ◆ myBuffViewNorm

    RWGltf_GltfBufferView RWGltf_CafWriter::myBuffViewNorm
    protected

    current buffer view with nodes normals

    ◆ myBuffViewPos

    RWGltf_GltfBufferView RWGltf_CafWriter::myBuffViewPos
    protected

    current buffer view with nodes positions

    ◆ myBuffViewsDraco

    NCollection_LinearVector<RWGltf_GltfBufferView> RWGltf_CafWriter::myBuffViewsDraco
    protected

    vector of buffers view with compression data

    ◆ myBuffViewTextCoord

    RWGltf_GltfBufferView RWGltf_CafWriter::myBuffViewTextCoord
    protected

    current buffer view with nodes UV coordinates

    ◆ myCSTrsf

    RWMesh_CoordinateSystemConverter RWGltf_CafWriter::myCSTrsf
    protected

    transformation from OCCT to glTF coordinate system

    ◆ myDefaultStyle

    XCAFPrs_Style RWGltf_CafWriter::myDefaultStyle
    protected

    default material definition to be used for nodes with only color defined

    ◆ myDracoParameters

    RWGltf_DracoParameters RWGltf_CafWriter::myDracoParameters
    protected

    Draco parameters.

    ◆ myFile

    TCollection_AsciiString RWGltf_CafWriter::myFile
    protected

    output glTF file

    ◆ myIsBinary

    bool RWGltf_CafWriter::myIsBinary
    protected

    flag to write into binary glTF format (.glb)

    ◆ myIsForcedUVExport

    bool RWGltf_CafWriter::myIsForcedUVExport
    protected

    export UV coordinates even if there are no mapped texture

    ◆ myMaterialMap

    occ::handle<RWGltf_GltfMaterialMap> RWGltf_CafWriter::myMaterialMap
    protected

    map of defined materials

    ◆ myMeshNameFormat

    RWMesh_NameFormat RWGltf_CafWriter::myMeshNameFormat
    protected

    name format for exporting Meshes

    ◆ myNodeNameFormat

    RWMesh_NameFormat RWGltf_CafWriter::myNodeNameFormat
    protected

    name format for exporting Nodes

    ◆ myToEmbedTexturesInGlb

    bool RWGltf_CafWriter::myToEmbedTexturesInGlb
    protected

    flag to write image textures into GLB file

    ◆ myToMergeFaces

    bool RWGltf_CafWriter::myToMergeFaces
    protected

    flag to merge faces within a single part

    ◆ myToParallel

    bool RWGltf_CafWriter::myToParallel
    protected

    flag to use multithreading; FALSE by default

    ◆ myToSplitIndices16

    bool RWGltf_CafWriter::myToSplitIndices16
    protected

    flag to prefer keeping 16-bit indexes while merging face

    ◆ myTrsfFormat

    RWGltf_WriterTrsfFormat RWGltf_CafWriter::myTrsfFormat
    protected

    transformation format to write into glTF file

    ◆ myWriter

    std::shared_ptr<RWGltf_GltfOStreamWriter> RWGltf_CafWriter::myWriter
    protected

    JSON writer.


    The documentation for this class was generated from the following file: