Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-05 08:34:48

0001 // Author: Kirill Gavrilov
0002 // Copyright (c) 2016-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_CafReader_HeaderFile
0016 #define _RWGltf_CafReader_HeaderFile
0017 
0018 #include <NCollection_Vector.hxx>
0019 #include <RWMesh_CafReader.hxx>
0020 #include <TopoDS_Face.hxx>
0021 
0022 class RWMesh_TriangulationReader;
0023 
0024 //! The glTF (GL Transmission Format) mesh reader into XDE document.
0025 class RWGltf_CafReader : public RWMesh_CafReader
0026 {
0027   DEFINE_STANDARD_RTTIEXT(RWGltf_CafReader, RWMesh_CafReader)
0028 public:
0029   //! Empty constructor.
0030   Standard_EXPORT RWGltf_CafReader();
0031 
0032   //! Return TRUE if multithreaded optimizations are allowed; FALSE by default.
0033   bool ToParallel() const { return myToParallel; }
0034 
0035   //! Setup multithreaded execution.
0036   void SetParallel(bool theToParallel) { myToParallel = theToParallel; }
0037 
0038   //! Return TRUE if Nodes without Geometry should be ignored, TRUE by default.
0039   bool ToSkipEmptyNodes() { return myToSkipEmptyNodes; }
0040 
0041   //! Set flag to ignore nodes without Geometry.
0042   void SetSkipEmptyNodes(bool theToSkip) { myToSkipEmptyNodes = theToSkip; }
0043 
0044   //! Return TRUE if all scenes in the document should be loaded, FALSE by default which means only
0045   //! main (default) scene will be loaded.
0046   bool ToLoadAllScenes() const { return myToLoadAllScenes; }
0047 
0048   //! Set flag to flag to load all scenes in the document, FALSE by default which means only main
0049   //! (default) scene will be loaded.
0050   void SetLoadAllScenes(bool theToLoadAll) { myToLoadAllScenes = theToLoadAll; }
0051 
0052   //! Set flag to use Mesh name in case if Node name is empty, TRUE by default.
0053   bool ToUseMeshNameAsFallback() { return myUseMeshNameAsFallback; }
0054 
0055   //! Set flag to use Mesh name in case if Node name is empty.
0056   void SetMeshNameAsFallback(bool theToFallback) { myUseMeshNameAsFallback = theToFallback; }
0057 
0058   //! Return flag to fill in triangulation using double or single precision; FALSE by default.
0059   bool IsDoublePrecision() const { return myIsDoublePrecision; }
0060 
0061   //! Set flag to fill in triangulation using double or single precision.
0062   void SetDoublePrecision(bool theIsDouble) { myIsDoublePrecision = theIsDouble; }
0063 
0064   //! Returns TRUE if data loading should be skipped and can be performed later; FALSE by default.
0065   bool ToSkipLateDataLoading() { return myToSkipLateDataLoading; }
0066 
0067   //! Sets flag to skip data loading.
0068   void SetToSkipLateDataLoading(bool theToSkip) { myToSkipLateDataLoading = theToSkip; }
0069 
0070   //! Returns TRUE if data should be loaded into itself without its transferring to new structure.
0071   //! It allows to keep information about deferred storage to load/unload this data later.
0072   //! TRUE by default.
0073   bool ToKeepLateData() { return myToKeepLateData; }
0074 
0075   //! Sets flag to keep information about deferred storage to load/unload data later.
0076   void SetToKeepLateData(bool theToKeep) { myToKeepLateData = theToKeep; }
0077 
0078   //! Returns TRUE if additional debug information should be print; FALSE by default.
0079   bool ToPrintDebugMessages() const { return myToPrintDebugMessages; }
0080 
0081   //! Sets flag to print debug information.
0082   void SetToPrintDebugMessages(const Standard_Boolean theToPrint)
0083   {
0084     myToPrintDebugMessages = theToPrint;
0085   }
0086 
0087 protected:
0088   //! Read the mesh from specified file.
0089   Standard_EXPORT virtual Standard_Boolean performMesh(std::istream&                  theStream,
0090                                                        const TCollection_AsciiString& theFile,
0091                                                        const Message_ProgressRange&   theProgress,
0092                                                        const Standard_Boolean         theToProbe)
0093     Standard_OVERRIDE;
0094 
0095   //! Create primitive array reader context.
0096   //! Can be overridden by sub-class to read triangulation into application-specific data structures
0097   //! instead of Poly_Triangulation. Default implementation creates RWGltf_TriangulationReader.
0098   Standard_EXPORT virtual Handle(RWMesh_TriangulationReader) createMeshReaderContext() const;
0099 
0100   //! Read late data from RWGltf_GltfLatePrimitiveArray stored as Poly_Triangulation within faces.
0101   Standard_EXPORT virtual Standard_Boolean readLateData(NCollection_Vector<TopoDS_Face>& theFaces,
0102                                                         const TCollection_AsciiString&   theFile,
0103                                                         const Message_ProgressRange& theProgress);
0104 
0105   //! Set reader for each late data.
0106   Standard_EXPORT void updateLateDataReader(
0107     NCollection_Vector<TopoDS_Face>&          theFaces,
0108     const Handle(RWMesh_TriangulationReader)& theReader) const;
0109 
0110 protected:
0111   class CafReader_GltfBaseLoadingFunctor;
0112   class CafReader_GltfFullDataLoadingFunctor;
0113   class CafReader_GltfStreamDataLoadingFunctor;
0114 
0115 protected:
0116   Standard_Boolean myToParallel;           //!< flag to use multithreading; FALSE by default
0117   Standard_Boolean myToSkipEmptyNodes;     //!< ignore nodes without Geometry; TRUE by default
0118                                            // clang-format off
0119   Standard_Boolean myToLoadAllScenes;       //!< flag to load all scenes in the document, FALSE by default
0120   Standard_Boolean myUseMeshNameAsFallback; //!< flag to use Mesh name in case if Node name is empty, TRUE by default
0121   Standard_Boolean myIsDoublePrecision;     //!< flag to fill in triangulation using single or double precision
0122   Standard_Boolean myToSkipLateDataLoading; //!< flag to skip triangulation loading
0123   Standard_Boolean myToKeepLateData;        //!< flag to keep information about deferred storage to load/unload triangulation later
0124                                            // clang-format on
0125   Standard_Boolean myToPrintDebugMessages; //!< flag to print additional debug information
0126 };
0127 
0128 #endif // _RWGltf_CafReader_HeaderFile