0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / CPnts / CPnts_MyRootFunction.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
7fd59977 15
42cf5bc1 16#include <CPnts_MyRootFunction.hxx>
7fd59977 17#include <math_GaussSingleIntegration.hxx>
42cf5bc1 18#include <Standard_DomainError.hxx>
7fd59977 19
20void CPnts_MyRootFunction::Init(const CPnts_RealFunction& F,
21 const Standard_Address D,
22 const Standard_Integer Order)
23{
24 myFunction.Init(F,D);
25 myOrder = Order;
26}
27
28void CPnts_MyRootFunction::Init(const Standard_Real X0,
29 const Standard_Real L)
30{
31 myX0 = X0;
32 myL = L;
33 myTol = -1; //to supress the tolerance
34}
35
36void CPnts_MyRootFunction::Init(const Standard_Real X0,
37 const Standard_Real L,
38 const Standard_Real Tol)
39{
40 myX0 = X0;
41 myL = L;
42 myTol = Tol;
43}
44
45Standard_Boolean CPnts_MyRootFunction::Value(const Standard_Real X,
46 Standard_Real& F)
47{
48 math_GaussSingleIntegration Length;
49
50 if (myTol <= 0) Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder);
51 else Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder, myTol);
52
53 if (Length.IsDone()){
54 F= Length.Value() - myL;
55 return Standard_True;
56 }
57 else {
58 return Standard_False;
59 }
60}
61
62Standard_Boolean CPnts_MyRootFunction::Derivative(const Standard_Real X,
63 Standard_Real& Df)
64{
65 return myFunction.Value(X,Df);
66}
67
68Standard_Boolean CPnts_MyRootFunction::Values(const Standard_Real X,
69 Standard_Real& F,
70 Standard_Real& Df)
71{
72 math_GaussSingleIntegration Length;
73
74 if (myTol <= 0) Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder);
75 else Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder, myTol);
76
77 if (Length.IsDone()){
78 F= Length.Value() - myL;
79 return myFunction.Value(X,Df);
80 }
81 else {
82 return Standard_False;
83 }
84}