0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / Law / Law_S.cxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 // pmn -> modified 17/01/1996 : utilisation de Curve() et SetCurve()
16
17 #include <Law_BSpline.hxx>
18 #include <Law_S.hxx>
19 #include <Standard_Type.hxx>
20 #include <TColStd_Array1OfInteger.hxx>
21 #include <TColStd_Array1OfReal.hxx>
22
23 IMPLEMENT_STANDARD_RTTIEXT(Law_S,Law_BSpFunc)
24
25 Law_S::Law_S ()
26 {}
27
28
29 void Law_S::Set (const Standard_Real Pdeb,
30                  const Standard_Real Valdeb,
31                  const Standard_Real Pfin,
32                  const Standard_Real Valfin)
33 {
34   Set(Pdeb,Valdeb,0.,Pfin,Valfin,0.);
35 }
36
37
38 void Law_S::Set (const Standard_Real Pdeb,
39                  const Standard_Real Valdeb,
40                  const Standard_Real Ddeb,
41                  const Standard_Real Pfin,
42                  const Standard_Real Valfin,
43                  const Standard_Real Dfin)
44 {
45   TColStd_Array1OfReal    poles(1,4);
46   TColStd_Array1OfReal    knots(1,2);
47   TColStd_Array1OfInteger mults(1,2);
48   poles(1) = Valdeb; poles(4) = Valfin;
49   Standard_Real coe = (Pfin-Pdeb) / 3.;
50   poles(2) = Valdeb + coe * Ddeb;
51   poles(3) = Valfin - coe * Dfin;
52   knots(1) = Pdeb; knots(2) = Pfin;
53   mults(1) = mults(2) = 4; 
54
55   SetCurve( new Law_BSpline(poles,knots,mults,3) );
56 }