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