1 // Created on: 1993-01-14
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _TopExp_Explorer_HeaderFile
18 #define _TopExp_Explorer_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <TopExp_Stack.hxx>
25 #include <Standard_Integer.hxx>
26 #include <TopoDS_Shape.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <TopAbs_ShapeEnum.hxx>
29 class Standard_NoMoreObject;
30 class Standard_NoSuchObject;
34 //! An Explorer is a Tool to visit a Topological Data
35 //! Structure form the TopoDS package.
37 //! An Explorer is built with :
39 //! * The Shape to explore.
41 //! * The type of Shapes to find : e.g VERTEX, EDGE.
42 //! This type cannot be SHAPE.
44 //! * The type of Shapes to avoid. e.g SHELL, EDGE.
45 //! By default this type is SHAPE which means no
46 //! restriction on the exploration.
48 //! The Explorer visits all the structure to find
49 //! shapes of the requested type which are not
50 //! contained in the type to avoid.
52 //! Example to find all the Faces in the Shape S :
54 //! TopExp_Explorer Ex;
55 //! for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next()) {
56 //! ProcessFace(Ex.Current());
60 //! TopExp_Explorer Ex(S,TopAbs_FACE);
61 //! while (Ex.More()) {
62 //! ProcessFace(Ex.Current());
66 //! To find all the vertices which are not in an edge :
68 //! for (Ex.Init(S,TopAbs_VERTEX,TopAbs_EDGE); ...)
70 //! To find all the faces in a SHELL, then all the
71 //! faces not in a SHELL :
73 //! TopExp_Explorer Ex1, Ex2;
75 //! for (Ex1.Init(S,TopAbs_SHELL),...) {
76 //! // visit all shells
77 //! for (Ex2.Init(Ex1.Current(),TopAbs_FACE),...) {
78 //! // visit all the faces of the current shell
82 //! for (Ex1.Init(S,TopAbs_FACE,TopAbs_SHELL),...) {
83 //! // visit all faces not in a shell
86 //! If the type to avoid is the same or is less
87 //! complex than the type to find it has no effect.
89 //! For example searching edges not in a vertex does
90 //! not make a difference.
98 //! Creates an empty explorer, becomes usefull after Init.
99 Standard_EXPORT TopExp_Explorer();
101 //! Creates an Explorer on the Shape <S>.
103 //! <ToFind> is the type of shapes to search.
104 //! TopAbs_VERTEX, TopAbs_EDGE, ...
106 //! <ToAvoid> is the type of shape to skip in the
107 //! exploration. If <ToAvoid> is equal or less
108 //! complex than <ToFind> or if <ToAVoid> is SHAPE it
109 //! has no effect on the exploration.
110 Standard_EXPORT TopExp_Explorer(const TopoDS_Shape& S, const TopAbs_ShapeEnum ToFind, const TopAbs_ShapeEnum ToAvoid = TopAbs_SHAPE);
112 //! Resets this explorer on the shape S. It is initialized to
113 //! search the shape S, for shapes of type ToFind, that
114 //! are not part of a shape ToAvoid.
115 //! If the shape ToAvoid is equal to TopAbs_SHAPE, or
116 //! if it is the same as, or less complex than, the shape
117 //! ToFind it has no effect on the search.
118 Standard_EXPORT void Init (const TopoDS_Shape& S, const TopAbs_ShapeEnum ToFind, const TopAbs_ShapeEnum ToAvoid = TopAbs_SHAPE);
120 //! Returns True if there are more shapes in the
122 Standard_Boolean More() const;
124 //! Moves to the next Shape in the exploration.
126 //! Standard_NoMoreObject if there are no more shapes to explore.
127 Standard_EXPORT void Next();
129 //! Returns the current shape in the exploration.
131 //! Standard_NoSuchObject if this explorer has no more shapes to explore.
132 Standard_EXPORT const TopoDS_Shape& Current() const;
134 //! Reinitialize the exploration with the original
136 Standard_EXPORT void ReInit();
138 //! Returns the current depth of the exploration. 0 is
139 //! the shape to explore itself.
140 Standard_Integer Depth() const;
142 //! Clears the content of the explorer. It will return
146 Standard_EXPORT void Destroy();
165 TopExp_Stack myStack;
166 Standard_Integer myTop;
167 Standard_Integer mySizeOfStack;
168 TopoDS_Shape myShape;
169 Standard_Boolean hasMore;
170 TopAbs_ShapeEnum toFind;
171 TopAbs_ShapeEnum toAvoid;
177 #include <TopExp_Explorer.lxx>
183 #endif // _TopExp_Explorer_HeaderFile