Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1993-01-14
0002 // Created by: Remi LEQUETTE
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _TopExp_Explorer_HeaderFile
0018 #define _TopExp_Explorer_HeaderFile
0019 
0020 #include <TopExp_Stack.hxx>
0021 #include <TopoDS_Iterator.hxx>
0022 #include <TopoDS_Shape.hxx>
0023 
0024 //! An Explorer is a Tool to visit  a Topological Data
0025 //! Structure form the TopoDS package.
0026 //!
0027 //! An Explorer is built with :
0028 //!
0029 //! * The Shape to explore.
0030 //!
0031 //! * The type of Shapes to find : e.g VERTEX, EDGE.
0032 //! This type cannot be SHAPE.
0033 //!
0034 //! * The type of Shapes to avoid. e.g  SHELL, EDGE.
0035 //! By default   this type is  SHAPE which  means no
0036 //! restriction on the exploration.
0037 //!
0038 //! The Explorer  visits  all the  structure   to find
0039 //! shapes of the   requested  type  which   are   not
0040 //! contained in the type to avoid.
0041 //!
0042 //! Example to find all the Faces in the Shape S :
0043 //!
0044 //! TopExp_Explorer Ex;
0045 //! for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next()) {
0046 //! ProcessFace(Ex.Current());
0047 //! }
0048 //!
0049 //! // an other way
0050 //! TopExp_Explorer Ex(S,TopAbs_FACE);
0051 //! while (Ex.More()) {
0052 //! ProcessFace(Ex.Current());
0053 //! Ex.Next();
0054 //! }
0055 //!
0056 //! To find all the vertices which are not in an edge :
0057 //!
0058 //! for (Ex.Init(S,TopAbs_VERTEX,TopAbs_EDGE); ...)
0059 //!
0060 //! To  find all the faces  in   a SHELL, then all the
0061 //! faces not in a SHELL :
0062 //!
0063 //! TopExp_Explorer Ex1, Ex2;
0064 //!
0065 //! for (Ex1.Init(S,TopAbs_SHELL),...) {
0066 //! // visit all shells
0067 //! for (Ex2.Init(Ex1.Current(),TopAbs_FACE),...) {
0068 //! // visit all the faces of the current shell
0069 //! }
0070 //! }
0071 //!
0072 //! for (Ex1.Init(S,TopAbs_FACE,TopAbs_SHELL),...) {
0073 //! // visit all faces not in a shell
0074 //! }
0075 //!
0076 //! If   the type  to avoid  is   the same  or is less
0077 //! complex than the type to find it has no effect.
0078 //!
0079 //! For example searching edges  not in a vertex  does
0080 //! not make a difference.
0081 class TopExp_Explorer 
0082 {
0083 public:
0084 
0085   DEFINE_STANDARD_ALLOC
0086 
0087   
0088   //! Creates an empty explorer, becomes useful after Init.
0089   Standard_EXPORT TopExp_Explorer();
0090   
0091   //! Creates an Explorer on the Shape <S>.
0092   //!
0093   //! <ToFind> is the type of shapes to search.
0094   //! TopAbs_VERTEX, TopAbs_EDGE, ...
0095   //!
0096   //! <ToAvoid>   is the type   of shape to  skip in the
0097   //! exploration.   If   <ToAvoid>  is  equal  or  less
0098   //! complex than <ToFind> or if  <ToAVoid> is SHAPE it
0099   //! has no effect on the exploration.
0100   Standard_EXPORT TopExp_Explorer(const TopoDS_Shape& S, const TopAbs_ShapeEnum ToFind, const TopAbs_ShapeEnum ToAvoid = TopAbs_SHAPE);
0101   
0102   //! Resets this explorer on the shape S. It is initialized to
0103   //! search the shape S, for shapes of type ToFind, that
0104   //! are not part of a shape ToAvoid.
0105   //! If the shape ToAvoid is equal to TopAbs_SHAPE, or
0106   //! if it is the same as, or less complex than, the shape
0107   //! ToFind it has no effect on the search.
0108   Standard_EXPORT void Init (const TopoDS_Shape& S, const TopAbs_ShapeEnum ToFind, const TopAbs_ShapeEnum ToAvoid = TopAbs_SHAPE);
0109   
0110   //! Returns True if there are more shapes in the exploration.
0111   Standard_Boolean More() const { return hasMore; }
0112 
0113   //! Moves to the next Shape in the exploration.
0114   //! Exceptions
0115   //! Standard_NoMoreObject if there are no more shapes to explore.
0116   Standard_EXPORT void Next();
0117 
0118   //! Returns the current shape in the exploration.
0119   //! Exceptions
0120   //! Standard_NoSuchObject if this explorer has no more shapes to explore.
0121   const TopoDS_Shape& Value() const { return Current(); }
0122 
0123   //! Returns the current shape in the exploration.
0124   //! Exceptions
0125   //! Standard_NoSuchObject if this explorer has no more shapes to explore.
0126   Standard_EXPORT const TopoDS_Shape& Current() const;
0127 
0128   //! Reinitialize the exploration with the original arguments.
0129   Standard_EXPORT void ReInit();
0130 
0131   //! Return explored shape.
0132   const TopoDS_Shape& ExploredShape() const { return myShape; }
0133 
0134   //! Returns the current depth of the exploration. 0 is
0135   //! the shape to explore itself.
0136   Standard_Integer Depth() const { return myTop; }
0137 
0138   //! Clears the content of the explorer. It will return
0139   //! False on More().
0140   Standard_EXPORT void Clear();
0141 
0142   //! Destructor.
0143   Standard_EXPORT ~TopExp_Explorer();
0144 
0145 private:
0146 
0147   TopExp_Stack myStack;
0148   TopoDS_Shape myShape;
0149   Standard_Integer myTop;
0150   Standard_Integer mySizeOfStack;
0151   TopAbs_ShapeEnum toFind;
0152   TopAbs_ShapeEnum toAvoid;
0153   Standard_Boolean hasMore;
0154 
0155 };
0156 
0157 #endif // _TopExp_Explorer_HeaderFile