b311480e |
1 | // Created on: 1991-03-16 |
2 | // Created by: LPA |
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 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <AppDef_MultiPointConstraint.hxx> |
19 | #include <gp_Vec.hxx> |
20 | #include <gp_Vec2d.hxx> |
21 | #include <MMgt_TShared.hxx> |
7fd59977 |
22 | #include <Standard_ConstructionError.hxx> |
42cf5bc1 |
23 | #include <Standard_DimensionError.hxx> |
24 | #include <Standard_OutOfRange.hxx> |
7fd59977 |
25 | #include <TColgp_HArray1OfPnt.hxx> |
26 | #include <TColgp_HArray1OfPnt2d.hxx> |
27 | #include <TColgp_HArray1OfVec.hxx> |
28 | #include <TColgp_HArray1OfVec2d.hxx> |
29 | |
7fd59977 |
30 | AppDef_MultiPointConstraint::AppDef_MultiPointConstraint() {} |
31 | |
32 | |
33 | |
34 | AppDef_MultiPointConstraint:: |
35 | AppDef_MultiPointConstraint(const Standard_Integer NbPoles, |
36 | const Standard_Integer NbPoles2d): |
37 | AppParCurves_MultiPoint(NbPoles, NbPoles2d) |
38 | { |
39 | } |
40 | |
41 | AppDef_MultiPointConstraint:: |
42 | AppDef_MultiPointConstraint(const TColgp_Array1OfPnt& tabP): |
43 | AppParCurves_MultiPoint(tabP) |
44 | { |
45 | } |
46 | |
47 | AppDef_MultiPointConstraint:: |
48 | AppDef_MultiPointConstraint(const TColgp_Array1OfPnt2d& tabP2d): |
49 | AppParCurves_MultiPoint(tabP2d) |
50 | { |
51 | } |
52 | |
53 | |
54 | |
55 | |
56 | AppDef_MultiPointConstraint:: |
57 | AppDef_MultiPointConstraint(const TColgp_Array1OfPnt& tabP, |
58 | const TColgp_Array1OfPnt2d& tabP2d): |
59 | AppParCurves_MultiPoint(tabP, tabP2d) |
60 | { |
61 | } |
62 | |
63 | |
64 | AppDef_MultiPointConstraint::AppDef_MultiPointConstraint |
65 | (const TColgp_Array1OfPnt& tabP, |
66 | const TColgp_Array1OfPnt2d& tabP2d, |
67 | const TColgp_Array1OfVec& tabVec, |
68 | const TColgp_Array1OfVec2d& tabVec2d, |
69 | const TColgp_Array1OfVec& tabCur, |
70 | const TColgp_Array1OfVec2d& tabCur2d): |
71 | AppParCurves_MultiPoint(tabP, tabP2d) { |
72 | |
73 | if ((tabP.Length() != tabVec.Length()) || |
74 | (tabP2d.Length() != tabVec2d.Length()) || |
75 | (tabCur.Length() != tabP.Length()) || |
76 | (tabCur2d.Length() != tabP2d.Length())) { |
77 | Standard_ConstructionError::Raise(); |
78 | } |
7fd59977 |
79 | |
5b111128 |
80 | tabTang = new TColgp_HArray1OfVec(1, tabVec.Length()); |
81 | tabTang2d = new TColgp_HArray1OfVec2d(1, tabVec2d.Length()); |
7fd59977 |
82 | |
83 | Standard_Integer i, Lower = tabVec.Lower(); |
84 | for (i = 1; i <= tabVec.Length(); i++) { |
85 | tabTang->SetValue(i, tabVec.Value(Lower+i-1)); |
86 | } |
87 | Lower = tabVec2d.Lower(); |
88 | for (i = 1; i <= tabVec2d.Length(); i++) { |
89 | tabTang2d->SetValue(i, tabVec2d.Value(Lower+i-1)); |
90 | } |
91 | |
5b111128 |
92 | tabCurv = new TColgp_HArray1OfVec(1, tabCur.Length()); |
93 | tabCurv2d = new TColgp_HArray1OfVec2d(1, tabCur2d.Length()); |
7fd59977 |
94 | |
95 | Lower = tabCur.Lower(); |
96 | for (i = 1; i <= tabVec.Length(); i++) { |
97 | tabCurv->SetValue(i, tabCur.Value(Lower+i-1)); |
98 | } |
99 | Lower = tabCur2d.Lower(); |
100 | for (i = 1; i <= tabCur2d.Length(); i++) { |
101 | tabCurv2d->SetValue(i, tabCur2d.Value(Lower+i-1)); |
102 | } |
103 | |
104 | } |
105 | |
7fd59977 |
106 | AppDef_MultiPointConstraint::AppDef_MultiPointConstraint |
107 | (const TColgp_Array1OfPnt& tabP, |
108 | const TColgp_Array1OfPnt2d& tabP2d, |
109 | const TColgp_Array1OfVec& tabVec, |
110 | const TColgp_Array1OfVec2d& tabVec2d): |
5b111128 |
111 | AppParCurves_MultiPoint(tabP, tabP2d) |
112 | { |
7fd59977 |
113 | |
114 | if ((tabP.Length() != tabVec.Length()) || |
115 | (tabP2d.Length() != tabVec2d.Length())) { |
116 | Standard_ConstructionError::Raise(); |
117 | } |
118 | |
5b111128 |
119 | tabTang = new TColgp_HArray1OfVec(1, tabVec.Length()); |
120 | tabTang2d = new TColgp_HArray1OfVec2d(1, tabVec2d.Length()); |
7fd59977 |
121 | |
122 | Standard_Integer i, Lower = tabVec.Lower(); |
123 | for (i = 1; i <= tabVec.Length(); i++) { |
124 | tabTang->SetValue(i, tabVec.Value(Lower+i-1)); |
125 | } |
126 | Lower = tabVec2d.Lower(); |
127 | for (i = 1; i <= tabVec2d.Length(); i++) { |
128 | tabTang2d->SetValue(i, tabVec2d.Value(Lower+i-1)); |
129 | } |
130 | } |
131 | |
132 | |
133 | |
134 | AppDef_MultiPointConstraint::AppDef_MultiPointConstraint ( |
135 | const TColgp_Array1OfPnt& tabP, |
136 | const TColgp_Array1OfVec& tabVec): |
137 | AppParCurves_MultiPoint(tabP) { |
138 | |
139 | if (tabP.Length() != tabVec.Length()) { |
140 | Standard_ConstructionError::Raise(); |
141 | } |
5b111128 |
142 | |
143 | tabTang = new TColgp_HArray1OfVec(1, tabVec.Length()); |
7fd59977 |
144 | |
145 | Standard_Integer i, Lower = tabVec.Lower(); |
146 | for (i = 1; i <= tabVec.Length(); i++) { |
147 | tabTang->SetValue(i, tabVec.Value(Lower+i-1)); |
148 | } |
149 | } |
150 | |
151 | |
152 | AppDef_MultiPointConstraint::AppDef_MultiPointConstraint |
153 | (const TColgp_Array1OfPnt& tabP, |
154 | const TColgp_Array1OfVec& tabVec, |
155 | const TColgp_Array1OfVec& tabCur): |
156 | AppParCurves_MultiPoint(tabP) { |
157 | |
158 | if ((tabP.Length() != tabVec.Length()) || |
159 | (tabP.Length() != tabCur.Length())) { |
160 | Standard_ConstructionError::Raise(); |
161 | } |
7fd59977 |
162 | |
5b111128 |
163 | tabTang = new TColgp_HArray1OfVec(1, tabVec.Length()); |
7fd59977 |
164 | Standard_Integer i, Lower = tabVec.Lower(); |
165 | for (i = 1; i <= tabVec.Length(); i++) { |
166 | tabTang->SetValue(i, tabVec.Value(Lower+i-1)); |
167 | } |
168 | |
5b111128 |
169 | tabCurv = new TColgp_HArray1OfVec(1, tabCur.Length()); |
7fd59977 |
170 | Lower = tabCur.Lower(); |
171 | for (i = 1; i <= tabCur.Length(); i++) { |
172 | tabCurv->SetValue(i, tabCur.Value(Lower+i-1)); |
173 | } |
174 | } |
175 | |
176 | |
177 | |
178 | AppDef_MultiPointConstraint::AppDef_MultiPointConstraint |
179 | (const TColgp_Array1OfPnt2d& tabP2d, |
180 | const TColgp_Array1OfVec2d& tabVec2d): |
181 | |
182 | AppParCurves_MultiPoint(tabP2d) { |
183 | |
184 | if (tabP2d.Length() != tabVec2d.Length()) { |
185 | Standard_ConstructionError::Raise(); |
186 | } |
187 | |
5b111128 |
188 | tabTang2d = new TColgp_HArray1OfVec2d(1, tabVec2d.Length()); |
7fd59977 |
189 | Standard_Integer i, Lower = tabVec2d.Lower(); |
190 | for (i = 1; i <= tabVec2d.Length(); i++) { |
191 | tabTang2d->SetValue(i, tabVec2d.Value(Lower+i-1)); |
192 | } |
193 | |
194 | } |
195 | |
196 | |
197 | |
198 | AppDef_MultiPointConstraint::AppDef_MultiPointConstraint |
199 | (const TColgp_Array1OfPnt2d& tabP2d, |
200 | const TColgp_Array1OfVec2d& tabVec2d, |
201 | const TColgp_Array1OfVec2d& tabCur2d): |
202 | AppParCurves_MultiPoint(tabP2d) { |
203 | |
204 | if ((tabP2d.Length() != tabVec2d.Length()) || |
205 | (tabCur2d.Length() != tabP2d.Length())) { |
206 | Standard_ConstructionError::Raise(); |
207 | } |
5b111128 |
208 | |
209 | tabTang2d = new TColgp_HArray1OfVec2d(1, tabVec2d.Length()); |
7fd59977 |
210 | Standard_Integer i, Lower = tabVec2d.Lower(); |
211 | for (i = 1; i <= tabVec2d.Length(); i++) { |
212 | tabTang2d->SetValue(i, tabVec2d.Value(Lower+i-1)); |
213 | } |
214 | |
5b111128 |
215 | tabCurv2d = new TColgp_HArray1OfVec2d(1, tabCur2d.Length()); |
7fd59977 |
216 | Lower = tabCur2d.Lower(); |
217 | for (i = 1; i <= tabCur2d.Length(); i++) { |
218 | tabCurv2d->SetValue(i, tabCur2d.Value(Lower+i-1)); |
219 | } |
220 | } |
221 | |
222 | |
223 | |
224 | void AppDef_MultiPointConstraint::SetTang (const Standard_Integer Index, |
225 | const gp_Vec& Tang) { |
226 | if (tabTang.IsNull()) |
227 | tabTang = new TColgp_HArray1OfVec (1, nbP); |
228 | if ((Index <= 0) || (Index > nbP)) { |
229 | Standard_OutOfRange::Raise(); |
230 | } |
231 | tabTang->SetValue(Index, Tang); |
232 | } |
233 | |
234 | |
235 | gp_Vec AppDef_MultiPointConstraint::Tang (const Standard_Integer Index) const { |
236 | if ((Index <= 0) || (Index > nbP)) { |
237 | Standard_OutOfRange::Raise(); |
238 | } |
239 | return tabTang->Value(Index); |
240 | } |
241 | |
242 | |
243 | |
244 | void AppDef_MultiPointConstraint::SetTang2d (const Standard_Integer Index, |
245 | const gp_Vec2d& Tang2d){ |
246 | if (tabTang2d.IsNull()) |
247 | tabTang2d = new TColgp_HArray1OfVec2d (1, nbP2d); |
248 | |
249 | if ((Index <= nbP) || |
250 | (Index > nbP+nbP2d)) { |
251 | Standard_OutOfRange::Raise(); |
252 | } |
253 | tabTang2d->SetValue(Index-nbP, Tang2d); |
254 | } |
255 | |
256 | |
257 | gp_Vec2d AppDef_MultiPointConstraint::Tang2d (const Standard_Integer Index) const { |
258 | if ((Index <= nbP) || |
259 | (Index > nbP+nbP2d)) { |
260 | Standard_OutOfRange::Raise(); |
261 | } |
262 | return tabTang2d->Value(Index-nbP); |
263 | } |
264 | |
265 | |
266 | void AppDef_MultiPointConstraint::SetCurv (const Standard_Integer Index, const gp_Vec& Curv) { |
267 | if (tabCurv.IsNull()) |
268 | tabCurv = new TColgp_HArray1OfVec (1, nbP); |
269 | if ((Index <= 0) || (Index > nbP)) { |
270 | Standard_OutOfRange::Raise(); |
271 | } |
272 | tabCurv->SetValue(Index, Curv); |
273 | } |
274 | |
275 | |
276 | gp_Vec AppDef_MultiPointConstraint::Curv (const Standard_Integer Index) const { |
277 | if ((Index <= 0) || (Index > nbP)) { |
278 | Standard_OutOfRange::Raise(); |
279 | } |
280 | return tabCurv->Value(Index); |
281 | } |
282 | |
283 | |
284 | |
285 | void AppDef_MultiPointConstraint::SetCurv2d (const Standard_Integer Index, |
286 | const gp_Vec2d& Curv2d){ |
287 | if (tabCurv2d.IsNull()) |
288 | tabCurv2d = new TColgp_HArray1OfVec2d (1, nbP2d); |
289 | if ((Index <= nbP) || |
290 | (Index > nbP+nbP2d)) { |
291 | Standard_OutOfRange::Raise(); |
292 | } |
293 | tabCurv2d->SetValue(Index- nbP, Curv2d); |
294 | } |
295 | |
296 | |
297 | |
298 | gp_Vec2d AppDef_MultiPointConstraint::Curv2d (const Standard_Integer Index) const { |
299 | if ((Index <= nbP) || |
300 | (Index > nbP+nbP2d)) { |
301 | Standard_OutOfRange::Raise(); |
302 | } |
303 | return tabCurv2d->Value(Index - nbP); |
304 | } |
305 | |
306 | |
307 | Standard_Boolean AppDef_MultiPointConstraint::IsTangencyPoint() const |
308 | { |
309 | return !(tabTang.IsNull() && tabTang2d.IsNull()); |
310 | } |
311 | |
312 | Standard_Boolean AppDef_MultiPointConstraint::IsCurvaturePoint() const |
313 | { |
314 | return !(tabCurv.IsNull() && tabCurv2d.IsNull()); |
315 | } |
316 | |
317 | |
318 | |
319 | |
320 | void AppDef_MultiPointConstraint::Dump(Standard_OStream& o) const |
321 | { |
322 | o << "AppDef_MultiPointConstraint dump:" << endl; |
323 | } |