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