|
|
|||
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_LayerIterator_HeaderFile 0015 #define _BRepGraph_LayerIterator_HeaderFile 0016 0017 #include <BRepGraph_LayerRegistry.hxx> 0018 #include <NCollection_ForwardRange.hxx> 0019 0020 //! @brief Iterator over registered layers in a BRepGraph_LayerRegistry. 0021 //! 0022 //! Provides zero-allocation iteration with OCCT More()/Next()/Value() pattern 0023 //! and STL range-for via begin()/end(). 0024 //! 0025 //! @code 0026 //! // Range-for: 0027 //! for (const occ::handle<BRepGraph_Layer>& aLayer : 0028 //! BRepGraph_LayerIterator(aGraph.LayerRegistry())) 0029 //! doSomething(aLayer); 0030 //! 0031 //! // Traditional: 0032 //! for (BRepGraph_LayerIterator anIt(aGraph.LayerRegistry()); anIt.More(); anIt.Next()) 0033 //! doSomething(anIt.Value()); 0034 //! @endcode 0035 class BRepGraph_LayerIterator 0036 { 0037 public: 0038 //! Construct an iterator over all layers in the registry. 0039 explicit BRepGraph_LayerIterator(const BRepGraph_LayerRegistry& theRegistry) 0040 : myRegistry(&theRegistry), 0041 myCount(theRegistry.NbLayers()), 0042 myCurrent(0) 0043 { 0044 } 0045 0046 //! True if the iterator has a current element. 0047 [[nodiscard]] bool More() const { return myCurrent < myCount; } 0048 0049 //! Advance to the next layer. 0050 void Next() { ++myCurrent; } 0051 0052 //! Return the current layer handle. 0053 [[nodiscard]] occ::handle<BRepGraph_Layer> Value() const { return myRegistry->Layer(myCurrent); } 0054 0055 //! Return the current slot index in the registry. 0056 [[nodiscard]] uint32_t Slot() const { return myCurrent; } 0057 0058 //! Number of layers in the registry. 0059 [[nodiscard]] uint32_t NbLayers() const { return myCount; } 0060 0061 //! STL range-for support. 0062 NCollection_ForwardRangeIterator<BRepGraph_LayerIterator> begin() 0063 { 0064 return NCollection_ForwardRangeIterator<BRepGraph_LayerIterator>(this); 0065 } 0066 0067 //! Sentinel marking end of iteration. 0068 NCollection_ForwardRangeSentinel end() const { return NCollection_ForwardRangeSentinel{}; } 0069 0070 private: 0071 const BRepGraph_LayerRegistry* myRegistry; 0072 uint32_t myCount; 0073 uint32_t myCurrent; 0074 }; 0075 0076 #endif // _BRepGraph_LayerIterator_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|