0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / ElSLib / ElSLib.hxx
CommitLineData
42cf5bc1 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
42cf5bc1 24#include <gp_Pnt.hxx>
42cf5bc1 25#include <gp_Vec.hxx>
26class gp_Pnt;
27class gp_Pln;
28class gp_Cone;
29class gp_Cylinder;
30class gp_Sphere;
31class gp_Torus;
32class gp_Vec;
33class gp_Ax3;
34class gp_Lin;
35class gp_Circ;
36
37
38//! Provides functions for basic geometric computation on
39//! elementary surfaces.
40//! This includes:
41//! - calculation of a point or derived vector on a surface
42//! where the surface is provided by the gp package, or
43//! defined in canonical form (as in the gp package), and
44//! the point is defined with a parameter,
45//! - evaluation of the parameters corresponding to a
46//! point on an elementary surface from gp,
47//! - calculation of isoparametric curves on an elementary
48//! surface defined in canonical form (as in the gp package).
49//! Notes:
50//! - ElSLib stands for Elementary Surfaces Library.
51//! - If the surfaces provided by the gp package are not
52//! explicitly parameterized, they still have an implicit
53//! parameterization, similar to that which they infer on
54//! the equivalent Geom surfaces.
55//! Note: ElSLib stands for Elementary Surfaces Library.
56class ElSLib
57{
58public:
59
60 DEFINE_STANDARD_ALLOC
61
62
63 //! For elementary surfaces from the gp package (planes,
64 //! cones, cylinders, spheres and tori), computes the point
65 //! of parameters (U, V).
0f57ab75 66 static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Pln& Pl);
42cf5bc1 67
68 static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Cone& C);
69
70 static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C);
71
72 static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Sphere& S);
73
74 static gp_Pnt Value (const Standard_Real U, const Standard_Real V, const gp_Torus& T);
75
76 //! For elementary surfaces from the gp package (planes,
77 //! cones, cylinders, spheres and tori), computes the
78 //! derivative vector of order Nu and Nv in the u and v
79 //! parametric directions respectively, at the point of
80 //! parameters (U, V).
0f57ab75 81 static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Pln& Pl, const Standard_Integer Nu, const Standard_Integer Nv);
42cf5bc1 82
83 static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Cone& C, const Standard_Integer Nu, const Standard_Integer Nv);
84
85 static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Cylinder& 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_Sphere& S, const Standard_Integer Nu, const Standard_Integer Nv);
88
89 static gp_Vec DN (const Standard_Real U, const Standard_Real V, const gp_Torus& T, const Standard_Integer Nu, const Standard_Integer Nv);
90
91 //! For elementary surfaces from the gp package (planes,
92 //! cones, cylinders, spheres and tori), computes the point P
93 //! of parameters (U, V).inline
0f57ab75 94 static void D0 (const Standard_Real U, const Standard_Real V, const gp_Pln& Pl, gp_Pnt& P);
42cf5bc1 95
96 static void D0 (const Standard_Real U, const Standard_Real V, const gp_Cone& C, gp_Pnt& P);
97
98 static void D0 (const Standard_Real U, const Standard_Real V, const gp_Cylinder& C, gp_Pnt& P);
99
100 static void D0 (const Standard_Real U, const Standard_Real V, const gp_Sphere& S, gp_Pnt& P);
101
102 static void D0 (const Standard_Real U, const Standard_Real V, const gp_Torus& T, gp_Pnt& P);
103
104
105 //! For elementary surfaces from the gp package (planes,
106 //! cones, cylinders, spheres and tori), computes:
107 //! - the point P of parameters (U, V), and
108 //! - the first derivative vectors Vu and Vv at this point in
109 //! the u and v parametric directions respectively.
0f57ab75 110 static void D1 (const Standard_Real U, const Standard_Real V, const gp_Pln& Pl, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
42cf5bc1 111
112 static void D1 (const Standard_Real U, const Standard_Real V, const gp_Cone& C, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
113
114 static void D1 (const Standard_Real U, const Standard_Real V, const gp_Cylinder& 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_Sphere& S, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
117
118 static void D1 (const Standard_Real U, const Standard_Real V, const gp_Torus& T, gp_Pnt& P, gp_Vec& Vu, gp_Vec& Vv);
119
120
121 //! For elementary surfaces from the gp package (cones,
122 //! cylinders, spheres and tori), computes:
123 //! - the point P of parameters (U, V), and
124 //! - the first derivative vectors Vu and Vv at this point in
125 //! the u and v parametric directions respectively, and
126 //! - the second derivative vectors Vuu, Vvv and Vuv at this point.
0f57ab75 127 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);
42cf5bc1 128
129 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);
130
131 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);
132
133 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);
134
135
136 //! For elementary surfaces from the gp package (cones,
137 //! cylinders, spheres and tori), computes:
138 //! - the point P of parameters (U,V), and
139 //! - the first derivative vectors Vu and Vv at this point in
140 //! the u and v parametric directions respectively, and
141 //! - the second derivative vectors Vuu, Vvv and Vuv at
142 //! this point, and
143 //! - the third derivative vectors Vuuu, Vvvv, Vuuv and
144 //! Vuvv at this point.
0f57ab75 145 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);
42cf5bc1 146
147 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);
148
149 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);
150
151 //! Surface evaluation
152 //! The following functions compute the point and the
153 //! derivatives on elementary surfaces defined with their
54adc5e9 154 //! geometric characteristics.
42cf5bc1 155 //! You don't need to create the surface to use these functions.
156 //! These functions are called by the previous ones.
157 //! Example :
158 //! A cylinder is defined with its position and its radius.
159 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);
160
161 Standard_EXPORT static gp_Pnt PlaneValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos);
162
163 Standard_EXPORT static gp_Pnt CylinderValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius);
164
165 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);
166
167 Standard_EXPORT static gp_Pnt SphereValue (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius);
168
169 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);
170
171 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);
172
173 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);
174
175 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);
176
177 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);
178
179 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);
180
181 Standard_EXPORT static void PlaneD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, gp_Pnt& P);
182
183 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);
184
185 Standard_EXPORT static void CylinderD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real Radius, gp_Pnt& P);
186
187 Standard_EXPORT static void SphereD0 (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 TorusD0 (const Standard_Real U, const Standard_Real V, const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, gp_Pnt& P);
190
191 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);
192
193 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);
194
195 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);
196
197 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);
198
199 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);
200
201 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);
202
203 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);
204
205 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);
206
207 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);
208
209 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);
210
211 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);
212
213 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);
214
215
216 //! The following functions compute the parametric values
217 //! corresponding to a given point on a elementary surface.
218 //! The point should be on the surface.
219 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);
220
221 //! parametrization
222 //! P (U, V) =
223 //! Pl.Location() + U * Pl.XDirection() + V * Pl.YDirection()
224 static void Parameters (const gp_Pln& Pl, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
225
226 //! parametrization
227 //! P (U, V) = Location + V * ZDirection +
228 //! Radius * (Cos(U) * XDirection + Sin (U) * YDirection)
229 static void Parameters (const gp_Cylinder& C, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
230
231 //! parametrization
232 //! P (U, V) = Location + V * ZDirection +
233 //! (Radius + V * Tan (SemiAngle)) *
234 //! (Cos(U) * XDirection + Sin(U) * YDirection)
235 static void Parameters (const gp_Cone& C, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
236
237 //! parametrization
238 //! P (U, V) = Location +
239 //! Radius * Cos (V) * (Cos (U) * XDirection + Sin (U) * YDirection) +
240 //! Radius * Sin (V) * ZDirection
241 static void Parameters (const gp_Sphere& S, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
242
243 //! parametrization
244 //! P (U, V) = Location +
245 //! (MajorRadius + MinorRadius * Cos(U)) *
246 //! (Cos(V) * XDirection - Sin(V) * YDirection) +
247 //! MinorRadius * Sin(U) * ZDirection
248 static void Parameters (const gp_Torus& T, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
249
250 //! parametrization
251 //! P (U, V) =
252 //! Pl.Location() + U * Pl.XDirection() + V * Pl.YDirection()
253 Standard_EXPORT static void PlaneParameters (const gp_Ax3& Pos, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
254
255 //! parametrization
256 //! P (U, V) = Location + V * ZDirection +
257 //! Radius * (Cos(U) * XDirection + Sin (U) * YDirection)
258 Standard_EXPORT static void CylinderParameters (const gp_Ax3& Pos, const Standard_Real Radius, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
259
260 //! parametrization
261 //! P (U, V) = Location + V * ZDirection +
262 //! (Radius + V * Tan (SemiAngle)) *
263 //! (Cos(U) * XDirection + Sin(U) * YDirection)
264 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);
265
266 //! parametrization
267 //! P (U, V) = Location +
268 //! Radius * Cos (V) * (Cos (U) * XDirection + Sin (U) * YDirection) +
269 //! Radius * Sin (V) * ZDirection
270 Standard_EXPORT static void SphereParameters (const gp_Ax3& Pos, const Standard_Real Radius, const gp_Pnt& P, Standard_Real& U, Standard_Real& V);
271
272 //! parametrization
273 //! P (U, V) = Location +
274 //! (MajorRadius + MinorRadius * Cos(U)) *
275 //! (Cos(V) * XDirection - Sin(V) * YDirection) +
276 //! MinorRadius * Sin(U) * ZDirection
277 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);
278
279 //! compute the U Isoparametric gp_Lin of the plane.
280 Standard_EXPORT static gp_Lin PlaneUIso (const gp_Ax3& Pos, const Standard_Real U);
281
282 //! compute the U Isoparametric gp_Lin of the cylinder.
283 Standard_EXPORT static gp_Lin CylinderUIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real U);
284
285 //! compute the U Isoparametric gp_Lin of the cone.
286 Standard_EXPORT static gp_Lin ConeUIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, const Standard_Real U);
287
288 //! compute the U Isoparametric gp_Circ of the sphere,
289 //! (the meridian is not trimmed).
290 Standard_EXPORT static gp_Circ SphereUIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real U);
291
292 //! compute the U Isoparametric gp_Circ of the torus.
293 Standard_EXPORT static gp_Circ TorusUIso (const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Real U);
294
295 //! compute the V Isoparametric gp_Lin of the plane.
296 Standard_EXPORT static gp_Lin PlaneVIso (const gp_Ax3& Pos, const Standard_Real V);
297
298 //! compute the V Isoparametric gp_Circ of the cylinder.
299 Standard_EXPORT static gp_Circ CylinderVIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real V);
300
301 //! compute the V Isoparametric gp_Circ of the cone.
302 Standard_EXPORT static gp_Circ ConeVIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real SAngle, const Standard_Real V);
303
304 //! compute the V Isoparametric gp_Circ of the sphere,
305 //! (the meridian is not trimmed).
306 Standard_EXPORT static gp_Circ SphereVIso (const gp_Ax3& Pos, const Standard_Real Radius, const Standard_Real V);
307
308 //! compute the V Isoparametric gp_Circ of the torus.
309 Standard_EXPORT static gp_Circ TorusVIso (const gp_Ax3& Pos, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Real V);
310
311
312
313
314protected:
315
316
317
318
319
320private:
321
322
323
324
325
326};
327
328
329#include <ElSLib.lxx>
330
331
332
333
334
335#endif // _ElSLib_HeaderFile