File indexing completed on 2026-09-25 09:20:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _Graphic3d_Layer_HeaderFile
0015 #define _Graphic3d_Layer_HeaderFile
0016
0017 #include <Graphic3d_BvhCStructureSet.hxx>
0018 #include <Graphic3d_BvhCStructureSetTrsfPers.hxx>
0019 #include <Graphic3d_DisplayPriority.hxx>
0020 #include <Graphic3d_ZLayerId.hxx>
0021 #include <Graphic3d_ZLayerSettings.hxx>
0022 #include <Graphic3d_RenderingParams.hxx>
0023 #include <NCollection_Array1.hxx>
0024 #include <NCollection_IndexedMap.hxx>
0025
0026 #include <array>
0027
0028
0029
0030
0031 typedef std::array<NCollection_IndexedMap<const Graphic3d_CStructure*>,
0032 Graphic3d_DisplayPriority_NB>
0033 Graphic3d_ArrayOfIndexedMapOfStructure;
0034
0035 class Graphic3d_CullingTool;
0036
0037
0038 class Graphic3d_Layer : public Standard_Transient
0039 {
0040 DEFINE_STANDARD_RTTIEXT(Graphic3d_Layer, Standard_Transient)
0041 public:
0042
0043 Standard_EXPORT Graphic3d_Layer(Graphic3d_ZLayerId theId,
0044 const occ::handle<BVH_Builder3d>& theBuilder);
0045
0046
0047 Standard_EXPORT ~Graphic3d_Layer() override;
0048
0049
0050 Graphic3d_ZLayerId LayerId() const { return myLayerId; }
0051
0052
0053 const occ::handle<BVH_Builder3d>& FrustumCullingBVHBuilder() const
0054 {
0055 return myBVHPrimitivesTrsfPers.Builder();
0056 }
0057
0058
0059 void SetFrustumCullingBVHBuilder(const occ::handle<BVH_Builder3d>& theBuilder)
0060 {
0061 myBVHPrimitivesTrsfPers.SetBuilder(theBuilder);
0062 }
0063
0064
0065 bool IsImmediate() const { return myLayerSettings.IsImmediate(); }
0066
0067
0068 const Graphic3d_ZLayerSettings& LayerSettings() const { return myLayerSettings; };
0069
0070
0071 Standard_EXPORT void SetLayerSettings(const Graphic3d_ZLayerSettings& theSettings);
0072
0073 Standard_EXPORT void Add(const Graphic3d_CStructure* theStruct,
0074 Graphic3d_DisplayPriority thePriority,
0075 bool isForChangePriority = false);
0076
0077
0078
0079 Standard_EXPORT bool Remove(const Graphic3d_CStructure* theStruct,
0080 Graphic3d_DisplayPriority& thePriority,
0081 bool isForChangePriority = false);
0082
0083
0084 int NbStructures() const { return myNbStructures; }
0085
0086
0087 int NbStructuresNotCulled() const { return myNbStructuresNotCulled; }
0088
0089
0090 int NbPriorities() const { return Graphic3d_DisplayPriority_NB; }
0091
0092
0093
0094 Standard_EXPORT bool Append(const Graphic3d_Layer& theOther);
0095
0096
0097 const Graphic3d_ArrayOfIndexedMapOfStructure& ArrayOfStructures() const { return myArray; }
0098
0099
0100 const NCollection_IndexedMap<const Graphic3d_CStructure*>& Structures(
0101 Graphic3d_DisplayPriority thePriority) const
0102 {
0103 return myArray[thePriority];
0104 }
0105
0106
0107
0108 Standard_EXPORT void InvalidateBVHData();
0109
0110
0111 void InvalidateBoundingBox() const
0112 {
0113 myIsBoundingBoxNeedsReset[0] = myIsBoundingBoxNeedsReset[1] = true;
0114 }
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 Standard_EXPORT Bnd_Box BoundingBox(int theViewId,
0125 const occ::handle<Graphic3d_Camera>& theCamera,
0126 int theWindowWidth,
0127 int theWindowHeight,
0128 bool theToIncludeAuxiliary) const;
0129
0130
0131 Standard_EXPORT double considerZoomPersistenceObjects(
0132 int theViewId,
0133 const occ::handle<Graphic3d_Camera>& theCamera,
0134 int theWindowWidth,
0135 int theWindowHeight) const;
0136
0137
0138
0139 Standard_EXPORT void UpdateCulling(
0140 int theViewId,
0141 const Graphic3d_CullingTool& theSelector,
0142 const Graphic3d_RenderingParams::FrustumCulling theFrustumCullingState);
0143
0144
0145 bool IsCulled() const { return myNbStructuresNotCulled == 0; }
0146
0147
0148 int NbOfTransformPersistenceObjects() const { return myBVHPrimitivesTrsfPers.Size(); }
0149
0150 public:
0151
0152 const Graphic3d_BvhCStructureSet& CullableStructuresBVH() const { return myBVHPrimitives; }
0153
0154
0155 const Graphic3d_BvhCStructureSetTrsfPers& CullableTrsfPersStructuresBVH() const
0156 {
0157 return myBVHPrimitivesTrsfPers;
0158 }
0159
0160
0161 const NCollection_IndexedMap<const Graphic3d_CStructure*>& NonCullableStructures() const
0162 {
0163 return myAlwaysRenderedMap;
0164 }
0165
0166
0167 Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const;
0168
0169 protected:
0170
0171 Standard_EXPORT void updateBVH() const;
0172
0173 private:
0174
0175 Graphic3d_ArrayOfIndexedMapOfStructure myArray;
0176
0177
0178 int myNbStructures;
0179
0180
0181 int myNbStructuresNotCulled;
0182
0183
0184 Graphic3d_ZLayerSettings myLayerSettings;
0185
0186
0187 Graphic3d_ZLayerId myLayerId;
0188
0189
0190 mutable Graphic3d_BvhCStructureSet myBVHPrimitives;
0191
0192
0193 mutable Graphic3d_BvhCStructureSetTrsfPers myBVHPrimitivesTrsfPers;
0194
0195
0196 mutable NCollection_IndexedMap<const Graphic3d_CStructure*> myAlwaysRenderedMap;
0197
0198
0199 bool myBVHIsLeftChildQueuedFirst;
0200
0201
0202 mutable bool myIsBVHPrimitivesNeedsReset;
0203
0204
0205 mutable bool myIsBoundingBoxNeedsReset[2];
0206
0207
0208 mutable Bnd_Box myBoundingBox[2];
0209 };
0210
0211 #endif