summaryrefslogtreecommitdiff
path: root/src/TopOpeBRepDS/TopOpeBRepDS_PointExplorer.cxx
blob: e31de886bfab65ba2f4b24ef416e7540ebb40ebf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// File:	TopOpeBRepDS_PointExplorer.cxx
// Created:	Fri Dec  8 19:38:41 1995
// Author:	Jean Yves LEBEY
//		<jyl@meteox>

#include <TopOpeBRepDS_PointExplorer.ixx>
#define MYDS (*((TopOpeBRepDS_DataStructure*)myDS))

//=======================================================================
//function : TopOpeBRepDS_PointExplorer
//purpose  : 
//=======================================================================

TopOpeBRepDS_PointExplorer::TopOpeBRepDS_PointExplorer() 
: myIndex(1),
  myMax(0),
  myDS(NULL),
  myFound(Standard_False),
  myFindKeep(Standard_False)
{
}

//=======================================================================
//function : TopOpeBRepDS_PointExplorer
//purpose  : 
//=======================================================================

TopOpeBRepDS_PointExplorer::TopOpeBRepDS_PointExplorer
(const TopOpeBRepDS_DataStructure& DS,
 const Standard_Boolean FindKeep)
{ 
  Init(DS,FindKeep);
}

//=======================================================================
//function : Init
//purpose  : 
//=======================================================================

void TopOpeBRepDS_PointExplorer::Init
(const TopOpeBRepDS_DataStructure& DS,
 const Standard_Boolean FindKeep)
{
  myIndex = 1; 
  myMax = DS.NbPoints();
  myDS = (TopOpeBRepDS_DataStructure*)&DS;
  myFindKeep = FindKeep;
  Find();
}


//=======================================================================
//function : Find
//purpose  : 
//=======================================================================

void TopOpeBRepDS_PointExplorer::Find()
{
  myFound = Standard_False;
  while (myIndex <= myMax) {
    if (myFindKeep) {
      myFound = IsPointKeep(myIndex);
    }
    else {
      myFound = IsPoint(myIndex);
    }
    if (myFound) break;
    else myIndex++;
  }
}

//=======================================================================
//function : More
//purpose  : 
//=======================================================================

Standard_Boolean TopOpeBRepDS_PointExplorer::More() const
{
  return myFound;
}

//=======================================================================
//function : Next
//purpose  : 
//=======================================================================

void TopOpeBRepDS_PointExplorer::Next()
{
  myIndex++;
  Find();
}

//=======================================================================
//function : Point
//purpose  : 
//=======================================================================

const TopOpeBRepDS_Point& TopOpeBRepDS_PointExplorer::Point()const
{
  if ( myFound ) {
    return MYDS.Point(myIndex);
  }
  else {
    return myEmpty;
  }
}

//=======================================================================
//function : IsPoint
//purpose  : 
//=======================================================================

Standard_Boolean TopOpeBRepDS_PointExplorer::IsPoint
(const Standard_Integer I)const
{
  Standard_Boolean b = MYDS.myPoints.IsBound(I);
  return b;
}

//=======================================================================
//function : IsPointKeep
//purpose  : 
//=======================================================================

Standard_Boolean TopOpeBRepDS_PointExplorer::IsPointKeep
(const Standard_Integer I)const
{
  Standard_Boolean b = MYDS.myPoints.IsBound(I);
  if (b) b = MYDS.Point(I).Keep();
  return b;
}


//=======================================================================
//function : Point
//purpose  : 
//=======================================================================

const TopOpeBRepDS_Point& TopOpeBRepDS_PointExplorer::Point
   (const Standard_Integer I)const
{
  if ( IsPoint(I) ) {
    return MYDS.Point(I);
  }
  else {
    return myEmpty;
  }
}

//=======================================================================
//function : NbPoint
//purpose  : 
//=======================================================================

Standard_Integer TopOpeBRepDS_PointExplorer::NbPoint()
{
  myIndex = 1; myMax = MYDS.NbPoints();
  Find();
  Standard_Integer n = 0;
  for (; More(); Next() ) n++;
  return n;
}

//=======================================================================
//function : Index
//purpose  : 
//=======================================================================

Standard_Integer TopOpeBRepDS_PointExplorer::Index()const
{
  return myIndex;
}