1 // Created on: 1991-09-09
2 // Created by: Michel Chauvat
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _ElSLib_HeaderFile
18 #define _ElSLib_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Real.hxx>
26 #include <Standard_Integer.hxx>
40 //! Provides functions for basic geometric computation on
41 //! elementary surfaces.
43 //! - calculation of a point or derived vector on a surface
44 //! where the surface is provided by the gp package, or
45 //! defined in canonical form (as in the gp package), and
46 //! the point is defined with a parameter,
47 //! - evaluation of the parameters corresponding to a
48 //! point on an elementary surface from gp,
49 //! - calculation of isoparametric curves on an elementary
50 //! surface defined in canonical form (as in the gp package).
52 //! - ElSLib stands for Elementary Surfaces Library.
53 //! - If the surfaces provided by the gp package are not
54 //! explicitly parameterized, they still have an implicit
55 //! parameterization, similar to that which they infer on
56 //! the equivalent Geom surfaces.
57 //! Note: ElSLib stands for Elementary Surfaces Library.
65 //! For elementary surfaces from the gp package (planes,
66 //! cones, cylinders, spheres and tori), computes the point
67 //! of parameters (U, V).
68 Standard_EXPORT static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Pln& Pl);
70 static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Cone& C);
72 static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C);
74 static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Sphere& S);
76 static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Torus& T);
78 //! For elementary surfaces from the gp package (planes,
79 //! cones, cylinders, spheres and tori), computes the
80 //! derivative vector of order Nu and Nv in the u and v
81 //! parametric directions respectively, at the point of
82 //! parameters (U, V).
83 Standard_EXPORT static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Pln& Pl, const Standard_Integer Nu, const Standard_Integer Nv);
85 static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Cone& C, const Standard_Integer Nu, const Standard_Integer Nv);
87 static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C, const Standard_Integer Nu, const Standard_Integer Nv);
89 static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Sphere& S, const Standard_Integer Nu, const Standard_Integer Nv);
91 static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Torus& T, const Standard_Integer Nu, const Standard_Integer Nv);
93 //! For elementary surfaces from the gp package (planes,
94 //! cones, cylinders, spheres and tori), computes the point P
95 //! of parameters (U, V).inline
96 Standard_EXPORT static void D0 (const Standard_Real U, const Standard_Real V, const gp_Pln& Pl, gp_Pnt& P);
98 static void D0 (const Standard_Real U, const Standard_Real V, const gp_Cone& C, gp_Pnt& P);
100 static void D0 (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C, gp_Pnt& P);
102 static void D0 (const Standard_Real U, const Standard_Real V, const gp_Sphere& S, gp_Pnt& P);
104 static void D0 (const Standard_Real U, const Standard_Real V, const gp_Torus& T, gp_Pnt& P);
107 //! For elementary surfaces from the gp package (planes,
108 //! cones, cylinders, spheres and tori), computes:
109 //! - the point P of parameters (U, V), and
110 //! - the first derivative vectors Vu and Vv at this point in
111 //! the u and v parametric directions respectively.
112 Standard_EXPORT static void D1 (const Standard_Real U, const Standard_Real V, const gp_Pln& Pl, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
114 static void D1 (const Standard_Real U, const Standard_Real V, const gp_Cone& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
116 static void D1 (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
118 static void D1 (const Standard_Real U, const Standard_Real V, const gp_Sphere& S, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
120 static void D1 (const Standard_Real U, const Standard_Real V, const gp_Torus& T, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
123 //! For elementary surfaces from the gp package (cones,
124 //! cylinders, spheres and tori), computes:
125 //! - the point P of parameters (U, V), and
126 //! - the first derivative vectors Vu and Vv at this point in
127 //! the u and v parametric directions respectively, and
128 //! - the second derivative vectors Vuu, Vvv and Vuv at this point.
129 Standard_EXPORT static void D2 (const Standard_Real U, const Standard_Real V, const gp_Cone& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
131 static void D2 (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
133 static void D2 (const Standard_Real U, const Standard_Real V, const gp_Sphere& S, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
135 static void D2 (const Standard_Real U, const Standard_Real V, const gp_Torus& T, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
138 //! For elementary surfaces from the gp package (cones,
139 //! cylinders, spheres and tori), computes:
140 //! - the point P of parameters (U,V), and
141 //! - the first derivative vectors Vu and Vv at this point in
142 //! the u and v parametric directions respectively, and
143 //! - the second derivative vectors Vuu, Vvv and Vuv at
145 //! - the third derivative vectors Vuuu, Vvvv, Vuuv and
146 //! Vuvv at this point.
147 Standard_EXPORT static void D3 (const Standard_Real U, const Standard_Real V, const gp_Cone& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
149 static void D3 (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
151 static void D3 (const Standard_Real U, const Standard_Real V, const gp_Sphere& S, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
153 //! Surface evaluation
154 //! The following functions compute the point and the
155 //! derivatives on elementary surfaces defined with their
156 //! geometric characterisitics.
157 //! You don't need to create the surface to use these functions.
158 //! These functions are called by the previous ones.
160 //! A cylinder is defined with its position and its radius.
161 static void D3 (const Standard_Real U, const Standard_Real V, const gp_Torus& T, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
163 Standard_EXPORT static gp_Pnt PlaneValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos);
165 Standard_EXPORT static gp_Pnt CylinderValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius);
167 Standard_EXPORT static gp_Pnt ConeValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle);
169 Standard_EXPORT static gp_Pnt SphereValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius);
171 Standard_EXPORT static gp_Pnt TorusValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
173 Standard_EXPORT static gp_Vec PlaneDN (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Integer Nu, const Standard_Integer Nv);
175 Standard_EXPORT static gp_Vec CylinderDN (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Integer Nu, const Standard_Integer Nv);
177 Standard_EXPORT static gp_Vec ConeDN (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, const Standard_Integer Nu, const Standard_Integer Nv);
179 Standard_EXPORT static gp_Vec SphereDN (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Integer Nu, const Standard_Integer Nv);
181 Standard_EXPORT static gp_Vec TorusDN (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Integer Nu, const Standard_Integer Nv);
183 Standard_EXPORT static void PlaneD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, gp_Pnt& P);
185 Standard_EXPORT static void ConeD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, gp_Pnt& P);
187 Standard_EXPORT static void CylinderD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P);
189 Standard_EXPORT static void SphereD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P);
191 Standard_EXPORT static void TorusD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, gp_Pnt& P);
193 Standard_EXPORT static void PlaneD1 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
195 Standard_EXPORT static void ConeD1 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
197 Standard_EXPORT static void CylinderD1 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
199 Standard_EXPORT static void SphereD1 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
201 Standard_EXPORT static void TorusD1 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
203 Standard_EXPORT static void ConeD2 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
205 Standard_EXPORT static void CylinderD2 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
207 Standard_EXPORT static void SphereD2 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
209 Standard_EXPORT static void TorusD2 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv);
211 Standard_EXPORT static void ConeD3 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
213 Standard_EXPORT static void CylinderD3 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
215 Standard_EXPORT static void SphereD3 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
218 //! The following functions compute the parametric values
219 //! corresponding to a given point on a elementary surface.
220 //! The point should be on the surface.
221 Standard_EXPORT static void TorusD3 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv, gp_Vec& Vuu, gp_Vec& Vvv, gp_Vec& Vuv, gp_Vec& Vuuu, gp_Vec& Vvvv, gp_Vec& Vuuv, gp_Vec& Vuvv);
225 //! Pl.Location() + U * Pl.XDirection() + V * Pl.YDirection()
226 static void Parameters (const gp_Pln& Pl, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
229 //! P (U, V) = Location + V * ZDirection +
230 //! Radius * (Cos(U) * XDirection + Sin (U) * YDirection)
231 static void Parameters (const gp_Cylinder& C, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
234 //! P (U, V) = Location + V * ZDirection +
235 //! (Radius + V * Tan (SemiAngle)) *
236 //! (Cos(U) * XDirection + Sin(U) * YDirection)
237 static void Parameters (const gp_Cone& C, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
240 //! P (U, V) = Location +
241 //! Radius * Cos (V) * (Cos (U) * XDirection + Sin (U) * YDirection) +
242 //! Radius * Sin (V) * ZDirection
243 static void Parameters (const gp_Sphere& S, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
246 //! P (U, V) = Location +
247 //! (MajorRadius + MinorRadius * Cos(U)) *
248 //! (Cos(V) * XDirection - Sin(V) * YDirection) +
249 //! MinorRadius * Sin(U) * ZDirection
250 static void Parameters (const gp_Torus& T, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
254 //! Pl.Location() + U * Pl.XDirection() + V * Pl.YDirection()
255 Standard_EXPORT static void PlaneParameters (const gp_Ax3& Pos, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
258 //! P (U, V) = Location + V * ZDirection +
259 //! Radius * (Cos(U) * XDirection + Sin (U) * YDirection)
260 Standard_EXPORT static void CylinderParameters (const gp_Ax3& Pos, const Standard_Real Radius, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
263 //! P (U, V) = Location + V * ZDirection +
264 //! (Radius + V * Tan (SemiAngle)) *
265 //! (Cos(U) * XDirection + Sin(U) * YDirection)
266 Standard_EXPORT static void ConeParameters (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
269 //! P (U, V) = Location +
270 //! Radius * Cos (V) * (Cos (U) * XDirection + Sin (U) * YDirection) +
271 //! Radius * Sin (V) * ZDirection
272 Standard_EXPORT static void SphereParameters (const gp_Ax3& Pos, const Standard_Real Radius, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
275 //! P (U, V) = Location +
276 //! (MajorRadius + MinorRadius * Cos(U)) *
277 //! (Cos(V) * XDirection - Sin(V) * YDirection) +
278 //! MinorRadius * Sin(U) * ZDirection
279 Standard_EXPORT static void TorusParameters (const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
281 //! compute the U Isoparametric gp_Lin of the plane.
282 Standard_EXPORT static gp_Lin PlaneUIso (const gp_Ax3& Pos, const Standard_Real U);
284 //! compute the U Isoparametric gp_Lin of the cylinder.
285 Standard_EXPORT static gp_Lin CylinderUIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real U);
287 //! compute the U Isoparametric gp_Lin of the cone.
288 Standard_EXPORT static gp_Lin ConeUIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, const Standard_Real U);
290 //! compute the U Isoparametric gp_Circ of the sphere,
291 //! (the meridian is not trimmed).
292 Standard_EXPORT static gp_Circ SphereUIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real U);
294 //! compute the U Isoparametric gp_Circ of the torus.
295 Standard_EXPORT static gp_Circ TorusUIso (const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Real U);
297 //! compute the V Isoparametric gp_Lin of the plane.
298 Standard_EXPORT static gp_Lin PlaneVIso (const gp_Ax3& Pos, const Standard_Real V);
300 //! compute the V Isoparametric gp_Circ of the cylinder.
301 Standard_EXPORT static gp_Circ CylinderVIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real V);
303 //! compute the V Isoparametric gp_Circ of the cone.
304 Standard_EXPORT static gp_Circ ConeVIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, const Standard_Real V);
306 //! compute the V Isoparametric gp_Circ of the sphere,
307 //! (the meridian is not trimmed).
308 Standard_EXPORT static gp_Circ SphereVIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real V);
310 //! compute the V Isoparametric gp_Circ of the torus.
311 Standard_EXPORT static gp_Circ TorusVIso (const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Real V);
331 #include <ElSLib.lxx>
337 #endif // _ElSLib_HeaderFile