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