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