Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-22 08:31:06

0001 // Created on: 2022-05-11
0002 // Copyright (c) 2022 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _XCAFDoc_AssemblyIterator_HeaderFile
0016 #define _XCAFDoc_AssemblyIterator_HeaderFile
0017 
0018 #include <NCollection_Sequence.hxx>
0019 #include <XCAFDoc_AssemblyItemId.hxx>
0020 
0021 class TDF_Label;
0022 class TDocStd_Document;
0023 class XCAFDoc_ShapeTool;
0024 
0025 //! Iterator in depth along the assembly tree.
0026 class XCAFDoc_AssemblyIterator
0027 {
0028 public:
0029   //! Constructs iterator starting from assembly roots.
0030   //! \param[in]       theDoc   - document to iterate.
0031   //! \param [in, opt] theLevel - max level of hierarchy to reach (INT_MAX is for no limit).
0032   Standard_EXPORT XCAFDoc_AssemblyIterator(const Handle(TDocStd_Document)& theDoc,
0033                                            const Standard_Integer          theLevel = INT_MAX);
0034 
0035   //! Constructs iterator starting from the specified position in the assembly tree.
0036   //! \param[in]       theDoc   - document to iterate.
0037   //! \param[in]       theRoot  - assembly item to start iterating from.
0038   //! \param [in, opt] theLevel - max level of hierarchy to reach (INT_MAX is for no limit).
0039   Standard_EXPORT XCAFDoc_AssemblyIterator(const Handle(TDocStd_Document)& theDoc,
0040                                            const XCAFDoc_AssemblyItemId&   theRoot,
0041                                            const Standard_Integer          theLevel = INT_MAX);
0042 
0043   //! \return true if there is still something to iterate, false -- otherwise.
0044   Standard_EXPORT Standard_Boolean More() const;
0045 
0046   //! Moves depth-first iterator to the next position.
0047   Standard_EXPORT void Next();
0048 
0049   //! \return current item.
0050   Standard_EXPORT XCAFDoc_AssemblyItemId Current() const;
0051 
0052 private:
0053   struct AuxAssemblyItem
0054   {
0055     TDF_Label              myLabel;
0056     XCAFDoc_AssemblyItemId myItem;
0057   };
0058 
0059   void createItem(const TDF_Label&                 theLabel,
0060                   const TColStd_ListOfAsciiString& theParentPath,
0061                   AuxAssemblyItem&                 theAuxItem) const;
0062 
0063 private:
0064   Handle(XCAFDoc_ShapeTool)             myShapeTool; //!< Document shape tool.
0065   NCollection_Sequence<AuxAssemblyItem> myFringe;    //!< Items pending for iteration.
0066   Standard_Integer                      myMaxLevel;  //!< Limit on max depth of iteration.
0067   Standard_Integer                      mySeedLevel; //!< Level of hierarchy where we start.
0068 };
0069 
0070 #endif // _XCAFDoc_AssemblyIterator_HeaderFile