Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:42

0001 // Author: Kirill Gavrilov
0002 // Copyright (c) 2019 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _RWGltf_TriangulationReader_HeaderFile
0016 #define _RWGltf_TriangulationReader_HeaderFile
0017 
0018 #include <RWMesh_TriangulationReader.hxx>
0019 #include <RWGltf_GltfAccessor.hxx>
0020 #include <RWGltf_GltfArrayType.hxx>
0021 
0022 class RWGltf_GltfLatePrimitiveArray;
0023 class RWGltf_GltfPrimArrayData;
0024 
0025 //! RWMesh_TriangulationReader implementation creating Poly_Triangulation.
0026 class RWGltf_TriangulationReader : public RWMesh_TriangulationReader
0027 {
0028   DEFINE_STANDARD_RTTIEXT(RWGltf_TriangulationReader, RWMesh_TriangulationReader)
0029 public:
0030 
0031   //! Empty constructor.
0032   Standard_EXPORT RWGltf_TriangulationReader();
0033 
0034   //! Loads only primitive arrays saved as stream buffer
0035   //! (it is primarily glTF data encoded in base64 saved to temporary buffer during glTF file reading).
0036   Standard_EXPORT bool LoadStreamData (const Handle(RWMesh_TriangulationSource)& theSourceMesh,
0037                                        const Handle(Poly_Triangulation)& theDestMesh) const;
0038 
0039 protected:
0040 
0041   //! Reports error.
0042   Standard_EXPORT virtual void reportError (const TCollection_AsciiString& theText) const;
0043 
0044   //! Loads only primitive arrays from file data.
0045   //! @param theSourceMesh    source triangulation
0046   //! @param theDestMesh      triangulation to be modified
0047   //! @param theFileSystem    shared file system to read from
0048   //! Note: this method skips "stream data" that should be loaded by LoadStreamData() call.
0049   Standard_EXPORT virtual bool load (const Handle(RWMesh_TriangulationSource)& theSourceMesh,
0050                                      const Handle(Poly_Triangulation)& theDestMesh,
0051                                      const Handle(OSD_FileSystem)& theFileSystem) const Standard_OVERRIDE;
0052 
0053   //! Performs additional actions to finalize data loading.
0054   //! @param theSourceMesh source triangulation
0055   //! @param theDestMesh   triangulation to be modified
0056   Standard_EXPORT virtual bool finalizeLoading (const Handle(RWMesh_TriangulationSource)& theSourceMesh,
0057                                                 const Handle(Poly_Triangulation)& theDestMesh) const Standard_OVERRIDE;
0058 
0059   //! Loads only primitive arrays saved as stream buffer
0060   //! (it is primarily glTF data encoded in base64 saved to temporary buffer during glTF file reading).
0061   //! @param theSourceMesh    source triangulation
0062   //! @param theDestMesh      triangulation to be modified
0063   //! @param theToResetStream if TRUE reset input stream data buffer after its loading.
0064   Standard_EXPORT bool loadStreamData (const Handle(RWMesh_TriangulationSource)& theSourceMesh,
0065                                        const Handle(Poly_Triangulation)& theDestMesh,
0066                                        bool theToResetStream = true) const;
0067 
0068   //! Reads primitive array from stream data.
0069   //! @param theSourceGltfMesh source glTF triangulation
0070   //! @param theGltfData       primitive array element (stream data should not be NULL)
0071   //! @param theDestMesh       triangulation to be modified
0072   Standard_EXPORT bool readStreamData (const Handle(RWGltf_GltfLatePrimitiveArray)& theSourceGltfMesh,
0073                                        const RWGltf_GltfPrimArrayData& theGltfData,
0074                                        const Handle(Poly_Triangulation)& theDestMesh) const;
0075 
0076   //! Reads primitive array from file data.
0077   //! @param theSourceGltfMesh source glTF triangulation
0078   //! @param theGltfData       primitive array element (Uri of file stream should not be empty)
0079   //! @param theDestMesh       triangulation to be modified
0080   //! @param theFileSystem     shared file system to read from
0081   Standard_EXPORT bool readFileData (const Handle(RWGltf_GltfLatePrimitiveArray)& theSourceGltfMesh,
0082                                      const RWGltf_GltfPrimArrayData& theGltfData,
0083                                      const Handle(Poly_Triangulation)& theDestMesh,
0084                                      const Handle(OSD_FileSystem)& theFileSystem) const;
0085 
0086   //! Fills triangulation data and ignore non-triangulation primitives.
0087   //! @param theSourceGltfMesh source glTF triangulation
0088   //! @param theDestMesh       triangulation to be modified
0089   //! @param theStream         input stream to read from
0090   //! @param theAccessor       buffer accessor
0091   //! @param theType           array type
0092   //! @return FALSE on error
0093   Standard_EXPORT virtual bool readBuffer (const Handle(RWGltf_GltfLatePrimitiveArray)& theSourceGltfMesh,
0094                                            const Handle(Poly_Triangulation)& theDestMesh,
0095                                            std::istream& theStream,
0096                                            const RWGltf_GltfAccessor& theAccessor,
0097                                            RWGltf_GltfArrayType theType) const;
0098 
0099   //! Reads primitive array from file data compressed in Draco format.
0100   //! @param theSourceGltfMesh source glTF triangulation
0101   //! @param theGltfData       primitive array element (Uri of file stream should not be empty)
0102   //! @param theDestMesh       triangulation to be modified
0103   //! @param theFileSystem     shared file system to read from
0104   Standard_EXPORT virtual bool readDracoBuffer (const Handle(RWGltf_GltfLatePrimitiveArray)& theSourceGltfMesh,
0105                                                 const RWGltf_GltfPrimArrayData& theGltfData,
0106                                                 const Handle(Poly_Triangulation)& theDestMesh,
0107                                                 const Handle(OSD_FileSystem)& theFileSystem) const;
0108 
0109 protected:
0110 
0111   Handle(Poly_Triangulation) myTriangulation;
0112 
0113 };
0114 
0115 #endif // _RWGltf_TriangulationReader_HeaderFile