1 // Created on: 1996-08-30
2 // Created by: Xavier BENVENISTE
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <GeomLib_Interpolate.ixx>
25 #include <Standard_ConstructionError.hxx>
27 #include <BSplCLib.hxx>
29 #include <TColgp_Array1OfPnt.hxx>
30 #include <TColgp_Array1OfVec.hxx>
31 #include <TColStd_HArray1OfReal.hxx>
32 #include <TColStd_Array1OfBoolean.hxx>
33 #include <TColStd_Array1OfInteger.hxx>
34 #include <Handle_TColStd_HArray1OfBoolean.hxx>
36 //=======================================================================
37 //function : GeomLib_Interpolate
39 //=======================================================================
41 GeomLib_Interpolate::GeomLib_Interpolate
42 (const Standard_Integer Degree,
43 const Standard_Integer NumPoints,
44 const TColgp_Array1OfPnt& PointsArray,
45 const TColStd_Array1OfReal& ParametersArray)
55 if (NumPoints < Degree ||
56 PointsArray.Lower() != 1 ||
57 PointsArray.Upper() < NumPoints ||
58 ParametersArray.Lower() != 1 ||
59 ParametersArray.Upper() < NumPoints) {
60 myError = GeomLib_NotEnoughtPoints ;
62 else if (Degree < 3) {
63 myError = GeomLib_DegreeSmallerThan3 ;
66 gp_Pnt null_point(0.0e0, 0.0e0, 0.0e0) ;
67 Standard_Integer order = Degree + 1,
72 half_order = order / 2 ;
73 num_knots = NumPoints + 2 * order - 2 ;
74 num_controls = num_knots - order ;
75 TColStd_Array1OfReal flat_knots(1,num_knots) ;
76 TColStd_Array1OfInteger contacts (1,num_controls) ;
77 TColStd_Array1OfInteger multiplicities(1, NumPoints) ;
78 TColStd_Array1OfReal parameters(1,num_controls) ;
79 TColgp_Array1OfPnt poles(1,num_controls) ;
81 for (ii = 1 ; ii <= NumPoints ; ii++) {
82 multiplicities(ii) = 1 ;
84 multiplicities(1) = order ;
85 multiplicities(NumPoints) = order ;
87 jj = num_controls + 1 ; ii <= order ; ii++, jj++) {
89 flat_knots(ii) = ParametersArray(1) ;
90 flat_knots(jj) = ParametersArray(NumPoints) ;
93 for (ii = 2 ; ii < NumPoints ; ii++) {
94 flat_knots(jj) = ParametersArray(ii) ;
97 for (ii = 1 ; ii <= num_controls ; ii++) {
101 for (ii = 1 ; ii <= half_order ; ii++) {
102 contacts(ii) = half_order + ii - 1 ;
103 parameters(ii) = ParametersArray(1) ;
104 poles(ii) = null_point ;
105 contacts(jj) = half_order + ii - 1 ;
106 parameters(jj) = ParametersArray(NumPoints) ;
107 poles(jj) = null_point ;
110 jj = half_order + 1 ;
111 for (ii = 2 ; ii < NumPoints ; ii++) {
112 parameters(jj) = ParametersArray(ii) ;
113 poles(jj) = PointsArray(ii) ;
117 contacts(num_controls) = 0 ;
118 poles(1) = PointsArray(1) ;
119 poles(num_controls) = PointsArray(NumPoints) ;
120 BSplCLib::Interpolate(order-1,
127 if (!inversion_problem) {
129 new Geom_BSplineCurve(poles,
133 myIsDone = Standard_True ;
136 myError = GeomLib_InversionProblem ;
143 //=======================================================================
146 //=======================================================================
148 Handle(Geom_BSplineCurve) GeomLib_Interpolate::Curve() const