Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:33

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 
0030   //! Constructs iterator starting from assembly roots.
0031   //! \param [in]      theDoc   - document to iterate.
0032   //! \param [in, opt] theLevel - max level of hierarchy to reach (INT_MAX is for no limit).
0033   Standard_EXPORT XCAFDoc_AssemblyIterator(const Handle(TDocStd_Document)& theDoc,
0034                                            const Standard_Integer          theLevel = INT_MAX);
0035 
0036   //! Constructs iterator starting from the specified position in the assembly tree.
0037   //! \param [in]      theDoc   - document to iterate.
0038   //! \param [in]      theRoot  - assembly item to start iterating from.
0039   //! \param [in, opt] theLevel - max level of hierarchy to reach (INT_MAX is for no limit).
0040   Standard_EXPORT XCAFDoc_AssemblyIterator(const Handle(TDocStd_Document)& theDoc,
0041                                            const XCAFDoc_AssemblyItemId&   theRoot,
0042                                            const Standard_Integer          theLevel = INT_MAX);
0043 
0044   //! \return true if there is still something to iterate, false -- otherwise.
0045   Standard_EXPORT Standard_Boolean More() const;
0046 
0047   //! Moves depth-first iterator to the next position.
0048   Standard_EXPORT void Next();
0049 
0050   //! \return current item.
0051   Standard_EXPORT XCAFDoc_AssemblyItemId Current() const;
0052 
0053 private:
0054 
0055   struct AuxAssemblyItem
0056   {
0057     TDF_Label myLabel;
0058     XCAFDoc_AssemblyItemId myItem;
0059   };
0060 
0061   void createItem(const TDF_Label& theLabel, const TColStd_ListOfAsciiString& theParentPath, 
0062                   AuxAssemblyItem& theAuxItem) const;
0063 
0064 private:
0065 
0066   Handle(XCAFDoc_ShapeTool)             myShapeTool; //!< Document shape tool.
0067   NCollection_Sequence<AuxAssemblyItem> myFringe;    //!< Items pending for iteration.
0068   Standard_Integer                      myMaxLevel;  //!< Limit on max depth of iteration.
0069   Standard_Integer                      mySeedLevel; //!< Level of hierarchy where we start.
0070 };
0071 
0072 #endif // _XCAFDoc_AssemblyIterator_HeaderFile