0028599: Replacement of old Boolean operations with new ones in BRepProj_Projection...
[occt.git] / src / GeomLib / GeomLib_PolyFunc.cxx
1 // Created on: 1998-09-22
2 // Created by: Philippe MANGIN
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <GeomLib_PolyFunc.hxx>
19 #include <math_Vector.hxx>
20 #include <PLib.hxx>
21
22 GeomLib_PolyFunc::GeomLib_PolyFunc(const math_Vector& Coeffs) 
23                                   :myCoeffs(1, Coeffs.Length()-1)
24 { // On construit le polynome derive
25   for (Standard_Integer ii=1; ii<=myCoeffs.Length(); ii++)
26     myCoeffs(ii) = ii*Coeffs(ii+1);
27 }
28
29  Standard_Boolean GeomLib_PolyFunc::Value(const Standard_Real X,
30                                           Standard_Real& F) 
31 {
32   Standard_Real * coeff = &myCoeffs(1);
33   Standard_Real * ff = &F;
34   PLib::EvalPolynomial(X, 0, myCoeffs.Length()-1, 1,  coeff[0], ff[0]);
35   return Standard_True;
36 }
37
38  Standard_Boolean GeomLib_PolyFunc::Derivative(const Standard_Real X,
39                                                Standard_Real& D) 
40 {
41   Standard_Real * coeff = &myCoeffs(1);
42   math_Vector Aux(1, 2);
43   Standard_Real * ff = &Aux(1);  
44   PLib::EvalPolynomial(X, 1, myCoeffs.Length()-1, 1,  coeff[0], ff[0]);
45   D = Aux(2);
46   return Standard_True;
47 }
48
49  Standard_Boolean GeomLib_PolyFunc::Values(const Standard_Real X,
50                                            Standard_Real& F,
51                                            Standard_Real& D) 
52 {
53  Standard_Real * coeff = &myCoeffs(1);
54  math_Vector Aux(1, 2);
55  Standard_Real * ff = &Aux(1);  
56  PLib::EvalPolynomial(X, 1, myCoeffs.Length()-1, 1,  coeff[0], ff[0]);
57  F = Aux(1);
58  D = Aux(2);
59  return Standard_True;
60 }