|
|
|||
File indexing completed on 2026-09-28 09:19:35
0001 // Copyright (c) 2026 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _BRepGraph_LayerTopoSupplement_HeaderFile 0015 #define _BRepGraph_LayerTopoSupplement_HeaderFile 0016 0017 #include <BRepGraph_Layer.hxx> 0018 #include <NCollection_DataMap.hxx> 0019 #include <NCollection_LinearVector.hxx> 0020 #include <TopoDS_Shape.hxx> 0021 0022 //! @brief Runtime-only storage for supplemental TopoDS topology fragments. 0023 //! 0024 //! This layer stores non-core topology extracted from a source shape and 0025 //! attached to supported core graph owners. These attachments are not 0026 //! serialized and are intended only to preserve live 0027 //! `TopoDS -> Graph -> TopoDS` behavior. 0028 class BRepGraph_LayerTopoSupplement : public BRepGraph_Layer 0029 { 0030 public: 0031 //! @brief Semantic role of one supplemental attachment. 0032 enum class AttachmentKind 0033 { 0034 VertexSupplementShape, 0035 EdgeInternalVertex, 0036 FaceDirectVertex, 0037 SolidAuxShape, 0038 ShellAuxShape, 0039 CompSolidAuxShape, 0040 CompoundAuxShape, 0041 GenericSupplementShape 0042 }; 0043 0044 //! @brief Stored runtime attachment record. 0045 struct Entry 0046 { 0047 BRepGraph_NodeId BaseOwner; 0048 uint64_t LocalUid = 0; 0049 AttachmentKind Kind = AttachmentKind::GenericSupplementShape; 0050 TopoDS_Shape Shape; 0051 }; 0052 0053 //! @brief Return the fixed layer type GUID. 0054 [[nodiscard]] Standard_EXPORT static const Standard_GUID& GetID(); 0055 0056 //! @brief Return the runtime type GUID for this layer instance. 0057 [[nodiscard]] Standard_EXPORT const Standard_GUID& ID() const override; 0058 0059 //! @brief Return a short stable layer name for diagnostics and registry lookup. 0060 [[nodiscard]] Standard_EXPORT const TCollection_AsciiString& Name() const override; 0061 0062 //! @brief Find one attachment entry by its layer-local uid. 0063 //! @param[in] theUid layer-local attachment uid 0064 //! @return pointer to the entry, or `nullptr` when not found 0065 [[nodiscard]] Standard_EXPORT const Entry* FindByUid(uint64_t theUid) const; 0066 0067 //! @brief Return all attachment uids currently owned by one core node. 0068 //! @param[in] theOwner core topology owner node 0069 //! @return owner-local insertion-ordered list of attachment uids 0070 [[nodiscard]] Standard_EXPORT const NCollection_LinearVector<uint64_t>& AttachedTo( 0071 BRepGraph_NodeId theOwner) const; 0072 0073 //! @brief Add one supplemental shape attachment to a supported core owner node. 0074 //! Supported owner kinds are vertex, edge, face, shell, solid, compsolid, and compound. 0075 //! @param[in] theOwner active core topology owner 0076 //! @param[in] theKind semantic attachment kind 0077 //! @param[in] theShape attached supplemental shape 0078 //! @return non-zero layer-local uid on success, `0` on rejection 0079 Standard_EXPORT uint64_t AddAttachment(BRepGraph_NodeId theOwner, 0080 AttachmentKind theKind, 0081 const TopoDS_Shape& theShape); 0082 0083 //! @brief Add one supplemental shape attachment with an explicitly preserved uid. 0084 //! Supported owner kinds are vertex, edge, face, shell, solid, compsolid, and compound. 0085 //! @param[in] theOwner active core topology owner 0086 //! @param[in] theUid layer-local attachment uid to preserve 0087 //! @param[in] theKind semantic attachment kind 0088 //! @param[in] theShape attached supplemental shape 0089 //! @return `true` on success, `false` when the uid or input is rejected 0090 Standard_EXPORT bool AddAttachmentWithUid(BRepGraph_NodeId theOwner, 0091 uint64_t theUid, 0092 AttachmentKind theKind, 0093 const TopoDS_Shape& theShape); 0094 0095 //! @brief Remove one supplemental attachment by uid. 0096 //! @param[in] theUid layer-local attachment uid 0097 //! @return `true` when the attachment existed and was removed 0098 Standard_EXPORT bool RemoveAttachment(uint64_t theUid); 0099 0100 //! @brief Validate internal owner/uid bookkeeping invariants. 0101 //! @throws Standard_ProgramError on inconsistent internal state 0102 Standard_EXPORT void Validate() const; 0103 0104 //! @brief Drop all attachments owned by a removed node. 0105 //! @param[in] theNode removed core node 0106 Standard_EXPORT void OnNodeRemoved(const BRepGraph_NodeId theNode) noexcept override; 0107 0108 //! @brief Migrate attachments from one owner node to another compatible node. 0109 //! @param[in] theOldNode previous owner node 0110 //! @param[in] theNewNode replacement owner node 0111 Standard_EXPORT void OnNodeReplaced(const BRepGraph_NodeId theOldNode, 0112 const BRepGraph_NodeId theNewNode) noexcept override; 0113 0114 //! @brief Copy remapped attachments to the target graph. 0115 Standard_EXPORT void CopyTo(const BRepGraph_CopyRemap& theCopy) const override; 0116 0117 //! @brief Invalidate all cached state in the layer. 0118 Standard_EXPORT void InvalidateAll() noexcept override; 0119 0120 //! @brief Remove every stored supplemental attachment. 0121 Standard_EXPORT void Clear() noexcept override; 0122 0123 DEFINE_STANDARD_RTTIEXT(BRepGraph_LayerTopoSupplement, BRepGraph_Layer) 0124 0125 private: 0126 //! @brief Remove all attachments belonging to one owner node. 0127 //! @param[in] theOwner owner node to erase 0128 void removeOwner(BRepGraph_NodeId theOwner) noexcept; 0129 0130 private: 0131 NCollection_DataMap<uint64_t, Entry> myEntries; 0132 NCollection_DataMap<BRepGraph_NodeId, NCollection_LinearVector<uint64_t>> myOwnerToUids; 0133 NCollection_LinearVector<uint64_t> myEmptyUids; 0134 uint64_t myNextUid = 1; 0135 }; 0136 0137 #endif // _BRepGraph_LayerTopoSupplement_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|