0025418: Debug output to be limited to OCC development environment
[occt.git] / src / TopOpeBRepTool / TopOpeBRepTool_ShapeExplorer.cxx
1 // Created on: 1995-07-13
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1995-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 #include <TopOpeBRepTool_ShapeExplorer.ixx>
18 #include <TopAbs.hxx>
19 #include <Standard_NoMoreObject.hxx>
20 #include <Standard_NoSuchObject.hxx>
21
22
23 //=======================================================================
24 //function : TopOpeBRepTool_ShapeExplorer
25 //purpose  : 
26 //=======================================================================
27
28 TopOpeBRepTool_ShapeExplorer::TopOpeBRepTool_ShapeExplorer() : 
29    myIndex(0),
30    myNbShapes(0)
31 {
32 }
33
34
35 //=======================================================================
36 //function : TopOpeBRepTool_ShapeExplorer
37 //purpose  : 
38 //=======================================================================
39
40 TopOpeBRepTool_ShapeExplorer::TopOpeBRepTool_ShapeExplorer
41    (const TopoDS_Shape& S, 
42     const TopAbs_ShapeEnum ToFind, 
43     const TopAbs_ShapeEnum ToAvoid)
44 {
45   Init(S,ToFind,ToAvoid);
46 }
47
48
49 //=======================================================================
50 //function : Init
51 //purpose  : 
52 //=======================================================================
53
54 void  TopOpeBRepTool_ShapeExplorer::Init(const TopoDS_Shape& S, 
55                                          const TopAbs_ShapeEnum ToFind, 
56                                          const TopAbs_ShapeEnum ToAvoid)
57 {
58   myExplorer.Init(S,ToFind,ToAvoid);
59
60 #ifdef OCCT_DEBUG
61   myIndex = myNbShapes = 0;
62   for (;More();Next()) myNbShapes++;
63   myExplorer.ReInit();
64   if (More()) myIndex = 1;
65 #endif
66
67 }
68
69 //=======================================================================
70 //function : More
71 //purpose  : 
72 //=======================================================================
73
74 Standard_Boolean  TopOpeBRepTool_ShapeExplorer::More()const 
75 {
76   Standard_Boolean b = myExplorer.More(); 
77   return b;
78 }
79
80 //=======================================================================
81 //function : Next
82 //purpose  : 
83 //=======================================================================
84
85 void  TopOpeBRepTool_ShapeExplorer::Next()
86 {
87   myExplorer.Next();
88 #ifdef OCCT_DEBUG
89   myIndex++;
90 #endif
91 }
92
93 //=======================================================================
94 //function : Current
95 //purpose  : 
96 //=======================================================================
97
98 const TopoDS_Shape&  TopOpeBRepTool_ShapeExplorer::Current()const 
99 {
100   const TopoDS_Shape& S = myExplorer.Current();
101   return S;
102 }
103
104
105 //=======================================================================
106 //function : NbShapes
107 //purpose  : 
108 //=======================================================================
109
110 Standard_Integer TopOpeBRepTool_ShapeExplorer::NbShapes()const 
111 {
112   Standard_Integer n = 0;
113 #ifdef OCCT_DEBUG
114   n = myNbShapes;
115 #endif
116   return n;
117 }
118
119
120 //=======================================================================
121 //function : Index
122 //purpose  : 
123 //=======================================================================
124
125 Standard_Integer TopOpeBRepTool_ShapeExplorer::Index()const 
126 {
127   Standard_Integer n = 0;
128 #ifdef OCCT_DEBUG
129   n = myIndex;
130 #endif
131   return n;
132 }
133  
134 //=======================================================================
135 //function : DumpCurrent
136 //purpose  : 
137 //=======================================================================
138
139 Standard_OStream& TopOpeBRepTool_ShapeExplorer::DumpCurrent
140 (Standard_OStream& OS)const 
141 {
142 #ifdef OCCT_DEBUG
143   if ( More() ) { 
144     const TopoDS_Shape& S = Current();
145     TopAbs_ShapeEnum    T = S.ShapeType();
146     TopAbs_Orientation  O = S.Orientation();
147     Standard_Integer    I = Index();
148     TopAbs::Print(T,cout);
149     cout<<"("<<I<<","; TopAbs::Print(O,cout); cout<<") ";
150   }
151 #endif
152   return OS;
153 }