0030520: VIS - IVtkTools_ShapePicker::GetPickPosition() returns incorrect point
[occt.git] / src / HLRBRep / HLRBRep_Curve.cxx
CommitLineData
b311480e 1// Created on: 1992-03-13
2// Created by: Christophe MARION
3// Copyright (c) 1992-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
42cf5bc1 17
18#include <BRepAdaptor_Curve.hxx>
19#include <Geom_BezierCurve.hxx>
20#include <Geom_BSplineCurve.hxx>
7fd59977 21#include <gp.hxx>
22#include <gp_Ax3.hxx>
42cf5bc1 23#include <gp_Circ2d.hxx>
24#include <gp_Dir2d.hxx>
25#include <gp_Elips2d.hxx>
26#include <gp_Hypr2d.hxx>
27#include <gp_Lin2d.hxx>
28#include <gp_Parab2d.hxx>
7fd59977 29#include <gp_Pln.hxx>
42cf5bc1 30#include <gp_Pnt.hxx>
31#include <gp_Pnt2d.hxx>
32#include <gp_Vec.hxx>
33#include <gp_Vec2d.hxx>
7fd59977 34#include <HLRAlgo.hxx>
35#include <HLRAlgo_Projector.hxx>
36#include <HLRBRep_CLProps.hxx>
42cf5bc1 37#include <HLRBRep_Curve.hxx>
38#include <Precision.hxx>
39#include <ProjLib.hxx>
40#include <Standard_DomainError.hxx>
41#include <Standard_NoSuchObject.hxx>
42#include <Standard_OutOfRange.hxx>
43#include <StdFail_UndefinedDerivative.hxx>
44#include <TColgp_Array1OfPnt.hxx>
45#include <TopoDS_Edge.hxx>
7fd59977 46
733a0e55 47//OCC155 // jfa 05.03.2002 // bad vectors projection
7fd59977 48//=======================================================================
49//function : HLRBRep_Curve
50//purpose :
51//=======================================================================
7fd59977 52HLRBRep_Curve::HLRBRep_Curve ()
53{}
54
55//=======================================================================
56//function : Curve
57//purpose :
58//=======================================================================
59
60void HLRBRep_Curve::Curve (const TopoDS_Edge& E)
61{ myCurve.Initialize(E); }
62
63//=======================================================================
64//function : Parameter2d
65//purpose :
66//=======================================================================
67
68Standard_Real
69HLRBRep_Curve::Parameter2d (const Standard_Real P3d) const
70{
7fd59977 71 // Mathematical formula for lines
72
73 // myOF P3d (myOF myVX - myOZ myVX + myOX myVZ)
733a0e55 74 // Res -> --------------------------------------------
7fd59977 75 // (-myOF + myOZ) (-myOF + myOZ + P3d myVZ)
76
5c953701 77 switch (myType)
78 {
79 case GeomAbs_Line:
80 if (((HLRAlgo_Projector*) myProj)->Perspective()) {
81 const Standard_Real FmOZ = myOF - myOZ;
82 return myOF * P3d * (myVX * FmOZ + myOX * myVZ) / (FmOZ * (FmOZ - P3d * myVZ));
83 }
84 return P3d * myVX;
85
86 case GeomAbs_Ellipse:
87 return P3d + myOX;
1aec3320 88
89 default: // implemented to avoid gcc compiler warnings
90 break;
7fd59977 91 }
733a0e55 92 return P3d;
7fd59977 93}
94
95//=======================================================================
96//function : Parameter3d
97//purpose :
98//=======================================================================
99
100Standard_Real
101HLRBRep_Curve::Parameter3d (const Standard_Real P2d) const
102{
7fd59977 103 // Mathematical formula for lines
104
105 // 2
106 // (-myOF + myOZ) P2d
107 // P3d -> -----------------------------------------------------
108 // (myOF - myOZ) (myOF myVX + P2d myVZ) + myOF myOX myVZ
109
7fd59977 110 if (myType == GeomAbs_Line) {
111 if (((HLRAlgo_Projector*) myProj)->Perspective()) {
733a0e55
S
112 const Standard_Real FmOZ = myOF - myOZ;
113 return P2d * FmOZ * FmOZ / (FmOZ * (myOF * myVX + P2d * myVZ) + myOF * myOX * myVZ);
7fd59977 114 }
5ec5d80d 115 return ((myVX <= gp::Resolution())? P2d : (P2d / myVX));
7fd59977 116 }
117
118 else if (myType == GeomAbs_Ellipse) {
733a0e55 119 return P2d - myOX;
7fd59977 120 }
121
733a0e55 122 return P2d;
7fd59977 123}
124
125//=======================================================================
126//function : Update
127//purpose :
128//=======================================================================
129
681f3919 130Standard_Real HLRBRep_Curve::Update(
131 Standard_Real TotMin[16], Standard_Real TotMax[16])
7fd59977 132{
133 GeomAbs_CurveType typ = HLRBRep_BCurveTool::GetType(myCurve);
134 myType = GeomAbs_OtherCurve;
135
136 switch (typ) {
137
138 case GeomAbs_Line:
139 myType = typ;
140 break;
141
142 case GeomAbs_Circle:
143 if (!((HLRAlgo_Projector*) myProj)->Perspective()) {
144 gp_Dir D1 = HLRBRep_BCurveTool::Circle(myCurve).Axis().Direction();
145 D1.Transform(((HLRAlgo_Projector*) myProj)->Transformation());
146 if (D1.IsParallel(gp::DZ(),Precision::Angular()))
733a0e55 147 myType = GeomAbs_Circle;
7fd59977 148 else if (Abs(D1.Dot(gp::DZ())) < Precision::Angular()*10) //*10: The minor radius of ellipse should not be too small.
733a0e55 149 myType = GeomAbs_OtherCurve;
7fd59977 150 else {
733a0e55
S
151 myType = GeomAbs_Ellipse;
152 // compute the angle offset
153 gp_Dir D3 = D1.Crossed(gp::DZ());
154 gp_Dir D2 = HLRBRep_BCurveTool::Circle(myCurve).XAxis().Direction();
155 D2.Transform(((HLRAlgo_Projector*) myProj)->Transformation());
156 myOX = D3.AngleWithRef(D2,D1);
7fd59977 157 }
158 }
159 break;
160
161 case GeomAbs_Ellipse:
162 if (!((HLRAlgo_Projector*) myProj)->Perspective()) {
163 gp_Dir D1 = HLRBRep_BCurveTool::Ellipse(myCurve).Axis().Direction();
164 D1.Transform(((HLRAlgo_Projector*) myProj)->Transformation());
165 if (D1.IsParallel(gp::DZ(),Precision::Angular())) {
733a0e55
S
166 myOX = 0.; // no offset on the angle
167 myType = GeomAbs_Ellipse;
7fd59977 168 }
169 }
170 break;
171
172 case GeomAbs_BezierCurve:
173 if (HLRBRep_BCurveTool::Degree(myCurve) == 1)
174 myType = GeomAbs_Line;
175 else if (!((HLRAlgo_Projector*) myProj)->Perspective())
176 myType = typ;
177 break;
178
179 case GeomAbs_BSplineCurve:
180 if (!((HLRAlgo_Projector*) myProj)->Perspective())
181 myType = typ;
182 break;
183
184 default:
185 break;
186 }
187
188 if (myType == GeomAbs_Line) {
189 // compute the values for a line
190 gp_Lin L;
191 Standard_Real l3d = 1.; // length of the 3d bezier curve
192 if (HLRBRep_BCurveTool::GetType(myCurve) == GeomAbs_Line) {
193 L = HLRBRep_BCurveTool::Line(myCurve);
194 }
195 else { // bezier degree 1
196 gp_Pnt PL;
197 gp_Vec VL;
198 HLRBRep_BCurveTool::D1(myCurve,0,PL,VL);
199 L = gp_Lin(PL,VL);
200 l3d = PL.Distance(HLRBRep_BCurveTool::Value(myCurve,1.));
201 }
202 gp_Pnt P = L.Location();
203 gp_Vec V = L.Direction();
204 P.Transform(((HLRAlgo_Projector*) myProj)->Transformation());
205 V.Transform(((HLRAlgo_Projector*) myProj)->Transformation());
206 if (((HLRAlgo_Projector*) myProj)->Perspective()) {
207 gp_Pnt2d F;
208 gp_Vec2d VFX;
209 D1(0.,F,VFX);
210 VFX.Normalize();
211 myVX = (VFX.X()*V.X()+VFX.Y()*V.Y()) * l3d;
212 Standard_Real l = - (VFX.X()*F.X() + VFX.Y()*F.Y());
213 F.SetCoord(F.X()+VFX.X()*l,F.Y()+VFX.Y()*l);
214 myOX = VFX.X()*(P.X()-F.X()) + VFX.Y()*(P.Y()-F.Y());
215 gp_Vec VFZ(-F.X(),-F.Y(),((HLRAlgo_Projector*) myProj)->Focus());
216 myOF = VFZ.Magnitude();
217 VFZ /= myOF;
218 myVZ = VFZ * V;
219 myVZ *= l3d;
220 myOZ = VFZ * gp_Vec(P.X()-F.X(),P.Y()-F.Y(),P.Z());
221 }
222 else myVX = Sqrt(V.X() * V.X() + V.Y() * V.Y()) * l3d;
223 }
224 return(UpdateMinMax(TotMin,TotMax));
225}
226
227//=======================================================================
228//function : UpdateMinMax
229//purpose :
230//=======================================================================
231
681f3919 232Standard_Real HLRBRep_Curve::UpdateMinMax(
233 Standard_Real TotMin[16], Standard_Real TotMax[16])
7fd59977 234{
235 Standard_Real a = HLRBRep_BCurveTool::FirstParameter(myCurve);
236 Standard_Real b = HLRBRep_BCurveTool::LastParameter(myCurve);
237 Standard_Real x,y,z,tolMinMax = 0;
238 ((HLRAlgo_Projector*) myProj)->Project(Value3D(a),x,y,z);
239 HLRAlgo::UpdateMinMax(x,y,z,TotMin,TotMax);
240
241 if (myType != GeomAbs_Line) {
242 Standard_Integer nbPnt = 30;
243 Standard_Integer i;
244 Standard_Real step = (b-a)/(nbPnt+1);
7fd59977 245 Standard_Real xa,ya,za,xb =0.,yb =0.,zb =0.;
7fd59977 246 Standard_Real dx1,dy1,dz1,dd1;
247 Standard_Real dx2,dy2,dz2,dd2;
248
249 for (i = 1; i <= nbPnt; i++) {
250 a += step;
251 xa = xb; ya = yb; za = zb;
252 xb = x ; yb = y ; zb = z ;
253 ((HLRAlgo_Projector*) myProj)->Project(Value3D(a),x,y,z);
254 HLRAlgo::UpdateMinMax(x,y,z,TotMin,TotMax);
733a0e55
S
255 if (i >= 2) {
256 dx1 = x - xa; dy1 = y - ya; dz1 = z - za;
257 dd1 = sqrt (dx1 * dx1 + dy1 * dy1 + dz1 * dz1);
258 if (dd1 > 0) {
259 dx2 = xb - xa; dy2 = yb - ya; dz2 = zb - za;
260 dd2 = sqrt (dx2 * dx2 + dy2 * dy2 + dz2 * dz2);
261 if (dd2 > 0) {
262 Standard_Real p = (dx1 * dx2 + dy1 * dy2 + dz1 * dz2) / (dd1 * dd2);
263 dx1 = xa + p * dx1 - xb;
264 dy1 = ya + p * dy1 - yb;
265 dz1 = za + p * dz1 - zb;
266 dd1 = sqrt (dx1 * dx1 + dy1 * dy1 + dz1 * dz1);
267 if (dd1 > tolMinMax) tolMinMax = dd1;
268 }
269 }
7fd59977 270 }
271 }
272 }
273 ((HLRAlgo_Projector*) myProj)->Project(Value3D(b),x,y,z);
274 HLRAlgo::UpdateMinMax(x,y,z,TotMin,TotMax);
275 return tolMinMax;
276}
277
278//=======================================================================
279//function : Z
280//purpose :
281//=======================================================================
282
283Standard_Real HLRBRep_Curve::Z (const Standard_Real U) const
284{
285 gp_Pnt P3d;
286 HLRBRep_BCurveTool::D0(myCurve,U,P3d);
287 P3d.Transform(((HLRAlgo_Projector*) myProj)->Transformation());
288 return P3d.Z();
289}
290
291//=======================================================================
292//function : Tangent
293//purpose :
294//=======================================================================
295
296void HLRBRep_Curve::Tangent (const Standard_Boolean AtStart,
733a0e55 297 gp_Pnt2d& P, gp_Dir2d& D) const
7fd59977 298{
733a0e55
S
299 Standard_Real U = AtStart? HLRBRep_BCurveTool::FirstParameter(myCurve) :
300 HLRBRep_BCurveTool::LastParameter (myCurve);
7fd59977 301
302 D0(U,P);
303 HLRBRep_CLProps CLP(2,Epsilon(1.));
681f3919 304 const HLRBRep_Curve* aCurve = this;
305 CLP.SetCurve(aCurve);
7fd59977 306 CLP.SetParameter(U);
307 StdFail_UndefinedDerivative_Raise_if
308 (!CLP.IsTangentDefined(), "HLRBRep_Curve::Tangent");
309 CLP.Tangent(D);
310}
311
312//=======================================================================
313//function : D0
314//purpose :
315//=======================================================================
316
317void HLRBRep_Curve::D0 (const Standard_Real U, gp_Pnt2d& P) const
318{
733a0e55 319 /* gp_Pnt P3d;
7fd59977 320 HLRBRep_BCurveTool::D0(myCurve,U,P3d);
321 P3d.Transform(((HLRAlgo_Projector*) myProj)->Transformation());
322 if (((HLRAlgo_Projector*) myProj)->Perspective()) {
323 Standard_Real R = 1.-P3d.Z()/((HLRAlgo_Projector*) myProj)->Focus();
324 P.SetCoord(P3d.X()/R,P3d.Y()/R);
325 }
733a0e55 326 else P.SetCoord(P3d.X(),P3d.Y()); */
7fd59977 327 gp_Pnt P3d;
328 HLRBRep_BCurveTool::D0(myCurve,U,P3d);
329 ((HLRAlgo_Projector*) myProj)->Project(P3d,P);
7fd59977 330}
331
332//=======================================================================
333//function : D1
334//purpose :
335//=======================================================================
336
337void HLRBRep_Curve::D1 (const Standard_Real U,
733a0e55 338 gp_Pnt2d& P, gp_Vec2d& V) const
7fd59977 339{
7fd59977 340 // Mathematical formula for lines
341
342 // X'[t] X[t] Z'[t]
343 // D1 = -------- + -------------
344 // Z[t] Z[t] 2
345 // 1 - ---- f (1 - ----)
346 // f f
347
7fd59977 348 gp_Pnt P3D;
349 gp_Vec V13D;
350 HLRBRep_BCurveTool::D1(myCurve,U,P3D,V13D);
2111e967 351 if (myProj->Perspective())
352 {
353 P3D .Transform(myProj->Transformation());
354 V13D.Transform(myProj->Transformation());
355
356 Standard_Real f = myProj->Focus();
7fd59977 357 Standard_Real R = 1. - P3D.Z()/f;
358 Standard_Real e = V13D.Z()/(f*R*R);
359 P.SetCoord(P3D .X()/R , P3D .Y()/R );
360 V.SetCoord(V13D.X()/R + P3D.X()*e, V13D.Y()/R + P3D.Y()*e);
361 }
362 else {
733a0e55 363 //OCC155
2111e967 364 myProj->Project(P3D,V13D,P,V);
7fd59977 365 }
7fd59977 366}
367
368//=======================================================================
369//function : D2
370//purpose :
371//=======================================================================
372
373void HLRBRep_Curve::D2 (const Standard_Real U,
733a0e55 374 gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const
7fd59977 375{
7fd59977 376 // Mathematical formula for lines
377
378 // 2
379 // 2 X'[t] Z'[t] 2 X[t] Z'[t] X''[t] X[t] Z''[t]
380 // D2 = ------------- + -------------- + -------- + -------------
381 // Z[t] 2 2 Z[t] 3 Z[t] Z[t] 2
382 // f (1 - ----) f (1 - ----) 1 - ---- f (1 - ----)
383 // f f f f
384
385 gp_Pnt P3D;
386 gp_Vec V13D,V23D;
387 HLRBRep_BCurveTool::D2(myCurve,U,P3D,V13D,V23D);
2111e967 388 P3D .Transform(myProj->Transformation());
389 V13D.Transform(myProj->Transformation());
390 V23D.Transform(myProj->Transformation());
391 if (myProj->Perspective())
392 {
393 Standard_Real f = myProj->Focus();
7fd59977 394 Standard_Real R = 1. - P3D.Z() / f;
395 Standard_Real q = f*R*R;
396 Standard_Real e = V13D.Z()/q;
397 Standard_Real c = e*V13D.Z()/(f*R);
398 P .SetCoord(P3D .X()/R , P3D .Y()/R );
399 V1.SetCoord(V13D.X()/R + P3D.X()*e, V13D.Y()/R + P3D.Y()*e);
400 V2.SetCoord(V23D.X()/R + 2*V13D.X()*e + P3D.X()*V23D.Z()/q + 2*P3D.X()*c,
401 V23D.Y()/R + 2*V13D.Y()*e + P3D.Y()*V23D.Z()/q + 2*P3D.Y()*c);
402 }
403 else {
404 P .SetCoord(P3D .X(),P3D .Y());
405 V1.SetCoord(V13D.X(),V13D.Y());
406 V2.SetCoord(V23D.X(),V23D.Y());
407 }
408}
409
410//=======================================================================
411//function : D3
412//purpose :
413//=======================================================================
414
415void HLRBRep_Curve::D3 (const Standard_Real,
733a0e55 416 gp_Pnt2d&, gp_Vec2d&, gp_Vec2d&, gp_Vec2d&) const
7fd59977 417{
418}
419
420//=======================================================================
421//function : DN
422//purpose :
423//=======================================================================
424
733a0e55 425gp_Vec2d HLRBRep_Curve::DN (const Standard_Real, const Standard_Integer) const
7fd59977 426{ return gp_Vec2d(); }
427
428//=======================================================================
429//function : Line
430//purpose :
431//=======================================================================
432
433gp_Lin2d HLRBRep_Curve::Line () const
434{
435 gp_Pnt2d P;
436 gp_Vec2d V;
437 D1(0.,P,V);
438 return gp_Lin2d(P,V);
439}
440
441//=======================================================================
442//function : Circle
443//purpose :
444//=======================================================================
445
446gp_Circ2d HLRBRep_Curve::Circle () const
447{
448 gp_Circ C = HLRBRep_BCurveTool::Circle(myCurve);
681f3919 449 C.Transform(myProj->Transformation());
7fd59977 450 return ProjLib::Project(gp_Pln(gp::XOY()),C);
451}
452
453//=======================================================================
454//function : Ellipse
455//purpose :
456//=======================================================================
457
458gp_Elips2d HLRBRep_Curve::Ellipse () const
459{
733a0e55 460 if (HLRBRep_BCurveTool::GetType(myCurve) == GeomAbs_Ellipse) {
7fd59977 461 gp_Elips E = HLRBRep_BCurveTool::Ellipse(myCurve);
681f3919 462 E.Transform(myProj->Transformation());
7fd59977 463 return ProjLib::Project(gp_Pln(gp::XOY()),E);
464 }
733a0e55
S
465 // this is a circle
466 gp_Circ C = HLRBRep_BCurveTool::Circle(myCurve);
681f3919 467 C.Transform(myProj->Transformation());
733a0e55
S
468 const gp_Dir& D1 = C.Axis().Direction();
469 const gp_Dir& D3 = D1.Crossed(gp::DZ());
470 const gp_Dir& D2 = D1.Crossed(D3);
471 Standard_Real rap = sqrt( D2.X()*D2.X() + D2.Y()*D2.Y() );
472 gp_Dir2d d(D1.Y(),-D1.X());
473 gp_Pnt2d p(C.Location().X(),C.Location().Y());
474 gp_Elips2d El(gp_Ax2d(p,d),C.Radius(),C.Radius()*rap);
475 if ( D1.Z() < 0 ) El.Reverse();
476 return El;
7fd59977 477}
478
479//=======================================================================
480//function : Hyperbola
481//purpose :
482//=======================================================================
483
484gp_Hypr2d HLRBRep_Curve::Hyperbola () const
485{ return gp_Hypr2d(); }
486
487//=======================================================================
488//function : Parabola
489//purpose :
490//=======================================================================
491gp_Parab2d HLRBRep_Curve::Parabola () const
492{ return gp_Parab2d(); }
493
494//=======================================================================
495//function : Poles
496//purpose :
497//=======================================================================
498
499void HLRBRep_Curve::Poles (TColgp_Array1OfPnt2d& TP) const
500{
501 Standard_Integer i1 = TP.Lower();
502 Standard_Integer i2 = TP.Upper();
503 TColgp_Array1OfPnt TP3(i1,i2);
504 //-- HLRBRep_BCurveTool::Poles(myCurve,TP3);
505 if(HLRBRep_BCurveTool::GetType(myCurve) == GeomAbs_BSplineCurve) {
506 (HLRBRep_BCurveTool::BSpline(myCurve))->Poles(TP3);
507 }
508 else {
509 (HLRBRep_BCurveTool::Bezier(myCurve))->Poles(TP3);
510 }
511 for (Standard_Integer i = i1; i <= i2; i++) {
681f3919 512 myProj->Transform(TP3(i));
7fd59977 513 TP(i).SetCoord(TP3(i).X(),TP3(i).Y());
514 }
515}
516
0a768f56 517//=======================================================================
518//function : Poles
519//purpose :
520//=======================================================================
521
522void HLRBRep_Curve::Poles (const Handle(Geom_BSplineCurve)& aCurve,
523 TColgp_Array1OfPnt2d& TP) const
524{
525 Standard_Integer i1 = TP.Lower();
526 Standard_Integer i2 = TP.Upper();
527 TColgp_Array1OfPnt TP3(i1,i2);
528 //-- HLRBRep_BCurveTool::Poles(myCurve,TP3);
529 aCurve->Poles(TP3);
530
531 for (Standard_Integer i = i1; i <= i2; i++) {
532 ((HLRAlgo_Projector*) myProj)->Transform(TP3(i));
533 TP(i).SetCoord(TP3(i).X(),TP3(i).Y());
534 }
535}
536
7fd59977 537//=======================================================================
538//function : PolesAndWeights
539//purpose :
540//=======================================================================
541
542void HLRBRep_Curve::PolesAndWeights (TColgp_Array1OfPnt2d& TP,
543 TColStd_Array1OfReal& TW) const
544{
545 Standard_Integer i1 = TP.Lower();
546 Standard_Integer i2 = TP.Upper();
547 TColgp_Array1OfPnt TP3(i1,i2);
548 //-- HLRBRep_BCurveTool::PolesAndWeights(myCurve,TP3,TW);
549
550 if(HLRBRep_BCurveTool::GetType(myCurve) == GeomAbs_BSplineCurve) {
551 Handle(Geom_BSplineCurve) HB = (HLRBRep_BCurveTool::BSpline(myCurve));
552 HB->Poles(TP3);
553 HB->Weights(TW);
554 //-- (HLRBRep_BCurveTool::BSpline(myCurve))->PolesAndWeights(TP3,TW);
555 }
556 else {
557 Handle(Geom_BezierCurve) HB = (HLRBRep_BCurveTool::Bezier(myCurve));
558 HB->Poles(TP3);
559 HB->Weights(TW);
560 //-- (HLRBRep_BCurveTool::Bezier(myCurve))->PolesAndWeights(TP3,TW);
561 }
562 for (Standard_Integer i = i1; i <= i2; i++) {
563 ((HLRAlgo_Projector*) myProj)->Transform(TP3(i));
564 TP(i).SetCoord(TP3(i).X(),TP3(i).Y());
565 }
566}
567
0a768f56 568//=======================================================================
569//function : PolesAndWeights
570//purpose :
571//=======================================================================
572
573void HLRBRep_Curve::PolesAndWeights (const Handle(Geom_BSplineCurve)& aCurve,
574 TColgp_Array1OfPnt2d& TP,
575 TColStd_Array1OfReal& TW) const
576{
577 Standard_Integer i1 = TP.Lower();
578 Standard_Integer i2 = TP.Upper();
579 TColgp_Array1OfPnt TP3(i1,i2);
580 //-- HLRBRep_BCurveTool::PolesAndWeights(myCurve,TP3,TW);
581
582 aCurve->Poles(TP3);
583 aCurve->Weights(TW);
584 //-- (HLRBRep_BCurveTool::BSpline(myCurve))->PolesAndWeights(TP3,TW);
585
586 for (Standard_Integer i = i1; i <= i2; i++) {
587 ((HLRAlgo_Projector*) myProj)->Transform(TP3(i));
588 TP(i).SetCoord(TP3(i).X(),TP3(i).Y());
589 }
590}
591
7fd59977 592//=======================================================================
593//function : Knots
594//purpose :
595//=======================================================================
596
597void HLRBRep_Curve::Knots (TColStd_Array1OfReal& kn) const
598{
599 if(HLRBRep_BCurveTool::GetType(myCurve) == GeomAbs_BSplineCurve) {
600 Handle(Geom_BSplineCurve) HB = (HLRBRep_BCurveTool::BSpline(myCurve));
601 HB->Knots(kn);
602 }
603}
604
7fd59977 605//=======================================================================
606//function : Multiplicities
607//purpose :
608//=======================================================================
609
610void HLRBRep_Curve::Multiplicities (TColStd_Array1OfInteger& mu) const
611{
612 if(HLRBRep_BCurveTool::GetType(myCurve) == GeomAbs_BSplineCurve) {
613 Handle(Geom_BSplineCurve) HB = (HLRBRep_BCurveTool::BSpline(myCurve));
614 HB->Multiplicities(mu);
615 }
616}