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_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 typedef NCollection_IndexedMap<const Graphic3d_CStructure*> Graphic3d_IndexedMapOfStructure;
0030
0031
0032 typedef std::array<Graphic3d_IndexedMapOfStructure, Graphic3d_DisplayPriority_NB> Graphic3d_ArrayOfIndexedMapOfStructure;
0033
0034 class Graphic3d_CullingTool;
0035
0036
0037 class Graphic3d_Layer : public Standard_Transient
0038 {
0039 DEFINE_STANDARD_RTTIEXT(Graphic3d_Layer, Standard_Transient)
0040 public:
0041
0042
0043 Standard_EXPORT Graphic3d_Layer (Graphic3d_ZLayerId theId,
0044 const Handle(Select3D_BVHBuilder3d)& theBuilder);
0045
0046
0047 Standard_EXPORT virtual ~Graphic3d_Layer();
0048
0049
0050 Graphic3d_ZLayerId LayerId() const { return myLayerId; }
0051
0052
0053 const Handle(Select3D_BVHBuilder3d)& FrustumCullingBVHBuilder() const { return myBVHPrimitivesTrsfPers.Builder(); }
0054
0055
0056 void SetFrustumCullingBVHBuilder (const Handle(Select3D_BVHBuilder3d)& theBuilder) { myBVHPrimitivesTrsfPers.SetBuilder (theBuilder); }
0057
0058
0059 Standard_Boolean IsImmediate() const { return myLayerSettings.IsImmediate(); }
0060
0061
0062 const Graphic3d_ZLayerSettings& LayerSettings() const { return myLayerSettings; };
0063
0064
0065 Standard_EXPORT void SetLayerSettings (const Graphic3d_ZLayerSettings& theSettings);
0066
0067 Standard_EXPORT void Add (const Graphic3d_CStructure* theStruct,
0068 Graphic3d_DisplayPriority thePriority,
0069 Standard_Boolean isForChangePriority = Standard_False);
0070
0071
0072 Standard_EXPORT bool Remove (const Graphic3d_CStructure* theStruct,
0073 Graphic3d_DisplayPriority& thePriority,
0074 Standard_Boolean isForChangePriority = Standard_False);
0075
0076
0077 Standard_Integer NbStructures() const { return myNbStructures; }
0078
0079
0080 Standard_Integer NbStructuresNotCulled() const { return myNbStructuresNotCulled; }
0081
0082
0083 Standard_Integer NbPriorities() const { return Graphic3d_DisplayPriority_NB; }
0084
0085
0086
0087 Standard_EXPORT Standard_Boolean Append (const Graphic3d_Layer& theOther);
0088
0089
0090 const Graphic3d_ArrayOfIndexedMapOfStructure& ArrayOfStructures() const { return myArray; }
0091
0092
0093 const Graphic3d_IndexedMapOfStructure& Structures (Graphic3d_DisplayPriority thePriority) const { return myArray[thePriority]; }
0094
0095
0096
0097 Standard_EXPORT void InvalidateBVHData();
0098
0099
0100 void InvalidateBoundingBox() const
0101 {
0102 myIsBoundingBoxNeedsReset[0] = myIsBoundingBoxNeedsReset[1] = true;
0103 }
0104
0105
0106
0107
0108
0109
0110
0111
0112 Standard_EXPORT Bnd_Box BoundingBox (Standard_Integer theViewId,
0113 const Handle(Graphic3d_Camera)& theCamera,
0114 Standard_Integer theWindowWidth,
0115 Standard_Integer theWindowHeight,
0116 Standard_Boolean theToIncludeAuxiliary) const;
0117
0118
0119 Standard_EXPORT Standard_Real considerZoomPersistenceObjects (Standard_Integer theViewId,
0120 const Handle(Graphic3d_Camera)& theCamera,
0121 Standard_Integer theWindowWidth,
0122 Standard_Integer theWindowHeight) const;
0123
0124
0125
0126 Standard_EXPORT void UpdateCulling (Standard_Integer theViewId,
0127 const Graphic3d_CullingTool& theSelector,
0128 const Graphic3d_RenderingParams::FrustumCulling theFrustumCullingState);
0129
0130
0131 bool IsCulled() const { return myNbStructuresNotCulled == 0; }
0132
0133
0134 Standard_Integer NbOfTransformPersistenceObjects() const
0135 {
0136 return myBVHPrimitivesTrsfPers.Size();
0137 }
0138
0139 public:
0140
0141
0142 const Graphic3d_BvhCStructureSet& CullableStructuresBVH() const { return myBVHPrimitives; }
0143
0144
0145 const Graphic3d_BvhCStructureSetTrsfPers& CullableTrsfPersStructuresBVH() const { return myBVHPrimitivesTrsfPers; }
0146
0147
0148 const NCollection_IndexedMap<const Graphic3d_CStructure*>& NonCullableStructures() const { return myAlwaysRenderedMap; }
0149
0150
0151 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0152
0153 protected:
0154
0155
0156 Standard_EXPORT void updateBVH() const;
0157
0158 private:
0159
0160
0161 Graphic3d_ArrayOfIndexedMapOfStructure myArray;
0162
0163
0164 Standard_Integer myNbStructures;
0165
0166
0167 Standard_Integer myNbStructuresNotCulled;
0168
0169
0170 Graphic3d_ZLayerSettings myLayerSettings;
0171
0172
0173 Graphic3d_ZLayerId myLayerId;
0174
0175
0176 mutable Graphic3d_BvhCStructureSet myBVHPrimitives;
0177
0178
0179 mutable Graphic3d_BvhCStructureSetTrsfPers myBVHPrimitivesTrsfPers;
0180
0181
0182 mutable NCollection_IndexedMap<const Graphic3d_CStructure*> myAlwaysRenderedMap;
0183
0184
0185 Standard_Boolean myBVHIsLeftChildQueuedFirst;
0186
0187
0188 mutable Standard_Boolean myIsBVHPrimitivesNeedsReset;
0189
0190
0191 mutable bool myIsBoundingBoxNeedsReset[2];
0192
0193
0194 mutable Bnd_Box myBoundingBox[2];
0195
0196 };
0197
0198 #endif