0023258: Missing parenthesis
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_SurfaceExplorer.cxx
1 // Created on: 1996-10-17
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 #include <TopOpeBRepDS_SurfaceExplorer.ixx>
23 #define MYDS (*((TopOpeBRepDS_DataStructure*)myDS))
24
25 //=======================================================================
26 //function : TopOpeBRepDS_SurfaceExplorer
27 //purpose  : 
28 //=======================================================================
29
30 TopOpeBRepDS_SurfaceExplorer::TopOpeBRepDS_SurfaceExplorer() 
31 : myIndex(1),myMax(0),myDS(NULL),myFound(Standard_False)
32 {
33 }
34
35 //=======================================================================
36 //function : TopOpeBRepDS_SurfaceExplorer
37 //purpose  : 
38 //=======================================================================
39
40 TopOpeBRepDS_SurfaceExplorer::TopOpeBRepDS_SurfaceExplorer
41 (const TopOpeBRepDS_DataStructure& DS,
42  const Standard_Boolean FindKeep)
43
44   Init(DS,FindKeep);
45 }
46
47 //=======================================================================
48 //function : Init
49 //purpose  : 
50 //=======================================================================
51
52 void TopOpeBRepDS_SurfaceExplorer::Init
53 (const TopOpeBRepDS_DataStructure& DS,
54  const Standard_Boolean FindKeep)
55 {
56   myIndex = 1; 
57   myMax = DS.NbSurfaces();
58   myDS = (TopOpeBRepDS_DataStructure*)&DS;
59   myFindKeep = FindKeep;
60   Find();
61 }
62
63
64 //=======================================================================
65 //function : Find
66 //purpose  : 
67 //=======================================================================
68
69 void TopOpeBRepDS_SurfaceExplorer::Find()
70 {
71   myFound = Standard_False;
72   while (myIndex <= myMax) {
73     if (myFindKeep) {
74       myFound = IsSurfaceKeep(myIndex);
75     }
76     else {
77       myFound = IsSurface(myIndex);
78     }
79     if (myFound) break;
80     else myIndex++;
81   }
82 }
83
84 //=======================================================================
85 //function : More
86 //purpose  : 
87 //=======================================================================
88
89 Standard_Boolean TopOpeBRepDS_SurfaceExplorer::More() const
90 {
91   return myFound;
92 }
93
94 //=======================================================================
95 //function : Next
96 //purpose  : 
97 //=======================================================================
98
99 void TopOpeBRepDS_SurfaceExplorer::Next()
100 {
101   myIndex++;
102   Find();
103 }
104
105 //=======================================================================
106 //function : Surface
107 //purpose  : 
108 //=======================================================================
109
110 const TopOpeBRepDS_Surface& TopOpeBRepDS_SurfaceExplorer::Surface()const
111 {
112   if ( myFound ) {
113     return MYDS.Surface(myIndex);
114   }
115   else {
116     return myEmpty;
117   }
118 }
119
120 //=======================================================================
121 //function : IsSurface
122 //purpose  : 
123 //=======================================================================
124
125 Standard_Boolean TopOpeBRepDS_SurfaceExplorer::IsSurface
126    (const Standard_Integer I)const
127 {
128   Standard_Boolean b = MYDS.mySurfaces.IsBound(I);
129   return b;
130 }
131
132 //=======================================================================
133 //function : IsSurfaceKeep
134 //purpose  : 
135 //=======================================================================
136
137 Standard_Boolean TopOpeBRepDS_SurfaceExplorer::IsSurfaceKeep
138    (const Standard_Integer I)const
139 {
140   Standard_Boolean b = MYDS.mySurfaces.IsBound(I);
141   if (b) b = MYDS.Surface(I).Keep();
142   return b;
143 }
144
145 //=======================================================================
146 //function : Surface
147 //purpose  : 
148 //=======================================================================
149
150 const TopOpeBRepDS_Surface& TopOpeBRepDS_SurfaceExplorer::Surface
151    (const Standard_Integer I)const
152 {
153   if ( IsSurface(I) ) {
154     return MYDS.Surface(I);
155   }
156   else {
157     return myEmpty;
158   }
159 }
160
161 //=======================================================================
162 //function : NbSurface
163 //purpose  : 
164 //=======================================================================
165
166 Standard_Integer TopOpeBRepDS_SurfaceExplorer::NbSurface()
167 {
168   myIndex = 1; myMax = MYDS.NbSurfaces();
169   Find();
170   Standard_Integer n = 0;
171   for (; More(); Next() ) n++;
172   return n;
173 }
174
175 //=======================================================================
176 //function : Index
177 //purpose  : 
178 //=======================================================================
179
180 Standard_Integer TopOpeBRepDS_SurfaceExplorer::Index()const
181 {
182   return myIndex;
183 }