2121//! @file Geom_ExtrusionUtils.pxx
2222//! @brief Shared utility functions for extrusion surface evaluation.
2323//!
24- //! This file provides template functions for evaluating points and derivatives
25- //! on linear extrusion surfaces. The functions are templated to work with both
26- //! Geom_Curve (for Geom_SurfaceOfLinearExtrusion) and Adaptor3d_Curve
27- //! (for GeomAdaptor_SurfaceOfLinearExtrusion).
24+ //! This file provides both direct calculation functions (accepting pre-computed curve values)
25+ //! and template functions for evaluating points and derivatives on linear extrusion surfaces.
26+ //! The template functions work with both Geom_Curve (for Geom_SurfaceOfLinearExtrusion)
27+ //! and Adaptor3d_Curve (for GeomAdaptor_SurfaceOfLinearExtrusion).
2828//!
2929//! Extrusion surface: P(U,V) = C(U) + V * Direction
3030
3131namespace Geom_ExtrusionUtils
3232{
3333
34+ //! Calculates point on extrusion surface from pre-computed curve point.
35+ //! @param theCurvePt Pre-computed curve point C(U)
36+ //! @param theV Parameter along the extrusion direction
37+ //! @param theDir Extrusion direction XYZ (must be normalized)
38+ //! @param theP [out] Evaluated surface point
39+ inline void CalculateD0(const gp_Pnt& theCurvePt,
40+ const double theV,
41+ const gp_XYZ& theDir,
42+ gp_Pnt& theP)
43+ {
44+ theP.SetXYZ(theCurvePt.XYZ() + theV * theDir);
45+ }
46+
47+ //! Calculates point and first derivatives on extrusion surface from pre-computed curve D1.
48+ //! @param theCurvePt Pre-computed curve point C(U)
49+ //! @param theCurveD1 Pre-computed curve first derivative C'(U)
50+ //! @param theV Parameter along the extrusion direction
51+ //! @param theDir Extrusion direction XYZ (must be normalized)
52+ //! @param theP [out] Evaluated surface point
53+ //! @param theD1U [out] First derivative with respect to U
54+ //! @param theD1V [out] First derivative with respect to V
55+ inline void CalculateD1(const gp_Pnt& theCurvePt,
56+ const gp_Vec& theCurveD1,
57+ const double theV,
58+ const gp_XYZ& theDir,
59+ gp_Pnt& theP,
60+ gp_Vec& theD1U,
61+ gp_Vec& theD1V)
62+ {
63+ theP.SetXYZ(theCurvePt.XYZ() + theV * theDir);
64+ theD1U = theCurveD1;
65+ theD1V.SetXYZ(theDir);
66+ }
67+
68+ //! Calculates point, first and second derivatives on extrusion surface from pre-computed curve D2.
69+ //! @param theCurvePt Pre-computed curve point C(U)
70+ //! @param theCurveD1 Pre-computed curve first derivative C'(U)
71+ //! @param theCurveD2 Pre-computed curve second derivative C''(U)
72+ //! @param theV Parameter along the extrusion direction
73+ //! @param theDir Extrusion direction XYZ (must be normalized)
74+ //! @param theP [out] Evaluated surface point
75+ //! @param theD1U [out] First derivative with respect to U
76+ //! @param theD1V [out] First derivative with respect to V
77+ //! @param theD2U [out] Second derivative with respect to U
78+ //! @param theD2V [out] Second derivative with respect to V (always zero)
79+ //! @param theD2UV [out] Mixed second derivative (always zero)
80+ inline void CalculateD2(const gp_Pnt& theCurvePt,
81+ const gp_Vec& theCurveD1,
82+ const gp_Vec& theCurveD2,
83+ const double theV,
84+ const gp_XYZ& theDir,
85+ gp_Pnt& theP,
86+ gp_Vec& theD1U,
87+ gp_Vec& theD1V,
88+ gp_Vec& theD2U,
89+ gp_Vec& theD2V,
90+ gp_Vec& theD2UV)
91+ {
92+ theP.SetXYZ(theCurvePt.XYZ() + theV * theDir);
93+ theD1U = theCurveD1;
94+ theD1V.SetXYZ(theDir);
95+ theD2U = theCurveD2;
96+ theD2V.SetCoord(0.0, 0.0, 0.0);
97+ theD2UV.SetCoord(0.0, 0.0, 0.0);
98+ }
99+
100+ //! Calculates point and derivatives up to third order on extrusion surface from pre-computed curve
101+ //! D3.
102+ //! @param theCurvePt Pre-computed curve point C(U)
103+ //! @param theCurveD1 Pre-computed curve first derivative C'(U)
104+ //! @param theCurveD2 Pre-computed curve second derivative C''(U)
105+ //! @param theCurveD3 Pre-computed curve third derivative C'''(U)
106+ //! @param theV Parameter along the extrusion direction
107+ //! @param theDir Extrusion direction XYZ (must be normalized)
108+ //! @param theP [out] Evaluated surface point
109+ //! @param theD1U [out] First derivative with respect to U
110+ //! @param theD1V [out] First derivative with respect to V
111+ //! @param theD2U [out] Second derivative with respect to U
112+ //! @param theD2V [out] Second derivative with respect to V (always zero)
113+ //! @param theD2UV [out] Mixed second derivative (always zero)
114+ //! @param theD3U [out] Third derivative with respect to U
115+ //! @param theD3V [out] Third derivative with respect to V (always zero)
116+ //! @param theD3UUV [out] Mixed third derivative (UUV) (always zero)
117+ //! @param theD3UVV [out] Mixed third derivative (UVV) (always zero)
118+ inline void CalculateD3(const gp_Pnt& theCurvePt,
119+ const gp_Vec& theCurveD1,
120+ const gp_Vec& theCurveD2,
121+ const gp_Vec& theCurveD3,
122+ const double theV,
123+ const gp_XYZ& theDir,
124+ gp_Pnt& theP,
125+ gp_Vec& theD1U,
126+ gp_Vec& theD1V,
127+ gp_Vec& theD2U,
128+ gp_Vec& theD2V,
129+ gp_Vec& theD2UV,
130+ gp_Vec& theD3U,
131+ gp_Vec& theD3V,
132+ gp_Vec& theD3UUV,
133+ gp_Vec& theD3UVV)
134+ {
135+ theP.SetXYZ(theCurvePt.XYZ() + theV * theDir);
136+ theD1U = theCurveD1;
137+ theD1V.SetXYZ(theDir);
138+ theD2U = theCurveD2;
139+ theD2V.SetCoord(0.0, 0.0, 0.0);
140+ theD2UV.SetCoord(0.0, 0.0, 0.0);
141+ theD3U = theCurveD3;
142+ theD3V.SetCoord(0.0, 0.0, 0.0);
143+ theD3UUV.SetCoord(0.0, 0.0, 0.0);
144+ theD3UVV.SetCoord(0.0, 0.0, 0.0);
145+ }
146+
147+ //! Calculates N-th derivative on extrusion surface from pre-computed curve derivative.
148+ //! @param theCurveDN Pre-computed curve N-th derivative C^(theDerU)(U)
149+ //! @param theDir Extrusion direction XYZ (must be normalized)
150+ //! @param theDerU Derivative order with respect to U
151+ //! @param theDerV Derivative order with respect to V
152+ //! @return The derivative vector
153+ inline gp_Vec CalculateDN(const gp_Vec& theCurveDN,
154+ const gp_XYZ& theDir,
155+ const int theDerU,
156+ const int theDerV)
157+ {
158+ if (theDerV == 0)
159+ return theCurveDN;
160+ else if (theDerU == 0 && theDerV == 1)
161+ return gp_Vec(theDir);
162+ return gp_Vec(0.0, 0.0, 0.0);
163+ }
164+
34165//! Evaluates point on extrusion surface.
35166//! @tparam CurveType Type supporting D0(param, point) method
36167//! @param theU Parameter along the basis curve
@@ -45,8 +176,9 @@ inline void D0(const double theU,
45176 const gp_XYZ& theDir,
46177 gp_Pnt& theP)
47178{
48- theBasis.D0(theU, theP);
49- theP.SetXYZ(theP.XYZ() + theV * theDir);
179+ gp_Pnt aCurvePt;
180+ theBasis.D0(theU, aCurvePt);
181+ CalculateD0(aCurvePt, theV, theDir, theP);
50182}
51183
52184//! Evaluates point and first derivatives on extrusion surface.
@@ -67,9 +199,10 @@ inline void D1(const double theU,
67199 gp_Vec& theD1U,
68200 gp_Vec& theD1V)
69201{
70- theBasis.D1(theU, theP, theD1U);
71- theP.SetXYZ(theP.XYZ() + theV * theDir);
72- theD1V.SetXYZ(theDir);
202+ gp_Pnt aCurvePt;
203+ gp_Vec aCurveD1;
204+ theBasis.D1(theU, aCurvePt, aCurveD1);
205+ CalculateD1(aCurvePt, aCurveD1, theV, theDir, theP, theD1U, theD1V);
73206}
74207
75208//! Evaluates point, first and second derivatives on extrusion surface.
@@ -96,11 +229,20 @@ inline void D2(const double theU,
96229 gp_Vec& theD2V,
97230 gp_Vec& theD2UV)
98231{
99- theBasis.D2(theU, theP, theD1U, theD2U);
100- theP.SetXYZ(theP.XYZ() + theV * theDir);
101- theD1V.SetXYZ(theDir);
102- theD2V.SetCoord(0.0, 0.0, 0.0);
103- theD2UV.SetCoord(0.0, 0.0, 0.0);
232+ gp_Pnt aCurvePt;
233+ gp_Vec aCurveD1, aCurveD2;
234+ theBasis.D2(theU, aCurvePt, aCurveD1, aCurveD2);
235+ CalculateD2(aCurvePt,
236+ aCurveD1,
237+ aCurveD2,
238+ theV,
239+ theDir,
240+ theP,
241+ theD1U,
242+ theD1V,
243+ theD2U,
244+ theD2V,
245+ theD2UV);
104246}
105247
106248//! Evaluates point, first, second and third derivatives on extrusion surface.
@@ -135,14 +277,25 @@ inline void D3(const double theU,
135277 gp_Vec& theD3UUV,
136278 gp_Vec& theD3UVV)
137279{
138- theBasis.D3(theU, theP, theD1U, theD2U, theD3U);
139- theP.SetXYZ(theP.XYZ() + theV * theDir);
140- theD1V.SetXYZ(theDir);
141- theD2V.SetCoord(0.0, 0.0, 0.0);
142- theD2UV.SetCoord(0.0, 0.0, 0.0);
143- theD3V.SetCoord(0.0, 0.0, 0.0);
144- theD3UUV.SetCoord(0.0, 0.0, 0.0);
145- theD3UVV.SetCoord(0.0, 0.0, 0.0);
280+ gp_Pnt aCurvePt;
281+ gp_Vec aCurveD1, aCurveD2, aCurveD3;
282+ theBasis.D3(theU, aCurvePt, aCurveD1, aCurveD2, aCurveD3);
283+ CalculateD3(aCurvePt,
284+ aCurveD1,
285+ aCurveD2,
286+ aCurveD3,
287+ theV,
288+ theDir,
289+ theP,
290+ theD1U,
291+ theD1V,
292+ theD2U,
293+ theD2V,
294+ theD2UV,
295+ theD3U,
296+ theD3V,
297+ theD3UUV,
298+ theD3UVV);
146299}
147300
148301//! Evaluates N-th derivative on extrusion surface.
@@ -160,11 +313,8 @@ inline gp_Vec DN(const double theU,
160313 const int theDerU,
161314 const int theDerV)
162315{
163- if (theDerV == 0)
164- return theBasis.DN(theU, theDerU);
165- else if (theDerU == 0 && theDerV == 1)
166- return gp_Vec(theDir);
167- return gp_Vec(0.0, 0.0, 0.0);
316+ gp_Vec aCurveDN = (theDerV == 0) ? theBasis.DN(theU, theDerU) : gp_Vec();
317+ return CalculateDN(aCurveDN, theDir, theDerU, theDerV);
168318}
169319
170320} // namespace Geom_ExtrusionUtils
0 commit comments