0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_PointExplorer.cxx
1 // Created on: 1995-12-08
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
18 #include <TopOpeBRepDS_DataStructure.hxx>
19 #include <TopOpeBRepDS_Point.hxx>
20 #include <TopOpeBRepDS_PointExplorer.hxx>
21
22 #define MYDS (*((TopOpeBRepDS_DataStructure*)myDS))
23
24 //=======================================================================
25 //function : TopOpeBRepDS_PointExplorer
26 //purpose  : 
27 //=======================================================================
28
29 TopOpeBRepDS_PointExplorer::TopOpeBRepDS_PointExplorer() 
30 : myIndex(1),
31   myMax(0),
32   myDS(NULL),
33   myFound(Standard_False),
34   myFindKeep(Standard_False)
35 {
36 }
37
38 //=======================================================================
39 //function : TopOpeBRepDS_PointExplorer
40 //purpose  : 
41 //=======================================================================
42
43 TopOpeBRepDS_PointExplorer::TopOpeBRepDS_PointExplorer
44 (const TopOpeBRepDS_DataStructure& DS,
45  const Standard_Boolean FindKeep)
46
47   Init(DS,FindKeep);
48 }
49
50 //=======================================================================
51 //function : Init
52 //purpose  : 
53 //=======================================================================
54
55 void TopOpeBRepDS_PointExplorer::Init
56 (const TopOpeBRepDS_DataStructure& DS,
57  const Standard_Boolean FindKeep)
58 {
59   myIndex = 1; 
60   myMax = DS.NbPoints();
61   myDS = (TopOpeBRepDS_DataStructure*)&DS;
62   myFindKeep = FindKeep;
63   Find();
64 }
65
66
67 //=======================================================================
68 //function : Find
69 //purpose  : 
70 //=======================================================================
71
72 void TopOpeBRepDS_PointExplorer::Find()
73 {
74   myFound = Standard_False;
75   while (myIndex <= myMax) {
76     if (myFindKeep) {
77       myFound = IsPointKeep(myIndex);
78     }
79     else {
80       myFound = IsPoint(myIndex);
81     }
82     if (myFound) break;
83     else myIndex++;
84   }
85 }
86
87 //=======================================================================
88 //function : More
89 //purpose  : 
90 //=======================================================================
91
92 Standard_Boolean TopOpeBRepDS_PointExplorer::More() const
93 {
94   return myFound;
95 }
96
97 //=======================================================================
98 //function : Next
99 //purpose  : 
100 //=======================================================================
101
102 void TopOpeBRepDS_PointExplorer::Next()
103 {
104   myIndex++;
105   Find();
106 }
107
108 //=======================================================================
109 //function : Point
110 //purpose  : 
111 //=======================================================================
112
113 const TopOpeBRepDS_Point& TopOpeBRepDS_PointExplorer::Point()const
114 {
115   if ( myFound ) {
116     return MYDS.Point(myIndex);
117   }
118   else {
119     return myEmpty;
120   }
121 }
122
123 //=======================================================================
124 //function : IsPoint
125 //purpose  : 
126 //=======================================================================
127
128 Standard_Boolean TopOpeBRepDS_PointExplorer::IsPoint
129 (const Standard_Integer I)const
130 {
131   Standard_Boolean b = MYDS.myPoints.IsBound(I);
132   return b;
133 }
134
135 //=======================================================================
136 //function : IsPointKeep
137 //purpose  : 
138 //=======================================================================
139
140 Standard_Boolean TopOpeBRepDS_PointExplorer::IsPointKeep
141 (const Standard_Integer I)const
142 {
143   Standard_Boolean b = MYDS.myPoints.IsBound(I);
144   if (b) b = MYDS.Point(I).Keep();
145   return b;
146 }
147
148
149 //=======================================================================
150 //function : Point
151 //purpose  : 
152 //=======================================================================
153
154 const TopOpeBRepDS_Point& TopOpeBRepDS_PointExplorer::Point
155    (const Standard_Integer I)const
156 {
157   if ( IsPoint(I) ) {
158     return MYDS.Point(I);
159   }
160   else {
161     return myEmpty;
162   }
163 }
164
165 //=======================================================================
166 //function : NbPoint
167 //purpose  : 
168 //=======================================================================
169
170 Standard_Integer TopOpeBRepDS_PointExplorer::NbPoint()
171 {
172   myIndex = 1; myMax = MYDS.NbPoints();
173   Find();
174   Standard_Integer n = 0;
175   for (; More(); Next() ) n++;
176   return n;
177 }
178
179 //=======================================================================
180 //function : Index
181 //purpose  : 
182 //=======================================================================
183
184 Standard_Integer TopOpeBRepDS_PointExplorer::Index()const
185 {
186   return myIndex;
187 }