File indexing completed on 2026-09-28 09:19:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _BRepGraph_LayerLock_HeaderFile
0015 #define _BRepGraph_LayerLock_HeaderFile
0016
0017 #include <BRepGraph_ItemId.hxx>
0018 #include <BRepGraph_Layer.hxx>
0019 #include <NCollection_FlatDataMap.hxx>
0020 #include <TCollection_AsciiString.hxx>
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 class BRepGraph_LayerLock : public BRepGraph_Layer
0035 {
0036 public:
0037
0038
0039
0040
0041
0042 class ScopedOwnerEdit
0043 {
0044 public:
0045 Standard_EXPORT ScopedOwnerEdit(BRepGraph_LayerLock& theLayer,
0046 const BRepGraph_ItemId theItem,
0047 const Standard_GUID& theOwnerId);
0048 Standard_EXPORT ~ScopedOwnerEdit();
0049
0050 ScopedOwnerEdit(const ScopedOwnerEdit&) = delete;
0051 ScopedOwnerEdit& operator=(const ScopedOwnerEdit&) = delete;
0052
0053 Standard_EXPORT ScopedOwnerEdit(ScopedOwnerEdit&& theOther) noexcept;
0054 Standard_EXPORT ScopedOwnerEdit& operator=(ScopedOwnerEdit&& theOther) noexcept;
0055
0056 private:
0057 BRepGraph_LayerLock* myLayer = nullptr;
0058 BRepGraph_ItemId myItem;
0059 bool myIsActive = false;
0060 };
0061
0062
0063 Standard_EXPORT BRepGraph_LayerLock();
0064
0065
0066 [[nodiscard]] Standard_EXPORT static const Standard_GUID& GetID();
0067
0068
0069 [[nodiscard]] Standard_EXPORT const Standard_GUID& ID() const override;
0070
0071
0072
0073
0074 [[nodiscard]] Standard_EXPORT bool FindOwnerId(const BRepGraph_ItemId theItem,
0075 Standard_GUID& theOwnerId) const;
0076
0077
0078 [[nodiscard]] bool FindOwnerId(const BRepGraph_NodeId theNode, Standard_GUID& theOwnerId) const
0079 {
0080 return FindOwnerId(BRepGraph_ItemId(theNode), theOwnerId);
0081 }
0082
0083
0084 [[nodiscard]] bool FindOwnerId(const BRepGraph_RefId theRef, Standard_GUID& theOwnerId) const
0085 {
0086 return FindOwnerId(BRepGraph_ItemId(theRef), theOwnerId);
0087 }
0088
0089
0090
0091 [[nodiscard]] Standard_EXPORT bool HasOwner(const BRepGraph_ItemId theItem) const;
0092
0093
0094 [[nodiscard]] bool HasOwner(const BRepGraph_NodeId theNode) const
0095 {
0096 return HasOwner(BRepGraph_ItemId(theNode));
0097 }
0098
0099
0100 [[nodiscard]] bool HasOwner(const BRepGraph_RefId theRef) const
0101 {
0102 return HasOwner(BRepGraph_ItemId(theRef));
0103 }
0104
0105
0106
0107
0108 Standard_EXPORT void SetOwner(const BRepGraph_ItemId theItem, const Standard_GUID& theOwnerId);
0109
0110
0111
0112 Standard_EXPORT bool SetOwner(const BRepGraph_ItemId theItem,
0113 const Standard_GUID& theOwnerId,
0114 const bool theToUpdateRevision);
0115
0116
0117 void SetOwner(const BRepGraph_NodeId theNode, const Standard_GUID& theOwnerId)
0118 {
0119 SetOwner(BRepGraph_ItemId(theNode), theOwnerId);
0120 }
0121
0122
0123 void SetOwner(const BRepGraph_RefId theRef, const Standard_GUID& theOwnerId)
0124 {
0125 SetOwner(BRepGraph_ItemId(theRef), theOwnerId);
0126 }
0127
0128
0129
0130 Standard_EXPORT void UnsetOwner(const BRepGraph_ItemId theItem);
0131
0132
0133 Standard_EXPORT void UnsetOwner(const BRepGraph_ItemId theItem, const Standard_GUID& theOwnerId);
0134
0135
0136 void UnsetOwner(const BRepGraph_NodeId theNode) { UnsetOwner(BRepGraph_ItemId(theNode)); }
0137
0138
0139 void UnsetOwner(const BRepGraph_RefId theRef) { UnsetOwner(BRepGraph_ItemId(theRef)); }
0140
0141
0142 [[nodiscard]] bool HasOwners() const
0143 {
0144 return myNodeOwners.Extent() != 0 || myRefOwners.Extent() != 0;
0145 }
0146
0147
0148 Standard_EXPORT void ReserveOwners(const size_t theNbOwners);
0149
0150
0151 Standard_EXPORT void TouchOwners();
0152
0153 Standard_EXPORT const TCollection_AsciiString& Name() const override;
0154 Standard_EXPORT void OnNodeRemoved(const BRepGraph_NodeId theNode) noexcept override;
0155 Standard_EXPORT void OnNodeReplaced(const BRepGraph_NodeId theOldNode,
0156 const BRepGraph_NodeId theNewNode) noexcept override;
0157 Standard_EXPORT void CopyTo(const BRepGraph_CopyRemap& theCopy) const override;
0158 Standard_EXPORT void OnRefRemoved(const BRepGraph_RefId theRef) noexcept override;
0159 Standard_EXPORT void InvalidateAll() noexcept override;
0160 Standard_EXPORT void Clear() noexcept override;
0161
0162 DEFINE_STANDARD_RTTIEXT(BRepGraph_LayerLock, BRepGraph_Layer)
0163
0164 private:
0165
0166 Standard_EXPORT void setItemOwned(const BRepGraph_ItemId theItem, const bool theIsOwned) const;
0167
0168
0169
0170 void expandOwnership(const BRepGraph_NodeId theRoot, const bool theIsOwned);
0171
0172
0173 void rebuildOwnedFlagsFromRoots();
0174
0175
0176
0177 [[nodiscard]] bool findRootNodeId(const BRepGraph_NodeId theNode,
0178 BRepGraph_ItemId& theRootItem) const;
0179
0180
0181
0182 [[nodiscard]] bool findRootRefId(const BRepGraph_RefId theRef,
0183 BRepGraph_ItemId& theRootItem) const;
0184
0185
0186 [[nodiscard]] BRepGraph_NodeId parentNodeId(const BRepGraph_RefId theRef) const;
0187
0188
0189
0190 [[nodiscard]] bool isCoveredByAncestor(const BRepGraph_ItemId theItem,
0191 Standard_GUID& theRootOwnerId) const;
0192
0193
0194 void removeRootEntry(const BRepGraph_ItemId theItem) noexcept;
0195
0196 NCollection_FlatDataMap<BRepGraph_ItemId, Standard_GUID> myNodeOwners;
0197 NCollection_FlatDataMap<BRepGraph_ItemId, Standard_GUID> myRefOwners;
0198 };
0199
0200 #endif