1 // Author: Kirill Gavrilov
2 // Copyright (c) 2019 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _RWGltf_PrimitiveArrayReader_HeaderFile
16 #define _RWGltf_PrimitiveArrayReader_HeaderFile
18 #include <Poly_Triangulation.hxx>
19 #include <RWMesh_CoordinateSystemConverter.hxx>
20 #include <RWGltf_GltfAccessor.hxx>
21 #include <RWGltf_GltfArrayType.hxx>
22 #include <RWGltf_GltfPrimitiveMode.hxx>
23 #include <TCollection_AsciiString.hxx>
25 class RWGltf_GltfLatePrimitiveArray;
28 //! Interface for reading primitive array from glTF buffer.
29 class RWGltf_PrimitiveArrayReader : public Standard_Transient
31 DEFINE_STANDARD_RTTIEXT(RWGltf_PrimitiveArrayReader, Standard_Transient)
35 RWGltf_PrimitiveArrayReader() {}
37 //! Return prefix for reporting issues.
38 const TCollection_AsciiString& ErrorPrefix() const { return myErrorPrefix; }
40 //! Set prefix for reporting issues.
41 void SetErrorPrefix (const TCollection_AsciiString& theErrPrefix) { myErrorPrefix = theErrPrefix; }
43 //! Return transformation from glTF to OCCT coordinate system.
44 const RWMesh_CoordinateSystemConverter& CoordinateSystemConverter() const { return myCoordSysConverter; }
46 //! Set transformation from glTF to OCCT coordinate system.
47 void SetCoordinateSystemConverter (const RWMesh_CoordinateSystemConverter& theConverter) { myCoordSysConverter = theConverter; }
49 //! Load primitive array.
50 Handle(Poly_Triangulation) Load (const Handle(RWGltf_GltfLatePrimitiveArray)& theMesh,
51 const Handle(OSD_FileSystem)& theFileSystem)
53 if (load (theMesh, theFileSystem))
57 return Handle(Poly_Triangulation)();
62 //! Reset cache before loading primitive array.
63 Standard_EXPORT virtual void reset() = 0;
65 //! Load primitive array.
66 Standard_EXPORT virtual bool load (const Handle(RWGltf_GltfLatePrimitiveArray)& theMesh,
67 const Handle(OSD_FileSystem)& theFileSystem);
69 //! Return result primitive array.
70 Standard_EXPORT virtual Handle(Poly_Triangulation) result() = 0;
72 //! Read primitive array data.
73 //! @param theStream input stream to read from
74 //! @param theName entity name for logging errors
75 //! @param theAccessor buffer accessor
76 //! @param theType array type
77 //! @param theMode primitive mode
78 //! @return FALSE on error
79 Standard_EXPORT virtual bool readBuffer (std::istream& theStream,
80 const TCollection_AsciiString& theName,
81 const RWGltf_GltfAccessor& theAccessor,
82 RWGltf_GltfArrayType theType,
83 RWGltf_GltfPrimitiveMode theMode) = 0;
86 Standard_EXPORT virtual void reportError (const TCollection_AsciiString& theText);
90 TCollection_AsciiString myErrorPrefix;
91 RWMesh_CoordinateSystemConverter myCoordSysConverter;
95 #endif // _RWGltf_PrimitiveArrayReader_HeaderFile