1 // Created on: 1995-01-17
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <AppDef_BSplineCompute.hxx>
19 #include <AppDef_MultiLine.hxx>
20 #include <AppDef_MultiPointConstraint.hxx>
21 #include <AppDef_Variational.hxx>
22 #include <AppParCurves_ConstraintCouple.hxx>
23 #include <AppParCurves_HArray1OfConstraintCouple.hxx>
24 #include <BSplCLib.hxx>
25 #include <Geom_BSplineCurve.hxx>
26 #include <Geom_BSplineSurface.hxx>
27 #include <GeomAPI_PointsToBSpline.hxx>
28 #include <GeomAPI_PointsToBSplineSurface.hxx>
29 #include <GeomFill_AppSurf.hxx>
30 #include <GeomFill_Line.hxx>
31 #include <GeomFill_SectionGenerator.hxx>
33 #include <math_Vector.hxx>
34 #include <Precision.hxx>
35 #include <StdFail_NotDone.hxx>
36 #include <TColgp_Array1OfPnt.hxx>
37 #include <AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute.hxx>
39 static void BuildParameters(const AppDef_MultiLine& theLine,
40 const Approx_ParametrizationType theParT,
41 TColStd_Array1OfReal& thePars)
43 Standard_Integer i, j, nbP3d = theLine.NbPoints();
45 Standard_Integer firstP = 1, lastP = theLine.NbMultiPoints();
46 const Standard_Integer aNbp = lastP - firstP + 1;
50 thePars(firstP) = 0.0;
53 else if (theParT == Approx_ChordLength || theParT == Approx_Centripetal)
56 thePars(firstP) = 0.0;
59 for (i = firstP + 1; i <= lastP; i++)
61 AppDef_MultiPointConstraint aMPC = theLine.Value(i - 1);
62 AppDef_MultiPointConstraint aMPC1 = theLine.Value(i);
65 for (j = 1; j <= nbP3d; j++)
67 const gp_Pnt &aP1 = aMPC.Point(j),
68 &aP2 = aMPC1.Point(j);
69 dist += aP2.SquareDistance(aP1);
73 if (theParT == Approx_ChordLength)
75 thePars(i) = thePars(i - 1) + dist;
78 {// Par == Approx_Centripetal
79 thePars(i) = thePars(i - 1) + Sqrt(dist);
82 for (i = firstP; i <= lastP; i++) thePars(i) /= thePars(lastP);
85 for (i = firstP; i <= lastP; i++) {
86 thePars(i) = (Standard_Real(i) - firstP) /
87 (Standard_Real(lastP - Standard_Real(firstP)));
93 static void BuildPeriodicTangent(const AppDef_MultiLine& theLine,
94 const TColStd_Array1OfReal& thePars,
97 Standard_Integer firstpt = 1, lastpt = theLine.NbMultiPoints();
98 Standard_Integer nbpoints = lastpt - firstpt + 1;
105 Standard_Integer i, nnpol, nnp = Min(nbpoints, 9);
107 Standard_Integer lastp = Min(lastpt, firstpt + nnp - 1);
109 AppParCurves_Constraint Cons = AppParCurves_TangencyPoint;
112 Cons = AppParCurves_PassPoint;
114 Standard_Integer nbP = 3 * theLine.NbPoints();
115 math_Vector V1(1, nbP), V2(1, nbP);
116 math_Vector P1(firstpt, lastp);
118 for (i = firstpt; i <= lastp; i++)
123 AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute SQ1(theLine, firstpt, lastp, Cons, Cons, nnpol);
125 const AppParCurves_MultiCurve& C1 = SQ1.BezierValue();
127 Standard_Integer j, nbP3d = theLine.NbPoints();
132 for (i = 1; i <= nbP3d; i++) {
140 Standard_Integer firstp = Max(firstpt, lastpt - nnp + 1);
142 if (firstp == firstpt && lastp == lastpt) {
145 for (i = 1; i <= nbP3d; i++) {
154 AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute
155 SQ2(theLine, firstp, lastpt, Cons, Cons, nnpol);
157 math_Vector P2(firstp, lastpt);
158 for (i = firstp; i <= lastpt; i++) P2(i) = thePars(i);
161 const AppParCurves_MultiCurve& C2 = SQ2.BezierValue();
164 for (i = 1; i <= nbP3d; i++) {
173 theTang = 0.5*(V1 + V2);
177 //=======================================================================
178 //function : GeomAPI_PointsToBSplineSurface
180 //=======================================================================
181 GeomAPI_PointsToBSplineSurface::GeomAPI_PointsToBSplineSurface()
182 : myIsDone ( Standard_False)
187 //=======================================================================
188 //function : GeomAPI_PointsToBSplineSurface
190 //=======================================================================
192 GeomAPI_PointsToBSplineSurface::GeomAPI_PointsToBSplineSurface
193 (const TColgp_Array2OfPnt& Points,
194 const Standard_Integer DegMin,
195 const Standard_Integer DegMax,
196 const GeomAbs_Shape Continuity,
197 const Standard_Real Tol3D)
198 : myIsDone ( Standard_False)
200 Init(Points,DegMin,DegMax,Continuity,Tol3D);
203 //=======================================================================
204 //function : GeomAPI_PointsToBSplineSurface
206 //=======================================================================
208 GeomAPI_PointsToBSplineSurface::GeomAPI_PointsToBSplineSurface
209 (const TColgp_Array2OfPnt& Points,
210 const Approx_ParametrizationType ParType,
211 const Standard_Integer DegMin,
212 const Standard_Integer DegMax,
213 const GeomAbs_Shape Continuity,
214 const Standard_Real Tol3D)
215 : myIsDone ( Standard_False)
217 Init(Points,ParType,DegMin,DegMax,Continuity,Tol3D);
220 //=======================================================================
221 //function : GeomAPI_PointsToBSplineSurface
223 //=======================================================================
225 GeomAPI_PointsToBSplineSurface::GeomAPI_PointsToBSplineSurface
226 (const TColgp_Array2OfPnt& Points,
227 const Standard_Real Weight1,
228 const Standard_Real Weight2,
229 const Standard_Real Weight3,
230 const Standard_Integer DegMax,
231 const GeomAbs_Shape Continuity,
232 const Standard_Real Tol3D)
233 : myIsDone ( Standard_False)
235 Init(Points,Weight1,Weight2,Weight3,DegMax,Continuity,Tol3D);
240 //=======================================================================
241 //function : GeomAPI_PointsToBSplineSurface
243 //=======================================================================
245 GeomAPI_PointsToBSplineSurface::GeomAPI_PointsToBSplineSurface
246 (const TColStd_Array2OfReal& ZPoints,
247 const Standard_Real X0,
248 const Standard_Real dX,
249 const Standard_Real Y0,
250 const Standard_Real dY,
251 const Standard_Integer DegMin,
252 const Standard_Integer DegMax,
253 const GeomAbs_Shape Continuity,
254 const Standard_Real Tol3D)
255 : myIsDone ( Standard_False)
257 Init(ZPoints,X0,dX,Y0,dY,DegMin,DegMax,Continuity,Tol3D);
262 //=======================================================================
263 //function : Interpolate
265 //=======================================================================
267 void GeomAPI_PointsToBSplineSurface::Interpolate(const TColgp_Array2OfPnt& Points,
268 const Standard_Boolean thePeriodic)
270 Interpolate(Points, Approx_ChordLength, thePeriodic);
273 //=======================================================================
274 //function : Interpolate
276 //=======================================================================
278 void GeomAPI_PointsToBSplineSurface::Interpolate(const TColgp_Array2OfPnt& Points,
279 const Approx_ParametrizationType ParType,
280 const Standard_Boolean thePeriodic)
282 Standard_Integer DegMin, DegMax;
284 GeomAbs_Shape CC = GeomAbs_C2;
285 Standard_Real Tol3d = -1.0;
286 Init(Points, ParType, DegMin, DegMax, CC, Tol3d, thePeriodic);
290 //=======================================================================
293 //=======================================================================
295 void GeomAPI_PointsToBSplineSurface::Init(const TColgp_Array2OfPnt& Points,
296 const Standard_Integer DegMin,
297 const Standard_Integer DegMax,
298 const GeomAbs_Shape Continuity,
299 const Standard_Real Tol3D)
301 Init(Points, Approx_ChordLength, DegMin, DegMax, Continuity, Tol3D);
303 //=======================================================================
306 //=======================================================================
308 void GeomAPI_PointsToBSplineSurface::Init(const TColgp_Array2OfPnt& Points,
309 const Approx_ParametrizationType ParType,
310 const Standard_Integer DegMin,
311 const Standard_Integer DegMax,
312 const GeomAbs_Shape Continuity,
313 const Standard_Real Tol3D,
314 const Standard_Boolean thePeriodic)
316 Standard_Integer Imin = Points.LowerRow();
317 Standard_Integer Imax = Points.UpperRow();
318 Standard_Integer Jmin = Points.LowerCol();
319 Standard_Integer Jmax = Points.UpperCol();
321 Standard_Real Tol2D = Tol3D;
323 // first approximate the U isos:
324 Standard_Integer add = 1;
329 AppDef_MultiLine Line(Jmax-Jmin+1);
330 Standard_Integer i, j;
332 for (j = Jmin; j <= Jmax; j++) {
333 AppDef_MultiPointConstraint MP(Imax-Imin+add, 0);
334 for (i = Imin; i <= Imax; i++) {
335 MP.SetPoint(i, Points(i,j));
339 MP.SetPoint(Imax+1, Points(1, j));
341 Line.SetValue(j, MP);
347 Standard_Integer nbit = 2;
348 Standard_Boolean UseSquares = Standard_False;
349 if(Tol3D <= 1.e-3) UseSquares = Standard_True;
351 AppDef_BSplineCompute TheComputer
352 (DegMin,DegMax,Tol3D,Tol2D,nbit,Standard_True,ParType,UseSquares);
354 switch( Continuity) {
356 TheComputer.SetContinuity(0); break;
360 TheComputer.SetContinuity(1); break;
364 TheComputer.SetContinuity(2); break;
367 TheComputer.SetContinuity(3);
371 TheComputer.Interpol(Line);
374 TheComputer.Perform(Line);
377 const AppParCurves_MultiBSpCurve& TheCurve = TheComputer.Value();
379 Standard_Integer VDegree = TheCurve.Degree();
380 TColgp_Array1OfPnt Poles(1,TheCurve.NbPoles());
381 const TColStd_Array1OfReal& VKnots = TheCurve.Knots();
382 const TColStd_Array1OfInteger& VMults = TheCurve.Multiplicities();
385 Standard_Integer nbisosu = Imax-Imin+add;
386 AppDef_MultiLine Line2(nbisosu);
388 for (i = 1; i <= nbisosu; i++) {
389 TheCurve.Curve(i, Poles);
390 AppDef_MultiPointConstraint MP(Poles.Upper(),0);
391 for (j = 1; j <= Poles.Upper(); j++) {
392 MP.SetPoint(j, Poles(j));
394 Line2.SetValue(i, MP);
398 // approximate the resulting poles:
400 AppDef_BSplineCompute TheComputer2
401 (DegMin,DegMax,Tol3D,Tol2D,nbit,Standard_True,ParType,UseSquares);
405 TheComputer2.SetPeriodic(thePeriodic);
407 TheComputer2.Interpol(Line2);
410 if (thePeriodic && Line2.NbMultiPoints() > 2)
412 TheComputer2.SetPeriodic(thePeriodic);
414 TColStd_Array1OfReal aPars(1, Line2.NbMultiPoints());
415 BuildParameters(Line2, ParType, aPars);
416 math_Vector aTang(1, 3 * Poles.Upper());
417 BuildPeriodicTangent(Line2, aPars, aTang);
418 Standard_Integer ind = 1;
419 TheCurve.Curve(ind, Poles);
420 AppDef_MultiPointConstraint MP1(Poles.Upper(), 0);
421 for (j = 1; j <= Poles.Upper(); j++) {
422 MP1.SetPoint(j, Poles(j));
423 Standard_Integer k = 3 * (j - 1);
424 gp_Vec aT(aTang(k + 1), aTang(k + 2), aTang(k + 3));
427 Line2.SetValue(ind, MP1);
429 ind = Line2.NbMultiPoints();
430 TheCurve.Curve(ind, Poles);
431 AppDef_MultiPointConstraint MP2(Poles.Upper(), 0);
432 for (j = 1; j <= Poles.Upper(); j++) {
433 MP2.SetPoint(j, Poles(j));
434 Standard_Integer k = 3 * (j - 1);
435 gp_Vec aT(aTang(k + 1), aTang(k + 2), aTang(k + 3));
438 Line2.SetValue(ind, MP2);
440 TheComputer2.Perform(Line2);
443 const AppParCurves_MultiBSpCurve& TheCurve2 = TheComputer2.Value();
445 Standard_Integer UDegree = TheCurve2.Degree();
446 TColgp_Array1OfPnt Poles2(1,TheCurve2.NbPoles());
447 const TColStd_Array1OfReal& UKnots = TheCurve2.Knots();
448 const TColStd_Array1OfInteger& UMults = TheCurve2.Multiplicities();
451 // computing the surface
452 TColgp_Array2OfPnt ThePoles(1, Poles2.Upper(), 1, Poles.Upper());
453 for ( j = 1; j <= Poles.Upper(); j++) {
454 TheCurve2.Curve(j, Poles2);
455 for (i = 1; i<= Poles2.Upper(); i++) {
456 ThePoles(i, j) = Poles2(i);
461 mySurface = new Geom_BSplineSurface(ThePoles, UKnots, VKnots, UMults, VMults,
463 if (thePeriodic && Line2.NbMultiPoints() > 2)
465 mySurface->SetUPeriodic();
468 myIsDone = Standard_True;
472 //=======================================================================
475 //=======================================================================
477 void GeomAPI_PointsToBSplineSurface::Init(const TColgp_Array2OfPnt& Points,
478 const Standard_Real Weight1,
479 const Standard_Real Weight2,
480 const Standard_Real Weight3,
481 const Standard_Integer DegMax,
482 const GeomAbs_Shape Continuity,
483 const Standard_Real Tol3D)
485 Standard_Integer Imin = Points.LowerRow();
486 Standard_Integer Imax = Points.UpperRow();
487 Standard_Integer Jmin = Points.LowerCol();
488 Standard_Integer Jmax = Points.UpperCol();
490 Standard_Integer nbit = 2;
491 if(Tol3D <= 1.e-3) nbit = 0;
493 // first approximate the U isos:
494 Standard_Integer NbPointJ = Jmax-Jmin+1;
495 Standard_Integer NbPointI = Imax-Imin+1;
496 Standard_Integer i, j;
498 AppDef_MultiLine Line(NbPointJ);
500 for (j = Jmin; j <= Jmax; j++) {
501 AppDef_MultiPointConstraint MP(NbPointI, 0);
502 for (i = Imin; i <= Imax; i++) {
503 MP.SetPoint(i, Points(i,j));
505 Line.SetValue(j, MP);
509 Handle(AppParCurves_HArray1OfConstraintCouple) TABofCC =
510 new AppParCurves_HArray1OfConstraintCouple(1, NbPointJ);
511 AppParCurves_Constraint Constraint=AppParCurves_NoConstraint;
513 for(i = 1; i <= NbPointJ; ++i) {
514 AppParCurves_ConstraintCouple ACC(i,Constraint);
515 TABofCC->SetValue(i,ACC);
519 AppDef_Variational Variation(Line, 1, NbPointJ, TABofCC);
521 //===================================
522 Standard_Integer theMaxSegments = 1000;
523 Standard_Boolean theWithMinMax = Standard_False;
524 //===================================
526 Variation.SetMaxDegree(DegMax);
527 Variation.SetContinuity(Continuity);
528 Variation.SetMaxSegment(theMaxSegments);
530 Variation.SetTolerance(Tol3D);
531 Variation.SetWithMinMax(theWithMinMax);
532 Variation.SetNbIterations(nbit);
534 Variation.SetCriteriumWeight(Weight1, Weight2, Weight3);
536 if(!Variation.IsCreated()) {
540 if(Variation.IsOverConstrained()) {
545 Variation.Approximate();
547 catch (Standard_Failure const&) {
551 if(!Variation.IsDone()) {
555 const AppParCurves_MultiBSpCurve& TheCurve = Variation.Value();
557 Standard_Integer VDegree = TheCurve.Degree();
558 TColgp_Array1OfPnt Poles(1,TheCurve.NbPoles());
559 const TColStd_Array1OfReal& VKnots = TheCurve.Knots();
560 const TColStd_Array1OfInteger& VMults = TheCurve.Multiplicities();
563 AppDef_MultiLine Line2(NbPointI);
565 for (i = 1; i <= NbPointI; i++) {
566 TheCurve.Curve(i, Poles);
567 AppDef_MultiPointConstraint MP(Poles.Upper(),0);
568 for (j = 1; j <= Poles.Upper(); j++) {
569 MP.SetPoint(j, Poles(j));
571 Line2.SetValue(i, MP);
575 Handle(AppParCurves_HArray1OfConstraintCouple) TABofCC2 =
576 new AppParCurves_HArray1OfConstraintCouple(1, NbPointI);
578 for(i = 1; i <= NbPointI; ++i) {
579 AppParCurves_ConstraintCouple ACC(i,Constraint);
580 TABofCC2->SetValue(i,ACC);
584 AppDef_Variational Variation2(Line2, 1, NbPointI, TABofCC2);
586 Variation2.SetMaxDegree(DegMax);
587 Variation2.SetContinuity(Continuity);
588 Variation2.SetMaxSegment(theMaxSegments);
590 Variation2.SetTolerance(Tol3D);
591 Variation2.SetWithMinMax(theWithMinMax);
592 Variation2.SetNbIterations(nbit);
594 Variation2.SetCriteriumWeight(Weight1, Weight2, Weight3);
596 if(!Variation2.IsCreated()) {
600 if(Variation2.IsOverConstrained()) {
605 Variation2.Approximate();
607 catch (Standard_Failure const&) {
611 if(!Variation2.IsDone()) {
615 const AppParCurves_MultiBSpCurve& TheCurve2 = Variation2.Value();
617 Standard_Integer UDegree = TheCurve2.Degree();
618 TColgp_Array1OfPnt Poles2(1,TheCurve2.NbPoles());
619 const TColStd_Array1OfReal& UKnots = TheCurve2.Knots();
620 const TColStd_Array1OfInteger& UMults = TheCurve2.Multiplicities();
623 // computing the surface
624 TColgp_Array2OfPnt ThePoles(1, Poles2.Upper(), 1, Poles.Upper());
625 for ( j = 1; j <= Poles.Upper(); j++) {
626 TheCurve2.Curve(j, Poles2);
627 for (i = 1; i<= Poles2.Upper(); i++) {
628 ThePoles(i, j) = Poles2(i);
633 mySurface = new Geom_BSplineSurface(ThePoles, UKnots, VKnots, UMults, VMults,
636 myIsDone = Standard_True;
638 //=======================================================================
641 //=======================================================================
643 void GeomAPI_PointsToBSplineSurface::Interpolate(const TColStd_Array2OfReal& ZPoints,
644 const Standard_Real X0,
645 const Standard_Real dX,
646 const Standard_Real Y0,
647 const Standard_Real dY)
649 Standard_Integer DegMin, DegMax;
651 Standard_Real Tol3D = -1.0;
652 GeomAbs_Shape CC = GeomAbs_C2;
653 Init(ZPoints, X0, dX, Y0, dY, DegMin, DegMax, CC, Tol3D);
656 //=======================================================================
659 //=======================================================================
661 void GeomAPI_PointsToBSplineSurface::Init(const TColStd_Array2OfReal& ZPoints,
662 const Standard_Real X0,
663 const Standard_Real dX,
664 const Standard_Real Y0,
665 const Standard_Real dY,
666 const Standard_Integer DegMin,
667 const Standard_Integer DegMax,
668 const GeomAbs_Shape Continuity,
669 const Standard_Real Tol3D)
671 Standard_Integer Imin = ZPoints.LowerRow();
672 Standard_Integer Imax = ZPoints.UpperRow();
673 Standard_Integer Jmin = ZPoints.LowerCol();
674 Standard_Integer Jmax = ZPoints.UpperCol();
675 Standard_Real length;
677 Standard_Real Tol2D = Tol3D;
679 // first approximate the U isos:
680 AppDef_MultiLine Line(Jmax-Jmin+1);
681 math_Vector Param(Jmin, Jmax);
682 Standard_Integer i, j;
683 // Standard_Real X, Y;
684 length = dY * (Jmax-Jmin);
686 for (j = Jmin; j <= Jmax; j++) {
687 AppDef_MultiPointConstraint MP(0, Imax-Imin+1);
688 for (i = Imin; i <= Imax; i++) {
689 MP.SetPoint2d(i, gp_Pnt2d(0.0, ZPoints(i, j)));
691 Param(j) = (Standard_Real)(j-Jmin)/(Standard_Real)(Jmax-Jmin);
692 Line.SetValue(j, MP);
695 AppDef_BSplineCompute TheComputer
696 (Param, DegMin,DegMax,Tol3D,Tol2D,0, Standard_True, Standard_True);
698 switch( Continuity) {
700 TheComputer.SetContinuity(0); break;
704 TheComputer.SetContinuity(1); break;
708 TheComputer.SetContinuity(2); break;
711 TheComputer.SetContinuity(3);
715 TheComputer.Interpol(Line);
718 TheComputer.Perform(Line);
722 const AppParCurves_MultiBSpCurve& TheCurve = TheComputer.Value();
724 Standard_Integer VDegree = TheCurve.Degree();
725 TColgp_Array1OfPnt2d Poles(1,TheCurve.NbPoles());
726 Standard_Integer nk = TheCurve.Knots().Length();
727 TColStd_Array1OfReal VKnots(1,nk);
728 TColStd_Array1OfInteger VMults(1,nk);
731 // compute Y values for the poles
732 TColStd_Array1OfReal YPoles(1,Poles.Upper());
735 TColStd_Array1OfReal TempPoles(1,2);
736 TColStd_Array1OfReal TempKnots(1,2);
737 TColStd_Array1OfInteger TempMults(1,2);
740 TempPoles(2) = Y0 + length;
744 // increase the Degree
745 TColStd_Array1OfReal NewTempPoles(1,VDegree+1);
746 TColStd_Array1OfReal NewTempKnots(1,2);
747 TColStd_Array1OfInteger NewTempMults(1,2);
748 BSplCLib::IncreaseDegree(1,VDegree,Standard_False,1,
749 TempPoles,TempKnots,TempMults,
750 NewTempPoles,NewTempKnots,NewTempMults);
754 BSplCLib::InsertKnots(VDegree,Standard_False,1,
755 NewTempPoles,NewTempKnots,NewTempMults,
756 TheCurve.Knots(),&TheCurve.Multiplicities(),
757 YPoles,VKnots,VMults,
761 for (i = 1; i <= nk; i++) {
762 VKnots(i) = Y0 + length * VKnots(i);
766 Standard_Integer nbisosu = Imax-Imin+1;
767 AppDef_MultiLine Line2(nbisosu);
768 math_Vector Param2(1, nbisosu);
769 length = dX*(Imax-Imin);
771 for (i = 1; i <= nbisosu; i++) {
772 TheCurve.Curve(i, Poles);
773 AppDef_MultiPointConstraint MP(0, Poles.Upper());
774 for (j = 1; j <= Poles.Upper(); j++) {
775 MP.SetPoint2d(j, gp_Pnt2d(0.0, Poles(j).Y()));
777 Param2(i) = (Standard_Real)(i-1)/(Standard_Real)(nbisosu-1);
778 Line2.SetValue(i, MP);
782 // approximate the resulting poles:
784 AppDef_BSplineCompute TheComputer2
785 (Param2, DegMin,DegMax,Tol3D,Tol2D,0, Standard_True, Standard_True);
787 TheComputer2.Interpol(Line2);
790 TheComputer2.Perform(Line2);
793 const AppParCurves_MultiBSpCurve& TheCurve2 = TheComputer2.Value();
795 Standard_Integer UDegree = TheCurve2.Degree();
796 TColgp_Array1OfPnt2d Poles2(1,TheCurve2.NbPoles());
797 Standard_Integer nk2 = TheCurve2.Knots().Length();
798 TColStd_Array1OfReal UKnots(1,nk2);
799 TColStd_Array1OfInteger UMults(1,nk2);
802 // compute X values for the poles
803 TColStd_Array1OfReal XPoles(1,Poles2.Upper());
807 TempPoles(2) = X0 + length;
810 TempMults(1) = TempMults(2) = 2;
812 // increase the Degree
813 TColStd_Array1OfReal NewTempPoles2(1,UDegree+1);
814 BSplCLib::IncreaseDegree(1,UDegree,Standard_False,1,
815 TempPoles,TempKnots,TempMults,
816 NewTempPoles2,NewTempKnots,NewTempMults);
820 BSplCLib::InsertKnots(UDegree,Standard_False,1,
821 NewTempPoles2,NewTempKnots,NewTempMults,
822 TheCurve2.Knots(),&TheCurve2.Multiplicities(),
823 XPoles,UKnots,UMults,
827 for (i = 1; i <= nk2; i++) {
828 UKnots(i) = X0 + length * UKnots(i);
831 // creating the surface
832 TColgp_Array2OfPnt ThePoles(1, Poles2.Upper(), 1, Poles.Upper());
834 for ( j = 1; j <= Poles.Upper(); j++) {
835 TheCurve2.Curve(j, Poles2);
836 for (i = 1; i<= Poles2.Upper(); i++) {
837 ThePoles(i, j).SetCoord(XPoles(i), YPoles(j), Poles2(i).Y());
842 mySurface = new Geom_BSplineSurface(ThePoles, UKnots, VKnots, UMults, VMults,
845 myIsDone = Standard_True;
850 //=======================================================================
851 //function : Handle(Geom_BSplineSurface)&
853 //=======================================================================
855 const Handle(Geom_BSplineSurface)& GeomAPI_PointsToBSplineSurface::Surface()
858 StdFail_NotDone_Raise_if
860 "GeomAPI_PointsToBSplineSurface: Surface not done");
867 //=======================================================================
870 //=======================================================================
872 GeomAPI_PointsToBSplineSurface::operator Handle(Geom_BSplineSurface)() const
877 //=======================================================================
880 //=======================================================================
882 Standard_Boolean GeomAPI_PointsToBSplineSurface::IsDone () const