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