1 // Created on: 1993-01-21 2 // Created by: Remi LEQUETTE 3 // Copyright (c) 1993-1999 Matra Datavision 4 // Copyright (c) 1999-2014 OPEN CASCADE SAS 5 // 6 // This file is part of Open CASCADE Technology software library. 7 // 8 // This library is free software; you can redistribute it and/or modify it under 9 // the terms of the GNU Lesser General Public License version 2.1 as published 10 // by the Free Software Foundation, with special exception defined in the file 11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 12 // distribution for complete text of the license and disclaimer of any warranty. 13 // 14 // Alternatively, this file may be used under the terms of Open CASCADE 15 // commercial license or contractual agreement. 16 17 #ifndef _TopoDS_Iterator_HeaderFile 18 #define _TopoDS_Iterator_HeaderFile 19 20 #include <Standard_NoSuchObject.hxx> 21 #include <TopoDS_Shape.hxx> 22 #include <TopoDS_ListIteratorOfListOfShape.hxx> 23 #include <TopAbs_Orientation.hxx> 24 #include <TopLoc_Location.hxx> 25 26 //! Iterates on the underlying shape underlying a given 27 //! TopoDS_Shape object, providing access to its 28 //! component sub-shapes. Each component shape is 29 //! returned as a TopoDS_Shape with an orientation, 30 //! and a compound of the original values and the relative values. 31 class TopoDS_Iterator 32 { 33 public: 34 35 DEFINE_STANDARD_ALLOC 36 37 //! Creates an empty Iterator. TopoDS_Iterator()38 TopoDS_Iterator() {} 39 40 //! Creates an Iterator on <S> sub-shapes. 41 //! Note: 42 //! - If cumOri is true, the function composes all 43 //! sub-shapes with the orientation of S. 44 //! - If cumLoc is true, the function multiplies all 45 //! sub-shapes by the location of S, i.e. it applies to 46 //! each sub-shape the transformation that is associated with S. TopoDS_Iterator(const TopoDS_Shape & S,const Standard_Boolean cumOri=Standard_True,const Standard_Boolean cumLoc=Standard_True)47 TopoDS_Iterator (const TopoDS_Shape& S, 48 const Standard_Boolean cumOri = Standard_True, 49 const Standard_Boolean cumLoc = Standard_True) 50 { 51 Initialize (S, cumOri,cumLoc); 52 } 53 54 //! Initializes this iterator with shape S. 55 //! Note: 56 //! - If cumOri is true, the function composes all 57 //! sub-shapes with the orientation of S. 58 //! - If cumLoc is true, the function multiplies all 59 //! sub-shapes by the location of S, i.e. it applies to 60 //! each sub-shape the transformation that is associated with S. 61 Standard_EXPORT void Initialize (const TopoDS_Shape& S, const Standard_Boolean cumOri = Standard_True, const Standard_Boolean cumLoc = Standard_True); 62 63 //! Returns true if there is another sub-shape in the 64 //! shape which this iterator is scanning. More() const65 Standard_Boolean More() const { return myShapes.More(); } 66 67 //! Moves on to the next sub-shape in the shape which 68 //! this iterator is scanning. 69 //! Exceptions 70 //! Standard_NoMoreObject if there are no more sub-shapes in the shape. 71 Standard_EXPORT void Next(); 72 73 //! Returns the current sub-shape in the shape which 74 //! this iterator is scanning. 75 //! Exceptions 76 //! Standard_NoSuchObject if there is no current sub-shape. Value() const77 const TopoDS_Shape& Value() const 78 { 79 Standard_NoSuchObject_Raise_if(!More(),"TopoDS_Iterator::Value"); 80 return myShape; 81 } 82 83 private: 84 85 TopoDS_Shape myShape; 86 TopoDS_ListIteratorOfListOfShape myShapes; 87 TopAbs_Orientation myOrientation; 88 TopLoc_Location myLocation; 89 90 }; 91 92 #endif // _TopoDS_Iterator_HeaderFile 93