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