summaryrefslogtreecommitdiff
path: root/src/TopOpeBRepDS/TopOpeBRepDS_Explorer.cxx
blob: cc04714ef75fa9f82127201dc393990865569539 (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
// File:	TopOpeBRepDS_Explorer.cxx
// Created:	Tue Jan  5 17:12:38 1999
// Author:	Jean Yves LEBEY
//		<jyl@langdox.paris1.matra-dtv.fr>

#define No_Standard_NoMoreObject
#define No_Standard_NoSuchObject

#include <TopOpeBRepDS_Explorer.ixx>
#include <TopOpeBRepDS_define.hxx>
#include <TopoDS.hxx>

//=======================================================================
//function : TopOpeBRepDS_Explorer
//purpose  : 
//=======================================================================
TopOpeBRepDS_Explorer::TopOpeBRepDS_Explorer()
:myT(TopAbs_SHAPE),myI(1),myN(0),myB(Standard_False),myFK(Standard_True)
{
}

//=======================================================================
//function : TopOpeBRepDS_Explorer
//purpose  : 
//=======================================================================
TopOpeBRepDS_Explorer::TopOpeBRepDS_Explorer
(const Handle(TopOpeBRepDS_HDataStructure)& HDS,const TopAbs_ShapeEnum T,const Standard_Boolean FK)
{
  Init(HDS,T,FK);
}

//=======================================================================
//function : Init
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Explorer::Init
(const Handle(TopOpeBRepDS_HDataStructure)& HDS,const TopAbs_ShapeEnum T,const Standard_Boolean FK)
{
  myI = 1; myN = 0; myB = Standard_False; myFK = Standard_True; myT = T;
  myHDS = HDS; if (myHDS.IsNull()) return;
  myN = myHDS->NbShapes(); myFK = FK;
  Find();
}


//=======================================================================
//function : Type
//purpose  : 
//=======================================================================
TopAbs_ShapeEnum TopOpeBRepDS_Explorer::Type() const
{
  return myT;
}

//=======================================================================
//function : Find
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Explorer::Find()
{
  Standard_Boolean found = Standard_False;
  const TopOpeBRepDS_DataStructure& BDS = myHDS->DS();
  while ( (myI <= myN) && (!found) ) {
    Standard_Boolean b = BDS.KeepShape(myI,myFK);
    if (b) {
      const TopoDS_Shape& s = BDS.Shape(myI,Standard_False);
      TopAbs_ShapeEnum t = s.ShapeType();
      if ( t == myT || myT == TopAbs_SHAPE ) found = Standard_True;
      else myI++;
    }
    else myI++;
  }
  myB = found;
}

//=======================================================================
//function : More
//purpose  : 
//=======================================================================
Standard_Boolean TopOpeBRepDS_Explorer::More() const
{
  return myB;
}

//=======================================================================
//function : Next
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Explorer::Next()
{
  Standard_NoMoreObject_Raise_if(!myB,"TopOpeBRepDS_Explorer::Next");
  myI++;
  Find();
}

//=======================================================================
//function : Current
//purpose  : 
//=======================================================================
const TopoDS_Shape& TopOpeBRepDS_Explorer::Current() const
{
  Standard_NoSuchObject_Raise_if(!More(),"TopOpeBRepDS_Explorer::Current");
  return myHDS->Shape(myI);
}

//=======================================================================
//function : Index
//purpose  : 
//=======================================================================
Standard_Integer TopOpeBRepDS_Explorer::Index() const
{
  Standard_NoSuchObject_Raise_if(!More(),"TopOpeBRepDS_Explorer::Index");
  return myI;
}

//=======================================================================
//function : Face
//purpose  : 
//=======================================================================
const TopoDS_Face& TopOpeBRepDS_Explorer::Face() const
{
  Standard_NoSuchObject_Raise_if(!More(),"TopOpeBRepDS_Explorer::Face");
  const TopoDS_Shape& s = Current();
  const TopoDS_Face& f = TopoDS::Face(s);
  return f;
}

//=======================================================================
//function : Edge
//purpose  : 
//=======================================================================
const TopoDS_Edge& TopOpeBRepDS_Explorer::Edge() const
{
  Standard_NoSuchObject_Raise_if(!More(),"TopOpeBRepDS_Explorer::Edge");
  const TopoDS_Shape& s = Current();
  const TopoDS_Edge& e = TopoDS::Edge(s);
  return e;
}

//=======================================================================
//function : Vertex
//purpose  : 
//=======================================================================
const TopoDS_Vertex& TopOpeBRepDS_Explorer::Vertex() const
{
  Standard_NoSuchObject_Raise_if(!More(),"TopOpeBRepDS_Explorer::Vertex");
  const TopoDS_Shape& s = Current();
  const TopoDS_Vertex& v = TopoDS::Vertex(s);
  return v;
}