File indexing completed on 2025-01-18 10:04:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef OpenGl_LayerList_HeaderFile
0017 #define OpenGl_LayerList_HeaderFile
0018
0019 #include <OpenGl_Layer.hxx>
0020 #include <OpenGl_LayerFilter.hxx>
0021
0022 #include <Graphic3d_ZLayerId.hxx>
0023 #include <NCollection_Array1.hxx>
0024 #include <NCollection_Handle.hxx>
0025 #include <NCollection_DataMap.hxx>
0026
0027 class OpenGl_FrameBuffer;
0028 class OpenGl_Structure;
0029 class OpenGl_Workspace;
0030 struct OpenGl_GlobalLayerSettings;
0031
0032
0033 class OpenGl_LayerList
0034 {
0035 public:
0036
0037
0038 Standard_EXPORT OpenGl_LayerList();
0039
0040
0041 Standard_EXPORT virtual ~OpenGl_LayerList();
0042
0043
0044 Standard_Integer NbPriorities() const { return Graphic3d_DisplayPriority_NB; }
0045
0046
0047 Standard_Integer NbStructures() const { return myNbStructures; }
0048
0049
0050 Standard_Integer NbImmediateStructures() const { return myImmediateNbStructures; }
0051
0052
0053 Standard_EXPORT void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
0054 const Graphic3d_ZLayerSettings& theSettings,
0055 const Graphic3d_ZLayerId theLayerAfter);
0056
0057
0058 Standard_EXPORT void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
0059 const Graphic3d_ZLayerSettings& theSettings,
0060 const Graphic3d_ZLayerId theLayerBefore);
0061
0062
0063 Standard_EXPORT void RemoveLayer (const Graphic3d_ZLayerId theLayerId);
0064
0065
0066
0067
0068 Standard_EXPORT void AddStructure (const OpenGl_Structure* theStruct,
0069 const Graphic3d_ZLayerId theLayerId,
0070 const Graphic3d_DisplayPriority thePriority,
0071 Standard_Boolean isForChangePriority = Standard_False);
0072
0073
0074 Standard_EXPORT void RemoveStructure (const OpenGl_Structure* theStructure);
0075
0076
0077
0078
0079 Standard_EXPORT void ChangeLayer (const OpenGl_Structure* theStructure,
0080 const Graphic3d_ZLayerId theOldLayerId,
0081 const Graphic3d_ZLayerId theNewLayerId);
0082
0083
0084 Standard_EXPORT void ChangePriority (const OpenGl_Structure* theStructure,
0085 const Graphic3d_ZLayerId theLayerId,
0086 const Graphic3d_DisplayPriority theNewPriority);
0087
0088
0089 OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) { return *myLayerIds.Find (theLayerId); }
0090
0091
0092 const OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) const { return *myLayerIds.Find (theLayerId); }
0093
0094
0095 Standard_EXPORT void SetLayerSettings (const Graphic3d_ZLayerId theLayerId,
0096 const Graphic3d_ZLayerSettings& theSettings);
0097
0098
0099 Standard_EXPORT void UpdateCulling (const Handle(OpenGl_Workspace)& theWorkspace,
0100 const Standard_Boolean theToDrawImmediate);
0101
0102
0103 Standard_EXPORT void Render (const Handle(OpenGl_Workspace)& theWorkspace,
0104 const Standard_Boolean theToDrawImmediate,
0105 const OpenGl_LayerFilter theLayersToProcess,
0106 OpenGl_FrameBuffer* theReadDrawFbo,
0107 OpenGl_FrameBuffer* theOitAccumFbo) const;
0108
0109
0110 const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const { return myLayers; }
0111
0112
0113 const NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)>& LayerIDs() const { return myLayerIds; }
0114
0115
0116
0117 Standard_EXPORT void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId);
0118
0119
0120 Standard_Size ModificationStateOfRaytracable() const { return myModifStateOfRaytraceable; }
0121
0122
0123 const Handle(Select3D_BVHBuilder3d)& FrustumCullingBVHBuilder() const { return myBVHBuilder; }
0124
0125
0126 Standard_EXPORT void SetFrustumCullingBVHBuilder (const Handle(Select3D_BVHBuilder3d)& theBuilder);
0127
0128
0129 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0130
0131 protected:
0132
0133
0134 class OpenGl_LayerStack
0135 {
0136 public:
0137 typedef NCollection_Array1<const Graphic3d_Layer*>::const_iterator const_iterator;
0138 typedef NCollection_Array1<const Graphic3d_Layer*>::iterator iterator;
0139
0140
0141 void Allocate (Standard_Integer theSize)
0142 {
0143 if (theSize > 0)
0144 {
0145 myStackSpace.Resize (1, theSize, false);
0146 myStackSpace.Init (NULL);
0147 myBackPtr = myStackSpace.begin();
0148 }
0149 else
0150 {
0151 NCollection_Array1<const Graphic3d_Layer*> aDummy;
0152 myStackSpace.Move (std::move(aDummy));
0153 myBackPtr = iterator();
0154 }
0155 }
0156
0157
0158 void Clear()
0159 {
0160 myStackSpace.Init (NULL);
0161 myBackPtr = myStackSpace.begin();
0162 }
0163
0164
0165 void Push (const OpenGl_Layer* theLayer) { (*myBackPtr++) = theLayer; }
0166
0167
0168 const_iterator Origin() const { return myStackSpace.IsEmpty() ? const_iterator() : myStackSpace.begin(); }
0169
0170
0171 iterator Back() const { return myBackPtr; }
0172
0173
0174 iterator Origin() { return myStackSpace.IsEmpty() ? iterator() : myStackSpace.begin(); }
0175
0176
0177 Standard_Boolean IsEmpty() const { return Back() == Origin(); }
0178
0179 private:
0180
0181 NCollection_Array1<const OpenGl_Layer*> myStackSpace;
0182 iterator myBackPtr;
0183 };
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194 Standard_EXPORT void renderTransparent (const Handle(OpenGl_Workspace)& theWorkspace,
0195 OpenGl_LayerStack::iterator& theLayerIter,
0196 const OpenGl_GlobalLayerSettings& theGlobalSettings,
0197 OpenGl_FrameBuffer* theReadDrawFbo,
0198 OpenGl_FrameBuffer* theOitAccumFbo) const;
0199
0200
0201 Standard_EXPORT void renderLayer (const Handle(OpenGl_Workspace)& theWorkspace,
0202 const OpenGl_GlobalLayerSettings& theDefaultSettings,
0203 const Graphic3d_Layer& theLayer) const;
0204
0205 protected:
0206
0207 NCollection_List<Handle(Graphic3d_Layer)> myLayers;
0208 NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)> myLayerIds;
0209 Handle(Select3D_BVHBuilder3d) myBVHBuilder;
0210
0211 Standard_Integer myNbStructures;
0212 Standard_Integer myImmediateNbStructures;
0213
0214 mutable Standard_Size myModifStateOfRaytraceable;
0215
0216
0217 mutable OpenGl_LayerStack myTransparentToProcess;
0218
0219 public:
0220
0221 DEFINE_STANDARD_ALLOC
0222
0223 };
0224
0225 #endif