0030811: Data Exchange, RWGltf_CafReader - fix inaccessibility of properties
[occt.git] / src / RWGltf / RWGltf_GltfLatePrimitiveArray.hxx
CommitLineData
0a419c51 1// Author: Kirill Gavrilov
2// Copyright (c) 2018-2019 OPEN CASCADE SAS
3//
4// This file is part of Open CASCADE Technology software library.
5//
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.
11//
12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
14
15#ifndef _RWGltf_GltfLatePrimitiveArray_HeaderFile
16#define _RWGltf_GltfLatePrimitiveArray_HeaderFile
17
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>
24
25class RWGltf_MaterialMetallicRoughness;
26class RWGltf_MaterialCommon;
27
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.
31class RWGltf_GltfLatePrimitiveArray : public Poly_Triangulation
32{
33 DEFINE_STANDARD_RTTIEXT(RWGltf_GltfLatePrimitiveArray, Poly_Triangulation)
34public:
35
36 //! Constructor.
37 Standard_EXPORT RWGltf_GltfLatePrimitiveArray (const TCollection_AsciiString& theId,
38 const TCollection_AsciiString& theName);
39
40 //! Destructor.
41 Standard_EXPORT virtual ~RWGltf_GltfLatePrimitiveArray();
42
43 //! Entity id.
44 const TCollection_AsciiString& Id() const { return myId; }
45
46 //! Entity name.
47 const TCollection_AsciiString& Name() const { return myName; }
48
49 //! Assign entity name.
50 void SetName (const TCollection_AsciiString& theName) { myName = theName; }
51
52 //! Return type of primitive array.
53 RWGltf_GltfPrimitiveMode PrimitiveMode() const { return myPrimMode; }
54
55 //! Set type of primitive array.
56 void SetPrimitiveMode (RWGltf_GltfPrimitiveMode theMode) { myPrimMode = theMode; }
57
58 //! Return true if primitive array has assigned material
59 bool HasStyle() const { return !myMaterialPbr.IsNull() || !myMaterialCommon.IsNull(); }
60
61 //! Return base color.
62 Standard_EXPORT Quantity_ColorRGBA BaseColor() const;
63
64 //! Return PBR material definition.
65 const Handle(RWGltf_MaterialMetallicRoughness)& MaterialPbr() const { return myMaterialPbr; }
66
67 //! Set PBR material definition.
68 void SetMaterialPbr (const Handle(RWGltf_MaterialMetallicRoughness)& theMat) { myMaterialPbr = theMat; }
69
70 //! Return common (obsolete) material definition.
71 const Handle(RWGltf_MaterialCommon)& MaterialCommon() const { return myMaterialCommon; }
72
73 //! Set common (obsolete) material definition.
74 void SetMaterialCommon (const Handle(RWGltf_MaterialCommon)& theMat) { myMaterialCommon = theMat; }
75
76 //! Return primitive array data elements.
77 const NCollection_Sequence<RWGltf_GltfPrimArrayData>& Data() const { return myData; }
78
79 //! Add primitive array data element.
80 Standard_EXPORT RWGltf_GltfPrimArrayData& AddPrimArrayData (RWGltf_GltfArrayType theType);
81
82c59511 82 //! Return bounding box defined within glTF file, or VOID if not specified.
83 const Bnd_Box& BoundingBox() const { return myBox; }
84
0a419c51 85 //! This method sets input bounding box and assigns a FAKE data to underlying Poly_Triangulation
86 //! as Min/Max corners of bounding box, so that standard tools like BRepBndLib::Add()
87 //! can be used transparently for computing bounding box of this face.
88 Standard_EXPORT void SetBoundingBox (const Bnd_Box& theBox);
89
82c59511 90protected:
0a419c51 91
92 NCollection_Sequence<RWGltf_GltfPrimArrayData> myData;
93 Handle(RWGltf_MaterialMetallicRoughness) myMaterialPbr; //!< PBR material
94 Handle(RWGltf_MaterialCommon) myMaterialCommon; //!< common (obsolete) material
95 Bnd_Box myBox; //!< bounding box
96 TCollection_AsciiString myId; //!< entity id
97 TCollection_AsciiString myName; //!< entity name
98 RWGltf_GltfPrimitiveMode myPrimMode; //!< type of primitive array
99
100};
101
102#endif // _RWGltf_GltfLatePrimitiveArray_HeaderFile