b311480e |
1 | // Created on: 1993-11-16 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
7fd59977 |
18 | #include <Standard_ProgramError.hxx> |
42cf5bc1 |
19 | #include <TopOpeBRep_LineInter.hxx> |
20 | #include <TopOpeBRep_VPointInter.hxx> |
21 | #include <TopOpeBRep_VPointInterIterator.hxx> |
7fd59977 |
22 | |
23 | //======================================================================= |
24 | //function : VPointInterIterator |
25 | //purpose : |
26 | //======================================================================= |
7fd59977 |
27 | TopOpeBRep_VPointInterIterator::TopOpeBRep_VPointInterIterator() : |
28 | myLineInter(NULL),myVPointIndex(0),myVPointNb(0),mycheckkeep(Standard_False) |
29 | {} |
30 | |
31 | //======================================================================= |
32 | //function : VPointInterIterator |
33 | //purpose : |
34 | //======================================================================= |
35 | |
36 | TopOpeBRep_VPointInterIterator::TopOpeBRep_VPointInterIterator |
37 | (const TopOpeBRep_LineInter& LI) |
38 | { |
39 | Init(LI); |
40 | } |
41 | |
42 | //======================================================================= |
43 | //function : Init |
44 | //purpose : |
45 | //======================================================================= |
46 | |
47 | void TopOpeBRep_VPointInterIterator::Init |
48 | (const TopOpeBRep_LineInter& LI, |
49 | const Standard_Boolean checkkeep) |
50 | { |
51 | myLineInter = (TopOpeBRep_LineInter*)&LI; |
52 | mycheckkeep = checkkeep; |
53 | Init(); |
54 | } |
55 | |
56 | //======================================================================= |
57 | //function : Init |
58 | //purpose : |
59 | //======================================================================= |
60 | |
61 | void TopOpeBRep_VPointInterIterator::Init() |
62 | { |
63 | myVPointIndex = 1; |
64 | myVPointNb = myLineInter->NbVPoint(); |
65 | if ( mycheckkeep ) { |
66 | while ( More() ) { |
67 | const TopOpeBRep_VPointInter& VP = CurrentVP(); |
7fd59977 |
68 | if (VP.Keep()) break; |
69 | else myVPointIndex++; |
70 | } |
71 | } |
72 | } |
73 | |
74 | //======================================================================= |
75 | //function : More |
76 | //purpose : |
77 | //======================================================================= |
78 | |
79 | Standard_Boolean TopOpeBRep_VPointInterIterator::More() const |
80 | { |
81 | return (myVPointIndex <= myVPointNb); |
82 | } |
83 | |
84 | //======================================================================= |
85 | //function : Next |
86 | //purpose : |
87 | //======================================================================= |
88 | |
89 | void TopOpeBRep_VPointInterIterator::Next() |
90 | { |
91 | myVPointIndex++; |
92 | if ( mycheckkeep ) { |
93 | while ( More() ) { |
94 | const TopOpeBRep_VPointInter& VP = CurrentVP(); |
7fd59977 |
95 | if (VP.Keep()) break; |
96 | else myVPointIndex++; |
97 | } |
98 | } |
99 | } |
100 | |
101 | //======================================================================= |
102 | //function : CurrentVP |
103 | //purpose : |
104 | //======================================================================= |
105 | |
106 | const TopOpeBRep_VPointInter& TopOpeBRep_VPointInterIterator::CurrentVP() |
107 | { |
108 | if (!More()) |
109 | Standard_ProgramError::Raise("TopOpeBRep_VPointInterIterator::CurrentVP"); |
110 | const TopOpeBRep_VPointInter& VP = myLineInter->VPoint(myVPointIndex); |
111 | return VP; |
112 | } |
113 | |
114 | //======================================================================= |
115 | //function : ChangeCurrentVP |
116 | //purpose : |
117 | //======================================================================= |
118 | |
119 | TopOpeBRep_VPointInter& TopOpeBRep_VPointInterIterator::ChangeCurrentVP() |
120 | { |
121 | if (!More()) |
122 | Standard_ProgramError::Raise("TopOpeBRep_VPointInterIterator::ChangeCurrentVP"); |
123 | TopOpeBRep_VPointInter& VP = myLineInter->ChangeVPoint(myVPointIndex); |
124 | return VP; |
125 | } |
126 | |
127 | //======================================================================= |
128 | //function : CurrentVPIndex |
129 | //purpose : |
130 | //======================================================================= |
131 | |
132 | Standard_Integer TopOpeBRep_VPointInterIterator::CurrentVPIndex()const |
133 | { |
134 | if (!More()) |
135 | Standard_ProgramError::Raise("TopOpeBRep_VPointInterIterator::CurrentVPIndex"); |
136 | return myVPointIndex; |
137 | } |
138 | |
139 | TopOpeBRep_PLineInter TopOpeBRep_VPointInterIterator::PLineInterDummy() const {return myLineInter;} |