File indexing completed on 2025-01-18 10:05:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _XCAFDoc_VisMaterial_HeaderFile
0015 #define _XCAFDoc_VisMaterial_HeaderFile
0016
0017 #include <Graphic3d_AlphaMode.hxx>
0018 #include <Graphic3d_TypeOfBackfacingModel.hxx>
0019 #include <TCollection_HAsciiString.hxx>
0020 #include <TDF_Attribute.hxx>
0021 #include <XCAFDoc_VisMaterialCommon.hxx>
0022 #include <XCAFDoc_VisMaterialPBR.hxx>
0023
0024 class Graphic3d_Aspects;
0025 class Graphic3d_MaterialAspect;
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 class XCAFDoc_VisMaterial : public TDF_Attribute
0052 {
0053 DEFINE_STANDARD_RTTIEXT(XCAFDoc_VisMaterial, TDF_Attribute)
0054 public:
0055
0056
0057 Standard_EXPORT static const Standard_GUID& GetID();
0058
0059 public:
0060
0061
0062 Standard_EXPORT XCAFDoc_VisMaterial();
0063
0064
0065 bool IsEmpty() const { return !myPbrMat.IsDefined && !myCommonMat.IsDefined; }
0066
0067
0068 Standard_EXPORT void FillMaterialAspect (Graphic3d_MaterialAspect& theAspect) const;
0069
0070
0071 Standard_EXPORT void FillAspect (const Handle(Graphic3d_Aspects)& theAspect) const;
0072
0073
0074 Standard_Boolean HasPbrMaterial() const { return myPbrMat.IsDefined; }
0075
0076
0077
0078 const XCAFDoc_VisMaterialPBR& PbrMaterial() const { return myPbrMat; }
0079
0080
0081 Standard_EXPORT void SetPbrMaterial (const XCAFDoc_VisMaterialPBR& theMaterial);
0082
0083
0084 void UnsetPbrMaterial()
0085 {
0086 XCAFDoc_VisMaterialPBR anEmpty;
0087 anEmpty.IsDefined = false;
0088 SetPbrMaterial (anEmpty);
0089 }
0090
0091
0092 Standard_Boolean HasCommonMaterial() const { return myCommonMat.IsDefined; }
0093
0094
0095
0096 const XCAFDoc_VisMaterialCommon& CommonMaterial() const { return myCommonMat; }
0097
0098
0099 Standard_EXPORT void SetCommonMaterial (const XCAFDoc_VisMaterialCommon& theMaterial);
0100
0101
0102 void UnsetCommonMaterial()
0103 {
0104 XCAFDoc_VisMaterialCommon anEmpty;
0105 anEmpty.IsDefined = false;
0106 SetCommonMaterial (anEmpty);
0107 }
0108
0109
0110 Standard_EXPORT Quantity_ColorRGBA BaseColor() const;
0111
0112
0113 Graphic3d_AlphaMode AlphaMode() const { return myAlphaMode; }
0114
0115
0116 Standard_ShortReal AlphaCutOff() const { return myAlphaCutOff; }
0117
0118
0119 Standard_EXPORT void SetAlphaMode (Graphic3d_AlphaMode theMode,
0120 Standard_ShortReal theCutOff = 0.5f);
0121
0122
0123 Graphic3d_TypeOfBackfacingModel FaceCulling() const { return myFaceCulling; }
0124
0125
0126 Standard_EXPORT void SetFaceCulling (Graphic3d_TypeOfBackfacingModel theFaceCulling);
0127
0128 Standard_DEPRECATED("Deprecated method, FaceCulling() should be used instead")
0129 Standard_Boolean IsDoubleSided() const { return myFaceCulling == Graphic3d_TypeOfBackfacingModel_DoubleSided; }
0130
0131 Standard_DEPRECATED("Deprecated method, SetFaceCulling() should be used instead")
0132 void SetDoubleSided (Standard_Boolean theIsDoubleSided)
0133 {
0134 SetFaceCulling (theIsDoubleSided ? Graphic3d_TypeOfBackfacingModel_DoubleSided : Graphic3d_TypeOfBackfacingModel_Auto);
0135 }
0136
0137
0138 const Handle(TCollection_HAsciiString)& RawName() const { return myRawName; }
0139
0140
0141 void SetRawName (const Handle(TCollection_HAsciiString)& theName) { myRawName = theName; }
0142
0143
0144
0145 Standard_Boolean IsEqual (const Handle(XCAFDoc_VisMaterial)& theOther) const
0146 {
0147 if (theOther.get() == this)
0148 {
0149 return true;
0150 }
0151 return theOther->myFaceCulling == myFaceCulling
0152 && theOther->myAlphaCutOff == myAlphaCutOff
0153 && theOther->myAlphaMode == myAlphaMode
0154 && theOther->myCommonMat.IsEqual (myCommonMat)
0155 && theOther->myPbrMat.IsEqual (myPbrMat);
0156 }
0157
0158
0159 Standard_EXPORT XCAFDoc_VisMaterialCommon ConvertToCommonMaterial();
0160
0161
0162 Standard_EXPORT XCAFDoc_VisMaterialPBR ConvertToPbrMaterial();
0163
0164 public:
0165
0166
0167 virtual const Standard_GUID& ID() const Standard_OVERRIDE { return GetID(); }
0168
0169
0170
0171 Standard_EXPORT virtual void Restore (const Handle(TDF_Attribute)& theWith) Standard_OVERRIDE;
0172
0173
0174 Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
0175
0176
0177
0178
0179 Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theInto,
0180 const Handle(TDF_RelocationTable)& theRelTable) const Standard_OVERRIDE;
0181
0182
0183 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0184
0185 private:
0186
0187 Handle(TCollection_HAsciiString) myRawName;
0188 XCAFDoc_VisMaterialPBR myPbrMat;
0189 XCAFDoc_VisMaterialCommon myCommonMat;
0190 Graphic3d_AlphaMode myAlphaMode;
0191 Standard_ShortReal myAlphaCutOff;
0192 Graphic3d_TypeOfBackfacingModel myFaceCulling;
0193
0194 };
0195
0196 DEFINE_STANDARD_HANDLE(XCAFDoc_VisMaterial, TDF_Attribute)
0197
0198 #endif