0026838: Using GeomEvaluators for calculation of values of curves
[occt.git] / src / GeomEvaluator / GeomEvaluator_SurfaceOfExtrusion.cxx
1 // Created on: 2015-09-21
2 // Copyright (c) 2015 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 #include <GeomEvaluator_SurfaceOfExtrusion.hxx>
16
17 #include <GeomAdaptor_HCurve.hxx>
18
19 GeomEvaluator_SurfaceOfExtrusion::GeomEvaluator_SurfaceOfExtrusion(
20         const Handle(Geom_Curve)& theBase, const gp_Dir& theExtrusionDir)
21   : GeomEvaluator_Surface(),
22     myBaseCurve(theBase),
23     myDirection(theExtrusionDir)
24 {
25 }
26
27 GeomEvaluator_SurfaceOfExtrusion::GeomEvaluator_SurfaceOfExtrusion(
28         const Handle(Adaptor3d_HCurve)& theBase, const gp_Dir& theExtrusionDir)
29   : GeomEvaluator_Surface(),
30     myBaseAdaptor(theBase),
31     myDirection(theExtrusionDir)
32 {
33 }
34
35 void GeomEvaluator_SurfaceOfExtrusion::D0(
36     const Standard_Real theU, const Standard_Real theV,
37     gp_Pnt& theValue) const
38 {
39   if (!myBaseAdaptor.IsNull())
40     myBaseAdaptor->D0(theU, theValue);
41   else
42     myBaseCurve->D0(theU, theValue);
43
44   Shift(theV, theValue);
45 }
46
47 void GeomEvaluator_SurfaceOfExtrusion::D1(
48     const Standard_Real theU, const Standard_Real theV,
49     gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V) const
50 {
51   if (!myBaseAdaptor.IsNull())
52     myBaseAdaptor->D1(theU, theValue, theD1U);
53   else
54     myBaseCurve->D1(theU, theValue, theD1U);
55
56   theD1V = myDirection;
57   Shift(theV, theValue);
58 }
59
60 void GeomEvaluator_SurfaceOfExtrusion::D2(
61     const Standard_Real theU, const Standard_Real theV,
62     gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V,
63     gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV) const
64 {
65   if (!myBaseAdaptor.IsNull())
66     myBaseAdaptor->D2(theU, theValue, theD1U, theD2U);
67   else
68     myBaseCurve->D2(theU, theValue, theD1U, theD2U);
69
70   theD1V = myDirection;
71   theD2V.SetCoord(0.0, 0.0, 0.0);
72   theD2UV.SetCoord(0.0, 0.0, 0.0);
73
74   Shift(theV, theValue);
75 }
76
77 void GeomEvaluator_SurfaceOfExtrusion::D3(
78     const Standard_Real theU, const Standard_Real theV,
79     gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V,
80     gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV,
81     gp_Vec& theD3U, gp_Vec& theD3V, gp_Vec& theD3UUV, gp_Vec& theD3UVV) const
82 {
83   if (!myBaseAdaptor.IsNull())
84     myBaseAdaptor->D3(theU, theValue, theD1U, theD2U, theD3U);
85   else
86     myBaseCurve->D3(theU, theValue, theD1U, theD2U, theD3U);
87
88   theD1V = myDirection;
89   theD2V.SetCoord(0.0, 0.0, 0.0);
90   theD2UV.SetCoord(0.0, 0.0, 0.0);
91   theD3V.SetCoord(0.0, 0.0, 0.0);
92   theD3UUV.SetCoord(0.0, 0.0, 0.0);
93   theD3UVV.SetCoord(0.0, 0.0, 0.0);
94
95   Shift(theV, theValue);
96 }
97
98 gp_Vec GeomEvaluator_SurfaceOfExtrusion::DN(
99     const Standard_Real theU, const Standard_Real ,
100     const Standard_Integer theDerU, const Standard_Integer theDerV) const
101 {
102   Standard_RangeError_Raise_if(theDerU < 0, "GeomEvaluator_SurfaceOfExtrusion::DN(): theDerU < 0");
103   Standard_RangeError_Raise_if(theDerV < 0, "GeomEvaluator_SurfaceOfExtrusion::DN(): theDerV < 0");
104   Standard_RangeError_Raise_if(theDerU + theDerV < 1,
105       "GeomEvaluator_SurfaceOfExtrusion::DN(): theDerU + theDerV < 1");
106
107   gp_Vec aResult(0.0, 0.0, 0.0);
108   if (theDerV == 0)
109   {
110     if (!myBaseAdaptor.IsNull())
111       aResult = myBaseAdaptor->DN(theU, theDerU);
112     else
113       aResult = myBaseCurve->DN(theU, theDerU);
114   }
115   else if (theDerU == 0 && theDerV == 1)
116     aResult = gp_Vec(myDirection);
117   return aResult;
118 }
119