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