Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:19:37

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_SupplementIterator_HeaderFile
0015 #define _BRepGraph_SupplementIterator_HeaderFile
0016 
0017 #include <BRepGraph.hxx>
0018 #include <BRepGraph_LayerRegistry.hxx>
0019 #include <BRepGraph_LayerTopoSupplement.hxx>
0020 #include <NCollection_ForwardRange.hxx>
0021 
0022 //! @brief Iterator over supplemental TopoDS attachments owned by one core node.
0023 //!
0024 //! The iterator resolves `BRepGraph_LayerTopoSupplement` through the graph layer
0025 //! registry and yields only explicit supplement attachments. Core traversal
0026 //! remains core-only and does not surface these entries.
0027 class BRepGraph_SupplementIterator
0028 {
0029 public:
0030   //! @brief Construct an iterator over supplement attachments of one owner.
0031   //! @param[in] theGraph graph providing the supplement layer
0032   //! @param[in] theOwner core owner node whose attachments should be iterated
0033   explicit BRepGraph_SupplementIterator(const BRepGraph& theGraph, const BRepGraph_NodeId theOwner)
0034       : myLayer(theGraph.LayerRegistry().FindLayer<BRepGraph_LayerTopoSupplement>()),
0035         myUids(myLayer.IsNull() ? nullptr : &myLayer->AttachedTo(theOwner))
0036   {
0037     skipInvalid();
0038   }
0039 
0040   //! @brief Return true when the iterator currently points to an attachment.
0041   [[nodiscard]] bool More() const
0042   {
0043     return myUids != nullptr && myEntry != nullptr && myIndex < myUids->Size();
0044   }
0045 
0046   //! @brief Advance to the next attachment.
0047   void Next()
0048   {
0049     ++myIndex;
0050     skipInvalid();
0051   }
0052 
0053   //! @brief Return the current layer-local attachment uid.
0054   [[nodiscard]] uint64_t Uid() const { return More() ? myUids->Value(myIndex) : uint64_t(0); }
0055 
0056   //! @brief Return the current attachment entry.
0057   [[nodiscard]] const BRepGraph_LayerTopoSupplement::Entry& Value() const { return *myEntry; }
0058 
0059   //! @brief STL range-for support.
0060   NCollection_ForwardRangeIterator<BRepGraph_SupplementIterator> begin()
0061   {
0062     return NCollection_ForwardRangeIterator<BRepGraph_SupplementIterator>(this);
0063   }
0064 
0065   //! @brief Sentinel marking end of iteration.
0066   NCollection_ForwardRangeSentinel end() const { return NCollection_ForwardRangeSentinel{}; }
0067 
0068 private:
0069   //! @brief Skip missing entries in owner-local uid storage.
0070   Standard_EXPORT void skipInvalid();
0071 
0072 private:
0073   occ::handle<BRepGraph_LayerTopoSupplement>  myLayer;
0074   const NCollection_LinearVector<uint64_t>*   myUids  = nullptr;
0075   const BRepGraph_LayerTopoSupplement::Entry* myEntry = nullptr;
0076   size_t                                      myIndex = 0;
0077 };
0078 
0079 #endif // _BRepGraph_SupplementIterator_HeaderFile