1 // Author: Kirill Gavrilov
2 // Copyright (c) 2018-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_GltfLatePrimitiveArray_HeaderFile
16 #define _RWGltf_GltfLatePrimitiveArray_HeaderFile
18 #include <Bnd_Box.hxx>
19 #include <NCollection_Sequence.hxx>
20 #include <Poly_Triangulation.hxx>
21 #include <RWGltf_GltfPrimArrayData.hxx>
22 #include <RWGltf_GltfPrimitiveMode.hxx>
23 #include <Quantity_ColorRGBA.hxx>
25 class RWGltf_MaterialMetallicRoughness;
26 class RWGltf_MaterialCommon;
28 //! Mesh data wrapper for delayed primitive array loading from glTF file.
29 //! Class inherits Poly_Triangulation so that it can be put temporarily into TopoDS_Face within assembly structure,
30 //! to be replaced with proper Poly_Triangulation loaded later on.
31 class RWGltf_GltfLatePrimitiveArray : public Poly_Triangulation
33 DEFINE_STANDARD_RTTIEXT(RWGltf_GltfLatePrimitiveArray, Poly_Triangulation)
37 Standard_EXPORT RWGltf_GltfLatePrimitiveArray (const TCollection_AsciiString& theId,
38 const TCollection_AsciiString& theName);
41 Standard_EXPORT virtual ~RWGltf_GltfLatePrimitiveArray();
44 const TCollection_AsciiString& Id() const { return myId; }
47 const TCollection_AsciiString& Name() const { return myName; }
49 //! Assign entity name.
50 void SetName (const TCollection_AsciiString& theName) { myName = theName; }
52 //! Return type of primitive array.
53 RWGltf_GltfPrimitiveMode PrimitiveMode() const { return myPrimMode; }
55 //! Set type of primitive array.
56 void SetPrimitiveMode (RWGltf_GltfPrimitiveMode theMode) { myPrimMode = theMode; }
58 //! Return true if primitive array has assigned material
59 bool HasStyle() const { return !myMaterialPbr.IsNull() || !myMaterialCommon.IsNull(); }
61 //! Return base color.
62 Standard_EXPORT Quantity_ColorRGBA BaseColor() const;
64 //! Return PBR material definition.
65 const Handle(RWGltf_MaterialMetallicRoughness)& MaterialPbr() const { return myMaterialPbr; }
67 //! Set PBR material definition.
68 void SetMaterialPbr (const Handle(RWGltf_MaterialMetallicRoughness)& theMat) { myMaterialPbr = theMat; }
70 //! Return common (obsolete) material definition.
71 const Handle(RWGltf_MaterialCommon)& MaterialCommon() const { return myMaterialCommon; }
73 //! Set common (obsolete) material definition.
74 void SetMaterialCommon (const Handle(RWGltf_MaterialCommon)& theMat) { myMaterialCommon = theMat; }
76 //! Return primitive array data elements.
77 const NCollection_Sequence<RWGltf_GltfPrimArrayData>& Data() const { return myData; }
79 //! Add primitive array data element.
80 Standard_EXPORT RWGltf_GltfPrimArrayData& AddPrimArrayData (RWGltf_GltfArrayType theType);
82 //! This method sets input bounding box and assigns a FAKE data to underlying Poly_Triangulation
83 //! as Min/Max corners of bounding box, so that standard tools like BRepBndLib::Add()
84 //! can be used transparently for computing bounding box of this face.
85 Standard_EXPORT void SetBoundingBox (const Bnd_Box& theBox);
89 NCollection_Sequence<RWGltf_GltfPrimArrayData> myData;
90 Handle(RWGltf_MaterialMetallicRoughness) myMaterialPbr; //!< PBR material
91 Handle(RWGltf_MaterialCommon) myMaterialCommon; //!< common (obsolete) material
92 Bnd_Box myBox; //!< bounding box
93 TCollection_AsciiString myId; //!< entity id
94 TCollection_AsciiString myName; //!< entity name
95 RWGltf_GltfPrimitiveMode myPrimMode; //!< type of primitive array
99 #endif // _RWGltf_GltfLatePrimitiveArray_HeaderFile