0031939: Coding - correction of spelling errors in comments [part 3]
[occt.git] / src / Geom / Geom_SurfaceOfRevolution.cxx
CommitLineData
b311480e 1// Created on: 1993-03-10
2// Created by: JCV
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
7fd59977 18#include <BSplCLib.hxx>
42cf5bc1 19#include <BSplSLib.hxx>
20#include <Geom_BSplineCurve.hxx>
7fd59977 21#include <Geom_Circle.hxx>
42cf5bc1 22#include <Geom_Curve.hxx>
23#include <Geom_Geometry.hxx>
24#include <Geom_SurfaceOfRevolution.hxx>
25#include <Geom_UndefinedDerivative.hxx>
6b84c3f7 26#include <GeomEvaluator_SurfaceOfRevolution.hxx>
7fd59977 27#include <gp.hxx>
42cf5bc1 28#include <gp_Ax1.hxx>
29#include <gp_Ax2.hxx>
7fd59977 30#include <gp_Ax2d.hxx>
7fd59977 31#include <gp_Dir.hxx>
42cf5bc1 32#include <gp_GTrsf2d.hxx>
33#include <gp_Lin.hxx>
7fd59977 34#include <gp_Pnt.hxx>
42cf5bc1 35#include <gp_Trsf.hxx>
36#include <gp_Vec.hxx>
37#include <gp_XYZ.hxx>
38#include <Precision.hxx>
7fd59977 39#include <Standard_ConstructionError.hxx>
40#include <Standard_NotImplemented.hxx>
41#include <Standard_RangeError.hxx>
42cf5bc1 42#include <Standard_Type.hxx>
43
92efcf78 44IMPLEMENT_STANDARD_RTTIEXT(Geom_SurfaceOfRevolution,Geom_SweptSurface)
45
7fd59977 46#define POLES (poles->Array2())
47#define WEIGHTS (weights->Array2())
48#define UKNOTS (uknots->Array1())
49#define VKNOTS (vknots->Array1())
50#define UFKNOTS (ufknots->Array1())
51#define VFKNOTS (vfknots->Array1())
52#define FMULTS (BSplCLib::NoMults())
53
54typedef Geom_SurfaceOfRevolution SurfaceOfRevolution;
7fd59977 55typedef Geom_Curve Curve;
7fd59977 56typedef gp_Ax1 Ax1;
57typedef gp_Ax2 Ax2;
58typedef gp_Dir Dir;
59typedef gp_Lin Lin;
60typedef gp_Pnt Pnt;
61typedef gp_Trsf Trsf;
62typedef gp_Vec Vec;
63typedef gp_XYZ XYZ;
c04c30b3 64
7fd59977 65
66
67
68
69//=======================================================================
70//function : Copy
71//purpose :
72//=======================================================================
73
74Handle(Geom_Geometry) Geom_SurfaceOfRevolution::Copy () const {
75
76 return new Geom_SurfaceOfRevolution (basisCurve, Axis());
77}
78
79
80//=======================================================================
81//function : Geom_SurfaceOfRevolution
82//purpose :
83//=======================================================================
84
85Geom_SurfaceOfRevolution::Geom_SurfaceOfRevolution
c04c30b3 86 (const Handle(Geom_Curve)& C ,
7fd59977 87 const Ax1& A1 ) : loc (A1.Location()) {
88
7fd59977 89 direction = A1.Direction();
6b84c3f7 90 SetBasisCurve(C);
7fd59977 91}
92
93
94//=======================================================================
95//function : UReverse
96//purpose :
97//=======================================================================
98
99void Geom_SurfaceOfRevolution::UReverse () {
100
6b84c3f7 101 direction.Reverse();
102 myEvaluator->SetDirection(direction);
7fd59977 103}
104
105
106//=======================================================================
107//function : UReversedParameter
108//purpose :
109//=======================================================================
110
111Standard_Real Geom_SurfaceOfRevolution::UReversedParameter (const Standard_Real U) const {
112
c6541a0c 113 return ( 2.*M_PI - U);
7fd59977 114}
115
116
117//=======================================================================
118//function : VReverse
119//purpose :
120//=======================================================================
121
122void Geom_SurfaceOfRevolution::VReverse () {
123
124 basisCurve->Reverse();
125}
126
127
128//=======================================================================
129//function : VReversedParameter
130//purpose :
131//=======================================================================
132
133Standard_Real Geom_SurfaceOfRevolution::VReversedParameter (const Standard_Real V) const {
134
135 return basisCurve->ReversedParameter(V);
136}
137
138
139//=======================================================================
140//function : Location
141//purpose :
142//=======================================================================
143
144const gp_Pnt& Geom_SurfaceOfRevolution::Location () const {
145
146 return loc;
147}
148
149//=======================================================================
150//function : IsUPeriodic
151//purpose :
152//=======================================================================
153
154Standard_Boolean Geom_SurfaceOfRevolution::IsUPeriodic () const {
155
156 return Standard_True;
157}
158
159//=======================================================================
160//function : IsCNu
161//purpose :
162//=======================================================================
163
164Standard_Boolean Geom_SurfaceOfRevolution::IsCNu (const Standard_Integer ) const {
165
166 return Standard_True;
167}
168
169//=======================================================================
170//function : Axis
171//purpose :
172//=======================================================================
173
174Ax1 Geom_SurfaceOfRevolution::Axis () const {
175
176 return Ax1 (loc, direction);
177}
178
179//=======================================================================
180//function : IsCNv
181//purpose :
182//=======================================================================
183
184Standard_Boolean Geom_SurfaceOfRevolution::IsCNv (const Standard_Integer N) const {
185
186 Standard_RangeError_Raise_if (N < 0, " ");
187 return basisCurve->IsCN(N);
188}
189
190
191//=======================================================================
192//function : IsUClosed
193//purpose :
194//=======================================================================
195
196Standard_Boolean Geom_SurfaceOfRevolution::IsUClosed () const {
197
198 return Standard_True;
199}
200
201//=======================================================================
202//function : IsVClosed
203//purpose :
204//=======================================================================
205
206Standard_Boolean Geom_SurfaceOfRevolution::IsVClosed () const
207{
208 return basisCurve->IsClosed();
209}
210
211
212//=======================================================================
213//function : IsVPeriodic
214//purpose :
215//=======================================================================
216
217Standard_Boolean Geom_SurfaceOfRevolution::IsVPeriodic () const {
218
219 return basisCurve->IsPeriodic();
220}
221
222
223//=======================================================================
224//function : SetAxis
225//purpose :
226//=======================================================================
227
228void Geom_SurfaceOfRevolution::SetAxis (const Ax1& A1) {
229
230 direction = A1.Direction();
231 loc = A1.Location();
6b84c3f7 232 myEvaluator->SetAxis(A1);
7fd59977 233}
234
235
236//=======================================================================
237//function : SetDirection
238//purpose :
239//=======================================================================
240
241void Geom_SurfaceOfRevolution::SetDirection (const Dir& V) {
242
243 direction = V;
6b84c3f7 244 myEvaluator->SetDirection(direction);
7fd59977 245}
246
247
248//=======================================================================
249//function : SetBasisCurve
250//purpose :
251//=======================================================================
252
c04c30b3 253void Geom_SurfaceOfRevolution::SetBasisCurve (const Handle(Geom_Curve)& C) {
7fd59977 254
c04c30b3 255 basisCurve = Handle(Geom_Curve)::DownCast(C->Copy());
7fd59977 256 smooth = C->Continuity();
6b84c3f7 257 myEvaluator = new GeomEvaluator_SurfaceOfRevolution(basisCurve, direction, loc);
7fd59977 258}
259
260
261//=======================================================================
262//function : SetLocation
263//purpose :
264//=======================================================================
265
266void Geom_SurfaceOfRevolution::SetLocation (const Pnt& P) {
267
268 loc = P;
6b84c3f7 269 myEvaluator->SetLocation(loc);
7fd59977 270}
271
272
273//=======================================================================
274//function : Bounds
275//purpose :
276//=======================================================================
277
278void Geom_SurfaceOfRevolution::Bounds ( Standard_Real& U1,
279 Standard_Real& U2,
280 Standard_Real& V1,
281 Standard_Real& V2 ) const {
282
283 U1 = 0.0;
c6541a0c 284 U2 = 2.0 * M_PI;
7fd59977 285 V1 = basisCurve->FirstParameter();
286 V2 = basisCurve->LastParameter();
287}
288
289
290//=======================================================================
291//function : D0
292//purpose :
293//=======================================================================
294
6b84c3f7 295void Geom_SurfaceOfRevolution::D0
296(const Standard_Real U, const Standard_Real V, Pnt& P) const
297{
298 myEvaluator->D0(U, V, P);
7fd59977 299}
300
301
302//=======================================================================
303//function : D1
304//purpose :
305//=======================================================================
306
307void Geom_SurfaceOfRevolution::D1
308 (const Standard_Real U, const Standard_Real V,
309 Pnt& P,
6b84c3f7 310 Vec& D1U, Vec& D1V ) const
311{
312 myEvaluator->D1(U, V, P, D1U, D1V);
313}
7fd59977 314
315//=======================================================================
316//function : D2
317//purpose :
318//=======================================================================
319
320void Geom_SurfaceOfRevolution::D2
321 (const Standard_Real U, const Standard_Real V,
322 Pnt& P,
323 Vec& D1U, Vec& D1V,
6b84c3f7 324 Vec& D2U, Vec& D2V, Vec& D2UV ) const
325{
326 myEvaluator->D2(U, V, P, D1U, D1V, D2U, D2V, D2UV);
7fd59977 327}
328
329
330
331//=======================================================================
332//function : D3
333//purpose :
334//=======================================================================
335
336void Geom_SurfaceOfRevolution::D3
337 (const Standard_Real U, const Standard_Real V,
338 Pnt& P,
339 Vec& D1U, Vec& D1V,
340 Vec& D2U, Vec& D2V, Vec& D2UV,
6b84c3f7 341 Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV ) const
342{
343 myEvaluator->D3(U, V, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV);
7fd59977 344}
345
346
347//=======================================================================
348//function : DN
349//purpose :
350//=======================================================================
351
352Vec Geom_SurfaceOfRevolution::DN (const Standard_Real U , const Standard_Real V,
6b84c3f7 353 const Standard_Integer Nu, const Standard_Integer Nv) const
7fd59977 354{
6b84c3f7 355 return myEvaluator->DN(U, V, Nu, Nv);
7fd59977 356}
7fd59977 357
7fd59977 358
359//=======================================================================
360//function : ReferencePlane
361//purpose :
362//=======================================================================
363
364Ax2 Geom_SurfaceOfRevolution::ReferencePlane() const {
365
9775fa61 366 throw Standard_NotImplemented();
7fd59977 367}
368
369
370//=======================================================================
371//function : UIso
372//purpose :
373//=======================================================================
374
c04c30b3 375Handle(Geom_Curve) Geom_SurfaceOfRevolution::UIso (const Standard_Real U) const {
7fd59977 376
c04c30b3 377 Handle(Geom_Curve) C = Handle(Geom_Curve)::DownCast(basisCurve->Copy());
7fd59977 378 Ax1 RotAxis = Ax1 (loc, direction);
379 C->Rotate (RotAxis, U);
380 return C;
381}
382
383
384//=======================================================================
385//function : VIso
386//purpose :
387//=======================================================================
388
389Handle(Geom_Curve) Geom_SurfaceOfRevolution::VIso (const Standard_Real V) const {
390
391 Handle(Geom_Circle) Circ;
392 Pnt Pc = basisCurve->Value (V);
393 gp_Lin L1(loc,direction);
394 Standard_Real Rad= L1.Distance(Pc);
395
396 Ax2 Rep ;
397 if ( Rad > gp::Resolution()) {
398 XYZ P = Pc.XYZ();
399 XYZ C;
400 C.SetLinearForm((P-loc.XYZ()).Dot(direction.XYZ()),
401 direction.XYZ(), loc.XYZ() );
402 P = P-C;
403 if(P.Modulus() > gp::Resolution()) {
404 gp_Dir D = P.Normalized();
405 Rep = gp_Ax2(C, direction, D);
406 }
407 else
408 Rep = gp_Ax2(C, direction);
409 }
410 else
411 Rep = gp_Ax2(Pc, direction);
412
413 Circ = new Geom_Circle (Rep, Rad);
414 return Circ;
415}
416
417
418//=======================================================================
419//function : Transform
420//purpose :
421//=======================================================================
422
423void Geom_SurfaceOfRevolution::Transform (const Trsf& T) {
424
425 loc.Transform (T);
426 direction.Transform (T);
427 basisCurve->Transform (T);
428 if(T.ScaleFactor()*T.HVectorialPart().Determinant() < 0.) UReverse();
6b84c3f7 429 myEvaluator->SetDirection(direction);
430 myEvaluator->SetLocation(loc);
7fd59977 431}
432
433//=======================================================================
434//function : TransformParameters
435//purpose :
436//=======================================================================
437
438void Geom_SurfaceOfRevolution::TransformParameters(Standard_Real& ,
439 Standard_Real& V,
440 const gp_Trsf& T)
441const
442{
443 V = basisCurve->TransformedParameter(V,T);
444}
445
446//=======================================================================
447//function : ParametricTransformation
448//purpose :
449//=======================================================================
450
451gp_GTrsf2d Geom_SurfaceOfRevolution::ParametricTransformation
452(const gp_Trsf& T) const
453{
454 gp_GTrsf2d T2;
455 gp_Ax2d Axis(gp::Origin2d(),gp::DX2d());
456 T2.SetAffinity(Axis, basisCurve->ParametricTransformation(T));
457 return T2;
458}
459
bc73b006 460//=======================================================================
461//function : DumpJson
462//purpose :
463//=======================================================================
464void Geom_SurfaceOfRevolution::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
465{
466 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
467 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Geom_SweptSurface)
468
469 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &loc)
470}