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) 2018-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_GltfLatePrimitiveArray_HeaderFile
0016 #define _RWGltf_GltfLatePrimitiveArray_HeaderFile
0017 
0018 #include <RWMesh_TriangulationSource.hxx>
0019 
0020 #include <NCollection_Sequence.hxx>
0021 #include <RWGltf_GltfArrayType.hxx>
0022 #include <RWGltf_GltfPrimitiveMode.hxx>
0023 #include <Quantity_ColorRGBA.hxx>
0024 
0025 class RWGltf_GltfPrimArrayData;
0026 class RWGltf_MaterialMetallicRoughness;
0027 class RWGltf_MaterialCommon;
0028 
0029 //! Mesh data wrapper for delayed primitive array loading from glTF file.
0030 class RWGltf_GltfLatePrimitiveArray : public RWMesh_TriangulationSource
0031 {
0032   DEFINE_STANDARD_RTTIEXT(RWGltf_GltfLatePrimitiveArray, RWMesh_TriangulationSource)
0033 public:
0034 
0035   //! Constructor.
0036   Standard_EXPORT RWGltf_GltfLatePrimitiveArray (const TCollection_AsciiString& theId,
0037                                                  const TCollection_AsciiString& theName);
0038 
0039   //! Destructor.
0040   Standard_EXPORT virtual ~RWGltf_GltfLatePrimitiveArray();
0041 
0042   //! Entity id.
0043   const TCollection_AsciiString& Id() const { return myId; }
0044 
0045   //! Entity name.
0046   const TCollection_AsciiString& Name() const { return myName; }
0047 
0048   //! Assign entity name.
0049   void SetName (const TCollection_AsciiString& theName) { myName = theName; }
0050 
0051   //! Return type of primitive array.
0052   RWGltf_GltfPrimitiveMode PrimitiveMode() const { return myPrimMode; }
0053 
0054   //! Set type of primitive array.
0055   void SetPrimitiveMode (RWGltf_GltfPrimitiveMode theMode) { myPrimMode = theMode; }
0056 
0057   //! Return true if primitive array has assigned material
0058   bool HasStyle() const { return !myMaterialPbr.IsNull() || !myMaterialCommon.IsNull(); }
0059 
0060   //! Return base color.
0061   Standard_EXPORT Quantity_ColorRGBA BaseColor() const;
0062 
0063   //! Return PBR material definition.
0064   const Handle(RWGltf_MaterialMetallicRoughness)& MaterialPbr() const { return myMaterialPbr; }
0065 
0066   //! Set PBR material definition.
0067   void SetMaterialPbr (const Handle(RWGltf_MaterialMetallicRoughness)& theMat) { myMaterialPbr = theMat; }
0068 
0069   //! Return common (obsolete) material definition.
0070   const Handle(RWGltf_MaterialCommon)& MaterialCommon() const { return myMaterialCommon; }
0071 
0072   //! Set common (obsolete) material definition.
0073   void SetMaterialCommon (const Handle(RWGltf_MaterialCommon)& theMat) { myMaterialCommon = theMat; }
0074 
0075   //! Return primitive array data elements.
0076   const NCollection_Sequence<RWGltf_GltfPrimArrayData>& Data() const { return myData; }
0077 
0078   //! Add primitive array data element.
0079   Standard_EXPORT RWGltf_GltfPrimArrayData& AddPrimArrayData (RWGltf_GltfArrayType theType);
0080 
0081   //! Return TRUE if there is deferred storage and some triangulation data
0082   //! that can be loaded using LoadDeferredData().
0083   virtual Standard_Boolean HasDeferredData() const Standard_OVERRIDE
0084   {
0085     return !myData.IsEmpty() && RWMesh_TriangulationSource::HasDeferredData();
0086   }
0087 
0088   //! Load primitive array saved as stream buffer to new triangulation object.
0089   Standard_EXPORT Handle(Poly_Triangulation) LoadStreamData() const;
0090 
0091 protected:
0092 
0093   NCollection_Sequence<RWGltf_GltfPrimArrayData> myData;
0094   Handle(RWGltf_MaterialMetallicRoughness) myMaterialPbr;    //!< PBR material
0095   Handle(RWGltf_MaterialCommon)            myMaterialCommon; //!< common (obsolete) material
0096   TCollection_AsciiString  myId;         //!< entity id
0097   TCollection_AsciiString  myName;       //!< entity name
0098   RWGltf_GltfPrimitiveMode myPrimMode;   //!< type of primitive array
0099 
0100 };
0101 
0102 #endif // _RWGltf_GltfLatePrimitiveArray_HeaderFile