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.
17 #include <GeomLib_Interpolate.ixx>
19 #include <Standard_ConstructionError.hxx>
21 #include <BSplCLib.hxx>
23 #include <TColgp_Array1OfPnt.hxx>
24 #include <TColgp_Array1OfVec.hxx>
25 #include <TColStd_HArray1OfReal.hxx>
26 #include <TColStd_Array1OfBoolean.hxx>
27 #include <TColStd_Array1OfInteger.hxx>
28 #include <TColStd_HArray1OfBoolean.hxx>
30 //=======================================================================
31 //function : GeomLib_Interpolate
33 //=======================================================================
35 GeomLib_Interpolate::GeomLib_Interpolate
36 (const Standard_Integer Degree,
37 const Standard_Integer NumPoints,
38 const TColgp_Array1OfPnt& PointsArray,
39 const TColStd_Array1OfReal& ParametersArray)
49 if (NumPoints < Degree ||
50 PointsArray.Lower() != 1 ||
51 PointsArray.Upper() < NumPoints ||
52 ParametersArray.Lower() != 1 ||
53 ParametersArray.Upper() < NumPoints) {
54 myError = GeomLib_NotEnoughtPoints ;
56 else if (Degree < 3) {
57 myError = GeomLib_DegreeSmallerThan3 ;
60 gp_Pnt null_point(0.0e0, 0.0e0, 0.0e0) ;
61 Standard_Integer order = Degree + 1,
66 half_order = order / 2 ;
67 num_knots = NumPoints + 2 * order - 2 ;
68 num_controls = num_knots - order ;
69 TColStd_Array1OfReal flat_knots(1,num_knots) ;
70 TColStd_Array1OfInteger contacts (1,num_controls) ;
71 TColStd_Array1OfInteger multiplicities(1, NumPoints) ;
72 TColStd_Array1OfReal parameters(1,num_controls) ;
73 TColgp_Array1OfPnt poles(1,num_controls) ;
75 for (ii = 1 ; ii <= NumPoints ; ii++) {
76 multiplicities(ii) = 1 ;
78 multiplicities(1) = order ;
79 multiplicities(NumPoints) = order ;
81 jj = num_controls + 1 ; ii <= order ; ii++, jj++) {
83 flat_knots(ii) = ParametersArray(1) ;
84 flat_knots(jj) = ParametersArray(NumPoints) ;
87 for (ii = 2 ; ii < NumPoints ; ii++) {
88 flat_knots(jj) = ParametersArray(ii) ;
91 for (ii = 1 ; ii <= num_controls ; ii++) {
95 for (ii = 1 ; ii <= half_order ; ii++) {
96 contacts(ii) = half_order + ii - 1 ;
97 parameters(ii) = ParametersArray(1) ;
98 poles(ii) = null_point ;
99 contacts(jj) = half_order + ii - 1 ;
100 parameters(jj) = ParametersArray(NumPoints) ;
101 poles(jj) = null_point ;
104 jj = half_order + 1 ;
105 for (ii = 2 ; ii < NumPoints ; ii++) {
106 parameters(jj) = ParametersArray(ii) ;
107 poles(jj) = PointsArray(ii) ;
111 contacts(num_controls) = 0 ;
112 poles(1) = PointsArray(1) ;
113 poles(num_controls) = PointsArray(NumPoints) ;
114 BSplCLib::Interpolate(order-1,
121 if (!inversion_problem) {
123 new Geom_BSplineCurve(poles,
127 myIsDone = Standard_True ;
130 myError = GeomLib_InversionProblem ;
137 //=======================================================================
140 //=======================================================================
142 Handle(Geom_BSplineCurve) GeomLib_Interpolate::Curve() const