Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-16 08:29:33

0001 // Created on: 1995-07-13
0002 // Created by: Jean Yves LEBEY
0003 // Copyright (c) 1995-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 _TopOpeBRepTool_ShapeExplorer_HeaderFile
0018 #define _TopOpeBRepTool_ShapeExplorer_HeaderFile
0019 
0020 #include <TopExp_Explorer.hxx>
0021 #include <TopAbs.hxx>
0022 
0023 //! Extends TopExp_Explorer by counting index of current item
0024 //! (for tracing and debug)
0025 
0026 class TopOpeBRepTool_ShapeExplorer : public TopExp_Explorer
0027 {
0028 public:
0029   //! Creates an empty explorer, becomes useful after Init.
0030   TopOpeBRepTool_ShapeExplorer()
0031       : myIndex(0)
0032   {
0033   }
0034 
0035   //! Creates an Explorer on the Shape <S>.
0036   //!
0037   //! <ToFind> is the type of shapes to search.
0038   //! TopAbs_VERTEX, TopAbs_EDGE, ...
0039   //!
0040   //! <ToAvoid>   is the type   of shape to  skip in the
0041   //! exploration.   If   <ToAvoid>  is  equal  or  less
0042   //! complex than <ToFind> or if  <ToAVoid> is SHAPE it
0043   //! has no effect on the exploration.
0044   TopOpeBRepTool_ShapeExplorer(const TopoDS_Shape&    S,
0045                                const TopAbs_ShapeEnum ToFind,
0046                                const TopAbs_ShapeEnum ToAvoid = TopAbs_SHAPE)
0047       : TopExp_Explorer(S, ToFind, ToAvoid),
0048         myIndex(More() ? 1 : 0)
0049   {
0050   }
0051 
0052   void Init(const TopoDS_Shape&    S,
0053             const TopAbs_ShapeEnum ToFind,
0054             const TopAbs_ShapeEnum ToAvoid = TopAbs_SHAPE)
0055   {
0056     TopExp_Explorer::Init(S, ToFind, ToAvoid);
0057     myIndex = (More() ? 1 : 0);
0058   }
0059 
0060   //! Moves to the next Shape in the exploration.
0061   void Next()
0062   {
0063     if (More())
0064       myIndex++;
0065     TopExp_Explorer::Next();
0066   }
0067 
0068   //! Index of current sub-shape
0069   Standard_Integer Index() const { return myIndex; }
0070 
0071   //! Dump info on current shape to stream
0072   Standard_OStream& DumpCurrent(Standard_OStream& OS) const
0073   {
0074     if (More())
0075     {
0076       TopAbs::Print(Current().ShapeType(), OS);
0077       OS << "(" << Index() << ",";
0078       TopAbs::Print(Current().Orientation(), OS);
0079       OS << ") ";
0080     }
0081     return OS;
0082   }
0083 
0084 private:
0085   Standard_Integer myIndex;
0086 };
0087 
0088 #endif // _TopOpeBRepTool_ShapeExplorer_HeaderFile