File indexing completed on 2025-01-18 10:03:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _Graphic3d_LightSet_HeaderFile
0015 #define _Graphic3d_LightSet_HeaderFile
0016
0017 #include <Graphic3d_CLight.hxx>
0018
0019
0020 class Graphic3d_LightSet : public Standard_Transient
0021 {
0022 DEFINE_STANDARD_RTTIEXT(Graphic3d_LightSet, Standard_Transient)
0023 public:
0024
0025
0026 enum IterationFilter
0027 {
0028 IterationFilter_None = 0x0000,
0029 IterationFilter_ExcludeAmbient = 0x0002,
0030 IterationFilter_ExcludeDisabled = 0x0004,
0031 IterationFilter_ExcludeNoShadow = 0x0008,
0032 IterationFilter_ExcludeDisabledAndAmbient = IterationFilter_ExcludeAmbient | IterationFilter_ExcludeDisabled,
0033 IterationFilter_ActiveShadowCasters = IterationFilter_ExcludeDisabledAndAmbient | IterationFilter_ExcludeNoShadow,
0034 };
0035
0036
0037 class Iterator
0038 {
0039 public:
0040
0041 Iterator() : myFilter (0) {}
0042
0043
0044 Iterator (const Graphic3d_LightSet& theSet,
0045 IterationFilter theFilter = IterationFilter_None)
0046 : myIter (theSet.myLights),
0047 myFilter (theFilter)
0048 {
0049 skipFiltered();
0050 }
0051
0052
0053 Iterator (const Handle(Graphic3d_LightSet)& theSet,
0054 IterationFilter theFilter = IterationFilter_None)
0055 : myFilter (theFilter)
0056 {
0057 if (!theSet.IsNull())
0058 {
0059 myIter = NCollection_IndexedDataMap<Handle(Graphic3d_CLight), Standard_Size>::Iterator (theSet->myLights);
0060 skipFiltered();
0061 }
0062 }
0063
0064
0065 Standard_Boolean More() const { return myIter.More(); }
0066
0067
0068 const Handle(Graphic3d_CLight)& Value() const { return myIter.Key(); }
0069
0070
0071 void Next()
0072 {
0073 myIter.Next();
0074 skipFiltered();
0075 }
0076
0077 protected:
0078
0079
0080 void skipFiltered()
0081 {
0082 if (myFilter == 0)
0083 {
0084 return;
0085 }
0086
0087 for (; myIter.More(); myIter.Next())
0088 {
0089 if ((myFilter & IterationFilter_ExcludeAmbient) != 0
0090 && myIter.Key()->Type() == Graphic3d_TypeOfLightSource_Ambient)
0091 {
0092 continue;
0093 }
0094 else if ((myFilter & IterationFilter_ExcludeDisabled) != 0
0095 && !myIter.Key()->IsEnabled())
0096 {
0097 continue;
0098 }
0099 else if ((myFilter & IterationFilter_ExcludeNoShadow) != 0
0100 && !myIter.Key()->ToCastShadows())
0101 {
0102 continue;
0103 }
0104
0105 break;
0106 }
0107 }
0108
0109 protected:
0110 NCollection_IndexedDataMap<Handle(Graphic3d_CLight), Standard_Size>::Iterator myIter;
0111 Standard_Integer myFilter;
0112 };
0113
0114 public:
0115
0116
0117 Standard_EXPORT Graphic3d_LightSet();
0118
0119
0120 Standard_Integer Lower() const { return 1; }
0121
0122
0123 Standard_Integer Upper() const { return myLights.Extent(); }
0124
0125
0126 Standard_Boolean IsEmpty() const { return myLights.IsEmpty(); }
0127
0128
0129 Standard_Integer Extent() const { return myLights.Extent(); }
0130
0131
0132 const Handle(Graphic3d_CLight)& Value (Standard_Integer theIndex) const { return myLights.FindKey (theIndex); }
0133
0134
0135 Standard_Boolean Contains (const Handle(Graphic3d_CLight)& theLight) const { return myLights.Contains (theLight); }
0136
0137
0138 Standard_EXPORT Standard_Boolean Add (const Handle(Graphic3d_CLight)& theLight);
0139
0140
0141 Standard_EXPORT Standard_Boolean Remove (const Handle(Graphic3d_CLight)& theLight);
0142
0143
0144 Standard_Integer NbLightsOfType (Graphic3d_TypeOfLightSource theType) const { return myLightTypes[theType]; }
0145
0146
0147 public:
0148
0149
0150 Standard_EXPORT Standard_Size UpdateRevision();
0151
0152
0153
0154 Standard_Size Revision() const { return myRevision; }
0155
0156
0157
0158 Standard_Integer NbEnabled() const { return myNbEnabled; }
0159
0160
0161
0162 Standard_Integer NbEnabledLightsOfType (Graphic3d_TypeOfLightSource theType) const { return myLightTypesEnabled[theType]; }
0163
0164
0165
0166 Standard_Integer NbCastShadows() const { return myNbCastShadows; }
0167
0168
0169
0170
0171 const Graphic3d_Vec4& AmbientColor() const { return myAmbient; }
0172
0173
0174
0175
0176
0177 const TCollection_AsciiString& KeyEnabledLong() const { return myKeyEnabledLong; }
0178
0179
0180
0181
0182
0183 const TCollection_AsciiString& KeyEnabledShort() const { return myKeyEnabledShort; }
0184
0185 protected:
0186 NCollection_IndexedDataMap<Handle(Graphic3d_CLight), Standard_Size>
0187 myLights;
0188 Graphic3d_Vec4 myAmbient;
0189 TCollection_AsciiString myKeyEnabledLong;
0190 TCollection_AsciiString myKeyEnabledShort;
0191 Standard_Integer myLightTypes [Graphic3d_TypeOfLightSource_NB];
0192 Standard_Integer myLightTypesEnabled[Graphic3d_TypeOfLightSource_NB];
0193 Standard_Integer myNbEnabled;
0194 Standard_Integer myNbCastShadows;
0195 Standard_Size myRevision;
0196 Standard_Size myCacheRevision;
0197 };
0198
0199 DEFINE_STANDARD_HANDLE(Graphic3d_LightSet, Standard_Transient)
0200
0201 #endif