b311480e |
1 | // Created on: 1996-10-17 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1996-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <TopOpeBRepDS_SurfaceExplorer.ixx> |
18 | #define MYDS (*((TopOpeBRepDS_DataStructure*)myDS)) |
19 | |
20 | //======================================================================= |
21 | //function : TopOpeBRepDS_SurfaceExplorer |
22 | //purpose : |
23 | //======================================================================= |
24 | |
25 | TopOpeBRepDS_SurfaceExplorer::TopOpeBRepDS_SurfaceExplorer() |
26 | : myIndex(1),myMax(0),myDS(NULL),myFound(Standard_False) |
27 | { |
28 | } |
29 | |
30 | //======================================================================= |
31 | //function : TopOpeBRepDS_SurfaceExplorer |
32 | //purpose : |
33 | //======================================================================= |
34 | |
35 | TopOpeBRepDS_SurfaceExplorer::TopOpeBRepDS_SurfaceExplorer |
36 | (const TopOpeBRepDS_DataStructure& DS, |
37 | const Standard_Boolean FindKeep) |
38 | { |
39 | Init(DS,FindKeep); |
40 | } |
41 | |
42 | //======================================================================= |
43 | //function : Init |
44 | //purpose : |
45 | //======================================================================= |
46 | |
47 | void TopOpeBRepDS_SurfaceExplorer::Init |
48 | (const TopOpeBRepDS_DataStructure& DS, |
49 | const Standard_Boolean FindKeep) |
50 | { |
51 | myIndex = 1; |
52 | myMax = DS.NbSurfaces(); |
53 | myDS = (TopOpeBRepDS_DataStructure*)&DS; |
54 | myFindKeep = FindKeep; |
55 | Find(); |
56 | } |
57 | |
58 | |
59 | //======================================================================= |
60 | //function : Find |
61 | //purpose : |
62 | //======================================================================= |
63 | |
64 | void TopOpeBRepDS_SurfaceExplorer::Find() |
65 | { |
66 | myFound = Standard_False; |
67 | while (myIndex <= myMax) { |
68 | if (myFindKeep) { |
69 | myFound = IsSurfaceKeep(myIndex); |
70 | } |
71 | else { |
72 | myFound = IsSurface(myIndex); |
73 | } |
74 | if (myFound) break; |
75 | else myIndex++; |
76 | } |
77 | } |
78 | |
79 | //======================================================================= |
80 | //function : More |
81 | //purpose : |
82 | //======================================================================= |
83 | |
84 | Standard_Boolean TopOpeBRepDS_SurfaceExplorer::More() const |
85 | { |
86 | return myFound; |
87 | } |
88 | |
89 | //======================================================================= |
90 | //function : Next |
91 | //purpose : |
92 | //======================================================================= |
93 | |
94 | void TopOpeBRepDS_SurfaceExplorer::Next() |
95 | { |
96 | myIndex++; |
97 | Find(); |
98 | } |
99 | |
100 | //======================================================================= |
101 | //function : Surface |
102 | //purpose : |
103 | //======================================================================= |
104 | |
105 | const TopOpeBRepDS_Surface& TopOpeBRepDS_SurfaceExplorer::Surface()const |
106 | { |
107 | if ( myFound ) { |
108 | return MYDS.Surface(myIndex); |
109 | } |
110 | else { |
111 | return myEmpty; |
112 | } |
113 | } |
114 | |
115 | //======================================================================= |
116 | //function : IsSurface |
117 | //purpose : |
118 | //======================================================================= |
119 | |
120 | Standard_Boolean TopOpeBRepDS_SurfaceExplorer::IsSurface |
121 | (const Standard_Integer I)const |
122 | { |
123 | Standard_Boolean b = MYDS.mySurfaces.IsBound(I); |
124 | return b; |
125 | } |
126 | |
127 | //======================================================================= |
128 | //function : IsSurfaceKeep |
129 | //purpose : |
130 | //======================================================================= |
131 | |
132 | Standard_Boolean TopOpeBRepDS_SurfaceExplorer::IsSurfaceKeep |
133 | (const Standard_Integer I)const |
134 | { |
135 | Standard_Boolean b = MYDS.mySurfaces.IsBound(I); |
136 | if (b) b = MYDS.Surface(I).Keep(); |
137 | return b; |
138 | } |
139 | |
140 | //======================================================================= |
141 | //function : Surface |
142 | //purpose : |
143 | //======================================================================= |
144 | |
145 | const TopOpeBRepDS_Surface& TopOpeBRepDS_SurfaceExplorer::Surface |
146 | (const Standard_Integer I)const |
147 | { |
148 | if ( IsSurface(I) ) { |
149 | return MYDS.Surface(I); |
150 | } |
151 | else { |
152 | return myEmpty; |
153 | } |
154 | } |
155 | |
156 | //======================================================================= |
157 | //function : NbSurface |
158 | //purpose : |
159 | //======================================================================= |
160 | |
161 | Standard_Integer TopOpeBRepDS_SurfaceExplorer::NbSurface() |
162 | { |
163 | myIndex = 1; myMax = MYDS.NbSurfaces(); |
164 | Find(); |
165 | Standard_Integer n = 0; |
166 | for (; More(); Next() ) n++; |
167 | return n; |
168 | } |
169 | |
170 | //======================================================================= |
171 | //function : Index |
172 | //purpose : |
173 | //======================================================================= |
174 | |
175 | Standard_Integer TopOpeBRepDS_SurfaceExplorer::Index()const |
176 | { |
177 | return myIndex; |
178 | } |