2de99d5a3b6735042bdd4a96aa01c00fc7409fec
[occt.git] / src / ElSLib / ElSLib.hxx
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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _ElSLib_HeaderFile
18 #define _ElSLib_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Real.hxx>
25 #include <gp_Pnt.hxx>
26 #include <Standard_Integer.hxx>
27 #include <gp_Vec.hxx>
28 class gp_Pnt;
29 class gp_Pln;
30 class gp_Cone;
31 class gp_Cylinder;
32 class gp_Sphere;
33 class gp_Torus;
34 class gp_Vec;
35 class gp_Ax3;
36 class gp_Lin;
37 class gp_Circ;
38
39
40 //! Provides functions for basic geometric computation on
41 //! elementary surfaces.
42 //! This includes:
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).
51 //! Notes:
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.
58 class ElSLib 
59 {
60 public:
61
62   DEFINE_STANDARD_ALLOC
63
64   
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);
69   
70     static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Cone& C);
71   
72     static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C);
73   
74     static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Sphere& S);
75   
76     static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Torus& T);
77   
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);
84   
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);
86   
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);
88   
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);
90   
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);
92   
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);
97   
98     static void D0 (const Standard_Real U, const Standard_Real V, const gp_Cone& C, gp_Pnt& P);
99   
100     static void D0 (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C, gp_Pnt& P);
101   
102     static void D0 (const Standard_Real U, const Standard_Real V, const gp_Sphere& S, gp_Pnt& P);
103   
104     static void D0 (const Standard_Real U, const Standard_Real V, const gp_Torus& T, gp_Pnt& P);
105   
106
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);
113   
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);
115   
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);
117   
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);
119   
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);
121   
122
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);
130   
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);
132   
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);
134   
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);
136   
137
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
144   //! this point, and
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);
148   
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);
150   
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);
152   
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.
159   //! Example :
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);
162   
163   Standard_EXPORT static gp_Pnt PlaneValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos);
164   
165   Standard_EXPORT static gp_Pnt CylinderValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius);
166   
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);
168   
169   Standard_EXPORT static gp_Pnt SphereValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius);
170   
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);
172   
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);
174   
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);
176   
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);
178   
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);
180   
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);
182   
183   Standard_EXPORT static void PlaneD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, gp_Pnt& P);
184   
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);
186   
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);
188   
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);
190   
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);
192   
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);
194   
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);
196   
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);
198   
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);
200   
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);
202   
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);
204   
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);
206   
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);
208   
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);
210   
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);
212   
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);
214   
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);
216   
217
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);
222   
223   //! parametrization
224   //! P (U, V) =
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);
227   
228   //! parametrization
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);
232   
233   //! parametrization
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);
238   
239   //! parametrization
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);
244   
245   //! parametrization
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);
251   
252   //! parametrization
253   //! P (U, 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);
256   
257   //! parametrization
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);
261   
262   //! parametrization
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);
267   
268   //! parametrization
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);
273   
274   //! parametrization
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);
280   
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);
283   
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);
286   
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);
289   
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);
293   
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);
296   
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);
299   
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);
302   
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);
305   
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);
309   
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);
312
313
314
315
316 protected:
317
318
319
320
321
322 private:
323
324
325
326
327
328 };
329
330
331 #include <ElSLib.lxx>
332
333
334
335
336
337 #endif // _ElSLib_HeaderFile