0023640: Documentation for local sewing with BRepBuilderAPI_Sewing is missing
[occt.git] / src / AppParCurves / AppParCurves_MultiCurve.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
7fd59977 14
15#include <AppParCurves_MultiCurve.ixx>
16#include <TColgp_Array1OfPnt.hxx>
17#include <TColgp_Array1OfPnt2d.hxx>
18#include <Standard_OutOfRange.hxx>
19#include <BSplCLib.hxx>
20#include <PLib.hxx>
21
22
23AppParCurves_MultiCurve::AppParCurves_MultiCurve() {}
24
25
26AppParCurves_MultiCurve::AppParCurves_MultiCurve (const Standard_Integer NbPol)
27{
28 tabPoint = new AppParCurves_HArray1OfMultiPoint(1, NbPol);
29}
30
31
32
33AppParCurves_MultiCurve::AppParCurves_MultiCurve (const AppParCurves_Array1OfMultiPoint& tabMU)
34{
35 tabPoint = new AppParCurves_HArray1OfMultiPoint(1, tabMU.Length());
36 Standard_Integer i, Lower = tabMU.Lower();
37 for (i = 1; i <= tabMU.Length(); i++) {
38 tabPoint->SetValue(i, tabMU.Value(Lower+i-1));
39 }
40
41}
42
43void AppParCurves_MultiCurve::Delete()
44{}
45
46Standard_Integer AppParCurves_MultiCurve::Dimension (const Standard_Integer Index) const {
47 Standard_Integer Lo = tabPoint->Lower();
48 Standard_Integer nb = tabPoint->Value(Lo).NbPoints() + tabPoint->Value(Lo).NbPoints2d();
49 if ((Index <= 0) || (Index > nb)) {
50 Standard_OutOfRange::Raise();
51 }
52 return tabPoint->Value(Lo).Dimension(Index);
53}
54
55
56Standard_Integer AppParCurves_MultiCurve::NbCurves () const {
57 if (tabPoint.IsNull())
58 return 0;
59 AppParCurves_MultiPoint MP = tabPoint->Value(1);
60 return MP.NbPoints() + MP.NbPoints2d();
61}
62
63
64Standard_Integer AppParCurves_MultiCurve::NbPoles() const {
65 if (tabPoint.IsNull())
66 return 0;
67 return tabPoint->Length();
68}
69
70
71Standard_Integer AppParCurves_MultiCurve::Degree() const {
72 return tabPoint->Length()-1;
73}
74
75
76void AppParCurves_MultiCurve::SetNbPoles(const Standard_Integer nbPoles)
77{
78 tabPoint = new AppParCurves_HArray1OfMultiPoint(1, nbPoles);
79}
80
81
82void AppParCurves_MultiCurve::SetValue (const Standard_Integer Index,
83 const AppParCurves_MultiPoint& MPoint) {
84
85 if ((Index <= 0) || (Index > tabPoint->Length())) {
86 Standard_OutOfRange::Raise();
87 }
88 tabPoint->SetValue(Index, MPoint);
89}
90
91
92void AppParCurves_MultiCurve::Curve (const Standard_Integer CuIndex,
93 TColgp_Array1OfPnt& TabPnt) const {
94 if ((CuIndex <= 0)) {
95 Standard_OutOfRange::Raise();
96 }
97 for ( Standard_Integer i = 1; i <= tabPoint->Length(); i++) {
98 TabPnt(i) = tabPoint->Value(i).Point(CuIndex);
99 }
100}
101
102
103void AppParCurves_MultiCurve::Curve (const Standard_Integer CuIndex,
104 TColgp_Array1OfPnt2d& TabPnt2d) const {
105 if ((CuIndex <= 0)) {
106 Standard_OutOfRange::Raise();
107 }
108 for ( Standard_Integer i = 1; i <= tabPoint->Length(); i++) {
109 TabPnt2d(i) = tabPoint->Value(i).Point2d(CuIndex);
110 }
111}
112
113
114
115const gp_Pnt& AppParCurves_MultiCurve::Pole(const Standard_Integer CuIndex,
116 const Standard_Integer Nieme) const
117{
118 if ((CuIndex <= 0) && Nieme <= 0) {
119 Standard_OutOfRange::Raise();
120 }
121 return tabPoint->Value(Nieme).Point(CuIndex);
122}
123
124const gp_Pnt2d& AppParCurves_MultiCurve::Pole2d(const Standard_Integer CuIndex,
125 const Standard_Integer Nieme)const
126{
127 if ((CuIndex <= 0) && Nieme <= 0) {
128 Standard_OutOfRange::Raise();
129 }
130 return tabPoint->Value(Nieme).Point2d(CuIndex);
131}
132
133
134
135const AppParCurves_MultiPoint& AppParCurves_MultiCurve::Value (const Standard_Integer Index) const {
136 if ((Index <= 0) || (Index > tabPoint->Length())) {
137 Standard_OutOfRange::Raise();
138 }
139 return tabPoint->Value(Index);
140}
141
142void AppParCurves_MultiCurve::Transform(const Standard_Integer CuIndex,
143 const Standard_Real x,
144 const Standard_Real dx,
145 const Standard_Real y,
146 const Standard_Real dy,
147 const Standard_Real z,
148 const Standard_Real dz)
149{
150 if (Dimension(CuIndex) != 3) Standard_OutOfRange::Raise();
151
152 for (Standard_Integer i = 1 ; i <= tabPoint->Length(); i++) {
153 (tabPoint->ChangeValue(i)).Transform(CuIndex, x, dx, y, dy, z, dz);
154 }
155}
156
157void AppParCurves_MultiCurve::Transform2d(const Standard_Integer CuIndex,
158 const Standard_Real x,
159 const Standard_Real dx,
160 const Standard_Real y,
161 const Standard_Real dy)
162{
163 if (Dimension(CuIndex) != 2) Standard_OutOfRange::Raise();
164
165 for (Standard_Integer i = 1 ; i <= tabPoint->Length(); i++) {
166 (tabPoint->ChangeValue(i)).Transform2d(CuIndex, x, dx, y, dy);
167 }
168}
169
170
171void AppParCurves_MultiCurve::Value (const Standard_Integer CuIndex,
172 const Standard_Real U, gp_Pnt& Pt) const {
173
174 if (Dimension(CuIndex) != 3)Standard_OutOfRange::Raise();
175
176 TColgp_Array1OfPnt TabPoles(1, tabPoint->Length());
177
178 for (Standard_Integer i =1 ; i <= tabPoint->Length(); i++) {
179 TabPoles(i) = tabPoint->Value(i).Point(CuIndex);
180 }
181
182 BSplCLib::D0 (U, TabPoles,PLib::NoWeights(), Pt);
183}
184
185
186void AppParCurves_MultiCurve::Value (const Standard_Integer CuIndex,
187 const Standard_Real U, gp_Pnt2d& Pt) const {
188 if (Dimension(CuIndex) != 2) {
189 Standard_OutOfRange::Raise();
190 }
191
192 TColgp_Array1OfPnt2d TabPole(1, tabPoint->Length());
193
194 for (Standard_Integer i =1 ; i <= tabPoint->Length(); i++) {
195 TabPole(i) = tabPoint->Value(i).Point2d(CuIndex);
196 }
197
198 BSplCLib::D0 (U, TabPole, PLib::NoWeights(), Pt);
199}
200
201
202void AppParCurves_MultiCurve::D1 (const Standard_Integer CuIndex,
203 const Standard_Real U,
204 gp_Pnt& Pt,
205 gp_Vec& V1) const {
206
207 if (Dimension(CuIndex) != 3) {
208 Standard_OutOfRange::Raise();
209 }
210
211 TColgp_Array1OfPnt TabPole(1, tabPoint->Length());
212
213 for (Standard_Integer i =1 ; i <= tabPoint->Length(); i++) {
214 TabPole(i) = tabPoint->Value(i).Point(CuIndex);
215 }
216
217 BSplCLib::D1 (U, TabPole, PLib::NoWeights(), Pt, V1);
218}
219
220
221void AppParCurves_MultiCurve::D2 (const Standard_Integer CuIndex,
222 const Standard_Real U,
223 gp_Pnt& Pt,
224 gp_Vec& V1,
225 gp_Vec& V2) const {
226
227 if (Dimension(CuIndex) != 3) {
228 Standard_OutOfRange::Raise();
229 }
230
231 TColgp_Array1OfPnt TabPole(1, tabPoint->Length());
232
233 for (Standard_Integer i =1 ; i <= tabPoint->Length(); i++) {
234 TabPole(i) = tabPoint->Value(i).Point(CuIndex);
235 }
236
237 BSplCLib::D2 (U, TabPole, PLib::NoWeights(), Pt, V1, V2);
238}
239
240
241void AppParCurves_MultiCurve::D1 (const Standard_Integer CuIndex,
242 const Standard_Real U, gp_Pnt2d& Pt, gp_Vec2d& V1) const {
243
244 if (Dimension(CuIndex) != 2) {
245 Standard_OutOfRange::Raise();
246 }
247
248 TColgp_Array1OfPnt2d TabPole(1, tabPoint->Length());
249
250 for (Standard_Integer i =1 ; i <= tabPoint->Length(); i++) {
251 TabPole(i) = tabPoint->Value(i).Point2d(CuIndex);
252 }
253
254 BSplCLib::D1 (U, TabPole, PLib::NoWeights(), Pt, V1);
255}
256
257
258void AppParCurves_MultiCurve::D2 (const Standard_Integer CuIndex,
259 const Standard_Real U,
260 gp_Pnt2d& Pt,
261 gp_Vec2d& V1,
262 gp_Vec2d& V2) const {
263
264 if (Dimension(CuIndex) != 2) {
265 Standard_OutOfRange::Raise();
266 }
267
268 TColgp_Array1OfPnt2d TabPole(1, tabPoint->Length());
269
270 for (Standard_Integer i =1 ; i <= tabPoint->Length(); i++) {
271 TabPole(i) = tabPoint->Value(i).Point2d(CuIndex);
272 }
273
274 BSplCLib::D2(U, TabPole, PLib::NoWeights(), Pt, V1, V2);
275}
276
277
278
279void AppParCurves_MultiCurve::Dump(Standard_OStream& o) const
280{
281 o << "AppParCurves_MultiCurve dump:" << endl;
282 o << " It contains " << NbCurves() << " Bezier curves of degree " << tabPoint->Length()-1 << endl;
283 o << " The poles are: " << endl;
284/* for (Standard_Integer i = 1; i <= NbCurves(); i++) {
285 o << " Curve No. " << i << endl;
286 if (Dimension(i) == 3) {
287 for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
288 o << " Pole No. " << j << ": " << endl;
289 o << " Pole x = " << (tabPoint->Value(j)->Point(i)).X() << endl;
290 o << " Pole y = " << (tabPoint->Value(j)->Point(i)).Y() << endl;
291 o << " Pole z = " << (tabPoint->Value(j)->Point(i)).Z() << endl;
292 }
293 }
294 else {
295 for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
296 o << " Pole No. " << j << ": " << endl;
297 o << " Pole x = " << (tabPoint->Value(j)->Point2d(i)).X() << endl;
298 o << " Pole y = " << (tabPoint->Value(j)->Point2d(i)).Y() << endl;
299 }
300 }
301 }
302*/
303}