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