1 // Created on: 1996-08-30
2 // Created by: Xavier BENVENISTE
3 // Copyright (c) 1996-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 <BSplCLib.hxx>
19 #include <Geom_BSplineCurve.hxx>
20 #include <GeomLib_Interpolate.hxx>
23 #include <Standard_ConstructionError.hxx>
24 #include <Standard_OutOfRange.hxx>
25 #include <StdFail_NotDone.hxx>
26 #include <TColgp_Array1OfPnt.hxx>
27 #include <TColgp_Array1OfVec.hxx>
28 #include <TColStd_Array1OfBoolean.hxx>
29 #include <TColStd_Array1OfInteger.hxx>
30 #include <TColStd_HArray1OfBoolean.hxx>
31 #include <TColStd_HArray1OfReal.hxx>
33 //=======================================================================
34 //function : GeomLib_Interpolate
36 //=======================================================================
37 GeomLib_Interpolate::GeomLib_Interpolate
38 (const Standard_Integer Degree,
39 const Standard_Integer NumPoints,
40 const TColgp_Array1OfPnt& PointsArray,
41 const TColStd_Array1OfReal& ParametersArray)
51 if (NumPoints < Degree ||
52 PointsArray.Lower() != 1 ||
53 PointsArray.Upper() < NumPoints ||
54 ParametersArray.Lower() != 1 ||
55 ParametersArray.Upper() < NumPoints) {
56 myError = GeomLib_NotEnoughtPoints ;
58 else if (Degree < 3) {
59 myError = GeomLib_DegreeSmallerThan3 ;
62 gp_Pnt null_point(0.0e0, 0.0e0, 0.0e0) ;
63 Standard_Integer order = Degree + 1,
68 half_order = order / 2 ;
69 num_knots = NumPoints + 2 * order - 2 ;
70 num_controls = num_knots - order ;
71 TColStd_Array1OfReal flat_knots(1,num_knots) ;
72 TColStd_Array1OfInteger contacts (1,num_controls) ;
73 TColStd_Array1OfInteger multiplicities(1, NumPoints) ;
74 TColStd_Array1OfReal parameters(1,num_controls) ;
75 TColgp_Array1OfPnt poles(1,num_controls) ;
77 for (ii = 1 ; ii <= NumPoints ; ii++) {
78 multiplicities(ii) = 1 ;
80 multiplicities(1) = order ;
81 multiplicities(NumPoints) = order ;
83 jj = num_controls + 1 ; ii <= order ; ii++, jj++) {
85 flat_knots(ii) = ParametersArray(1) ;
86 flat_knots(jj) = ParametersArray(NumPoints) ;
89 for (ii = 2 ; ii < NumPoints ; ii++) {
90 flat_knots(jj) = ParametersArray(ii) ;
93 for (ii = 1 ; ii <= num_controls ; ii++) {
97 for (ii = 1 ; ii <= half_order ; ii++) {
98 contacts(ii) = half_order + ii - 1 ;
99 parameters(ii) = ParametersArray(1) ;
100 poles(ii) = null_point ;
101 contacts(jj) = half_order + ii - 1 ;
102 parameters(jj) = ParametersArray(NumPoints) ;
103 poles(jj) = null_point ;
106 jj = half_order + 1 ;
107 for (ii = 2 ; ii < NumPoints ; ii++) {
108 parameters(jj) = ParametersArray(ii) ;
109 poles(jj) = PointsArray(ii) ;
113 contacts(num_controls) = 0 ;
114 poles(1) = PointsArray(1) ;
115 poles(num_controls) = PointsArray(NumPoints) ;
116 BSplCLib::Interpolate(order-1,
123 if (!inversion_problem) {
125 new Geom_BSplineCurve(poles,
129 myIsDone = Standard_True ;
132 myError = GeomLib_InversionProblem ;
139 //=======================================================================
142 //=======================================================================
144 Handle(Geom_BSplineCurve) GeomLib_Interpolate::Curve() const