0022627: Change OCCT memory management defaults
[occt.git] / src / Law / Law_Linear.cxx
CommitLineData
7fd59977 1// File: Law_Linear.cxx
2// Created: Thu Jan 12 10:37:57 1995
3// Author: Laurent BOURESCHE
4// <lbo@phylox>
5
6// pmn -> 17/01/1996 added : Continuity, (Nb)Interals, D2, Trim
7
8#include <Law_Linear.ixx>
9
10
11Law_Linear::Law_Linear () {}
12
13
14void Law_Linear::Set (const Standard_Real Pdeb,
15 const Standard_Real Valdeb,
16 const Standard_Real Pfin,
17 const Standard_Real Valfin)
18{
19 pdeb = Pdeb;
20 pfin = Pfin;
21 valdeb = Valdeb;
22 valfin = Valfin;
23}
24
25//=======================================================================
26//function : Continuity
27//purpose :
28//=======================================================================
29GeomAbs_Shape Law_Linear::Continuity() const
30{
31 return GeomAbs_CN;
32}
33
34//=======================================================================
35//function : NbIntervals
36//purpose :
37//=======================================================================
38//Standard_Integer Law_Linear::NbIntervals(const GeomAbs_Shape S) const
39Standard_Integer Law_Linear::NbIntervals(const GeomAbs_Shape ) const
40{
41 return 1;
42}
43
44//=======================================================================
45//function : Intervals
46//purpose :
47//=======================================================================
48void Law_Linear::Intervals(TColStd_Array1OfReal& T,
49// const GeomAbs_Shape S) const
50 const GeomAbs_Shape ) const
51{
52 T.SetValue(T.Lower(), pdeb);
53 T.SetValue(T.Upper(), pfin);
54}
55
56Standard_Real Law_Linear::Value(const Standard_Real X)
57{
58 return ((X-pdeb)*valfin + (pfin-X)*valdeb)/(pfin-pdeb);
59}
60
61void Law_Linear::D1(const Standard_Real X,
62 Standard_Real& F,
63 Standard_Real& D)
64{
65 F = ((X-pdeb)*valfin + (pfin-X)*valdeb)/(pfin-pdeb);
66 D = (valfin-valdeb)/(pfin-pdeb);
67}
68void Law_Linear::D2(const Standard_Real X,
69 Standard_Real& F,
70 Standard_Real& D,
71 Standard_Real& D2)
72{
73 F = ((X-pdeb)*valfin + (pfin-X)*valdeb)/(pfin-pdeb);
74 D = (valfin-valdeb)/(pfin-pdeb);
75 D2 = 0;
76}
77
78//=======================================================================
79//function : Trim
80//purpose :
81//=======================================================================
82
83Handle(Law_Function) Law_Linear::Trim(const Standard_Real PFirst,
84 const Standard_Real PLast,
85// const Standard_Real Tol) const
86 const Standard_Real ) const
87{
88 Handle(Law_Linear) l = new (Law_Linear)();
89 Standard_Real Vdeb, Vfin;
90 Vdeb = (( PFirst-pdeb)*valfin + (pfin-PFirst)*valdeb)/(pfin-pdeb);
91 Vfin = (( PLast-pdeb)*valfin + (pfin-PLast)*valdeb)/(pfin-pdeb);
92 l->Set(PFirst, Vdeb, PLast, Vfin);
93
94 return l;
95}
96
97
98void Law_Linear::Bounds(Standard_Real& PFirst,
99 Standard_Real& PLast)
100{
101 PFirst = pdeb;
102 PLast = pfin;
103}