b311480e |
1 | // Created on: 1991-06-21 |
2 | // Created by: Didier PIFFAULT |
3 | // Copyright (c) 1991-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 | |
18 | #include <Intf_SectionLine.hxx> |
19 | #include <Intf_SectionPoint.hxx> |
20 | #include <Standard_OutOfRange.hxx> |
7fd59977 |
21 | |
22 | //======================================================================= |
23 | //function : Intf_SectionLine |
24 | //purpose : Construct |
25 | //======================================================================= |
7fd59977 |
26 | Intf_SectionLine::Intf_SectionLine () |
27 | : closed(Standard_False) |
28 | {} |
29 | |
30 | //======================================================================= |
31 | //function : Intf_SectionLine |
32 | //purpose : Copy |
33 | //======================================================================= |
34 | |
35 | Intf_SectionLine::Intf_SectionLine (const Intf_SectionLine& Other) |
36 | : closed(Standard_False) |
37 | { |
38 | myPoints=Other.myPoints; |
39 | } |
40 | |
41 | |
42 | //======================================================================= |
43 | //function : Append |
44 | //purpose : |
45 | //======================================================================= |
46 | |
47 | void Intf_SectionLine::Append (const Intf_SectionPoint& Pi) |
48 | { |
49 | myPoints.Append(Pi); |
50 | } |
51 | |
52 | //======================================================================= |
53 | //function : Append |
54 | //purpose : |
55 | //======================================================================= |
56 | |
57 | void Intf_SectionLine::Append (Intf_SectionLine& LS) |
58 | { |
59 | myPoints.Append(LS.myPoints); |
60 | } |
61 | |
62 | //======================================================================= |
63 | //function : Prepend |
64 | //purpose : |
65 | //======================================================================= |
66 | |
67 | void Intf_SectionLine::Prepend (const Intf_SectionPoint& Pi) |
68 | { |
69 | myPoints.Prepend(Pi); |
70 | } |
71 | |
72 | //======================================================================= |
73 | //function : Prepend |
74 | //purpose : |
75 | //======================================================================= |
76 | |
77 | void Intf_SectionLine::Prepend (Intf_SectionLine& LS) |
78 | { |
79 | myPoints.Prepend(LS.myPoints); |
80 | } |
81 | |
82 | //======================================================================= |
83 | //function : Reverse |
84 | //purpose : |
85 | //======================================================================= |
86 | |
87 | void Intf_SectionLine::Reverse () |
88 | { |
89 | myPoints.Reverse(); |
90 | } |
91 | |
92 | //======================================================================= |
93 | //function : Close |
94 | //purpose : |
95 | //======================================================================= |
96 | |
97 | void Intf_SectionLine::Close () |
98 | { |
99 | closed=Standard_True; |
100 | } |
101 | |
102 | |
103 | //======================================================================= |
104 | //function : GetPoint |
105 | //purpose : |
106 | //======================================================================= |
107 | |
108 | const Intf_SectionPoint& Intf_SectionLine::GetPoint |
109 | (const Standard_Integer index) const |
110 | { |
111 | return myPoints.Value(index); |
112 | } |
113 | |
114 | |
115 | //======================================================================= |
116 | //function : IsClosed |
117 | //purpose : |
118 | //======================================================================= |
119 | |
120 | Standard_Boolean Intf_SectionLine::IsClosed () const |
121 | { |
122 | //return closed; |
123 | // On ne peut fermer une ligne de section inseree dans une liste car |
124 | // la fonction Value() copie l'element avant d'appeler la fonction. |
125 | // C'est donc la copie qui est modifiee. |
126 | // Pour la sequence myPoints on a un pointeur donc le pb ne se pose pas. |
127 | |
128 | return (myPoints.First()==myPoints.Last()); |
129 | } |
130 | |
131 | //======================================================================= |
132 | //function : Contains |
133 | //purpose : |
134 | //======================================================================= |
135 | |
136 | Standard_Boolean Intf_SectionLine::Contains |
137 | (const Intf_SectionPoint& ThePI) const |
138 | { |
139 | for (Standard_Integer i = 1; i <= myPoints.Length();i++) |
140 | if (ThePI.IsEqual(myPoints(i))) return Standard_True; |
141 | return Standard_False; |
142 | } |
143 | |
144 | |
145 | //======================================================================= |
146 | //function : IsEnd |
147 | //purpose : |
148 | //======================================================================= |
149 | |
150 | Standard_Integer Intf_SectionLine::IsEnd |
151 | (const Intf_SectionPoint& ThePI) const |
152 | { |
153 | if (myPoints.First().IsEqual(ThePI)) return 1; |
154 | if (myPoints.Last().IsEqual(ThePI)) return myPoints.Length(); |
155 | return 0; |
156 | } |
157 | |
158 | |
159 | //======================================================================= |
160 | //function : IsEqual |
161 | //purpose : |
162 | //======================================================================= |
163 | |
164 | Standard_Boolean Intf_SectionLine::IsEqual |
165 | (const Intf_SectionLine& Other) const |
166 | { |
167 | if (myPoints.Length() != Other.myPoints.Length()) |
168 | return Standard_False; |
169 | for (Standard_Integer i = 1; i <= myPoints.Length(); i++) |
170 | if (!myPoints(i).IsEqual(Other.myPoints(i))) return Standard_False; |
171 | return Standard_True; |
172 | } |
173 | |
174 | //======================================================================= |
175 | //function : Dump |
176 | //purpose : |
177 | //======================================================================= |
178 | |
179 | void Intf_SectionLine::Dump |
180 | (const Standard_Integer Indent) const |
181 | { |
04232180 |
182 | for (Standard_Integer id=0; id<Indent; id++) std::cout << " "; |
183 | std::cout << "LS "; |
184 | if (IsClosed()) std::cout << "Closed :" << std::endl; |
185 | else std::cout << "Open :" << std::endl; |
7fd59977 |
186 | for (Standard_Integer p=1; p<=myPoints.Length(); p++) { |
187 | myPoints.Value(p).Dump(Indent+2); |
188 | } |
189 | } |