summaryrefslogtreecommitdiff
path: root/src/Geom/Geom_ConicalSurface.cxx
blob: 71959c2cfa6f8487b8d96d9d5e2e18992f022387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
// File:	Geom_ConicalSurface.cxx
// Created:	Wed Mar 10 09:33:39 1993
// Author:	JCV
//		<fid@phylox>
// Copyright:	Matra Datavision 1993

//File Geom_ConicalSurface.cxx, JCV 17/01/91


#include <Geom_ConicalSurface.ixx>

#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>

#include <Precision.hxx>
#include <gp.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
#include <gp_Ax2d.hxx>
#include <gp_XYZ.hxx>
#include <gp_Dir.hxx>
#include <ElSLib.hxx>
#include <GeomAbs_UVSense.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>

typedef Geom_ConicalSurface         ConicalSurface;
typedef Handle(Geom_ConicalSurface) Handle(ConicalSurface);
typedef gp_Ax1  Ax1;
typedef gp_Ax2  Ax2;
typedef gp_Ax3  Ax3;
typedef gp_Circ Circ;
typedef gp_Dir  Dir;
typedef gp_Lin  Lin;
typedef gp_Pnt  Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec  Vec;
typedef gp_XYZ  XYZ;




//=======================================================================
//function : Copy
//purpose  : 
//=======================================================================

Handle(Geom_Geometry) Geom_ConicalSurface::Copy () const {
 
   Handle(ConicalSurface) Cs;
   Cs = new ConicalSurface (pos, semiAngle, radius);
   return Cs;
}

//=======================================================================
//function : Geom_ConicalSurface
//purpose  : 
//=======================================================================

Geom_ConicalSurface::Geom_ConicalSurface ( const Ax3& A3 , 
					   const Standard_Real Ang, 
					   const Standard_Real R) :
       radius(R), semiAngle (Ang) 
{

  if (R < 0.0 || Abs(Ang) <= gp::Resolution() || Abs(Ang) >= PI/2.0 - gp::Resolution()) 
    Standard_ConstructionError::Raise();
  
  pos = A3;
}


//=======================================================================
//function : Geom_ConicalSurface
//purpose  : 
//=======================================================================

Geom_ConicalSurface::Geom_ConicalSurface ( const gp_Cone& C ) 
: radius (C.RefRadius()), semiAngle (C.SemiAngle()) 
{
   pos = C.Position();
}


//=======================================================================
//function : UReversedParameter
//purpose  : 
//=======================================================================

Standard_Real Geom_ConicalSurface::UReversedParameter( const Standard_Real U) const
{
  return ( 2.*PI - U);
}


//=======================================================================
//function : VReversedParameter
//purpose  : 
//=======================================================================

Standard_Real Geom_ConicalSurface::VReversedParameter( const Standard_Real V) const
{
  return ( -V);
}

//=======================================================================
//function : VReverse
//purpose  : 
//=======================================================================

void Geom_ConicalSurface::VReverse()
{
  semiAngle = -semiAngle;
  pos.ZReverse();
}

//=======================================================================
//function : RefRadius
//purpose  : 
//=======================================================================

Standard_Real Geom_ConicalSurface::RefRadius () const               
{ return radius; }

//=======================================================================
//function : SemiAngle
//purpose  : 
//=======================================================================

Standard_Real Geom_ConicalSurface::SemiAngle () const               
{ return semiAngle;}

//=======================================================================
//function : IsUClosed
//purpose  : 
//=======================================================================

Standard_Boolean Geom_ConicalSurface::IsUClosed () const            
{ return Standard_True; }

//=======================================================================
//function : IsVClosed
//purpose  : 
//=======================================================================

Standard_Boolean Geom_ConicalSurface::IsVClosed () const            
{ return Standard_False; }

//=======================================================================
//function : IsUPeriodic
//purpose  : 
//=======================================================================

Standard_Boolean Geom_ConicalSurface::IsUPeriodic () const          
{ return Standard_True; }

//=======================================================================
//function : IsVPeriodic
//purpose  : 
//=======================================================================

Standard_Boolean Geom_ConicalSurface::IsVPeriodic () const          
{ return Standard_False; }

//=======================================================================
//function : Cone
//purpose  : 
//=======================================================================

gp_Cone Geom_ConicalSurface::Cone () const {

  return gp_Cone (pos, semiAngle, radius);
}


//=======================================================================
//function : SetCone
//purpose  : 
//=======================================================================

void Geom_ConicalSurface::SetCone (const gp_Cone& C) {

  radius = C.RefRadius ();
  semiAngle   = C.SemiAngle ();
  pos    = C.Position  ();
}


//=======================================================================
//function : SetRadius
//purpose  : 
//=======================================================================

void Geom_ConicalSurface::SetRadius (const Standard_Real R) {

  if (R < 0.0)  Standard_ConstructionError::Raise();
  radius = R;
}


//=======================================================================
//function : SetSemiAngle
//purpose  : 
//=======================================================================

void Geom_ConicalSurface::SetSemiAngle (const Standard_Real Ang) {

  if (Abs(Ang) <= gp::Resolution() || Abs(Ang) >= PI/2.0 - gp::Resolution()) {
    Standard_ConstructionError::Raise();
  }
  semiAngle = Ang;
}


//=======================================================================
//function : Apex
//purpose  : 
//=======================================================================

Pnt Geom_ConicalSurface::Apex () const 
{

   XYZ Coord = Position().Direction().XYZ();
   Coord.Multiply (-radius / Tan (semiAngle));
   Coord.Add      (Position().Location().XYZ());
   return Pnt     (Coord);
}


//=======================================================================
//function : Bounds
//purpose  : 
//=======================================================================

void Geom_ConicalSurface::Bounds (Standard_Real& U1, Standard_Real& U2, 
				  Standard_Real& V1, Standard_Real& V2) const {

   U1 = 0.0;  U2 = 2.0 * PI;  
   V1 = -Precision::Infinite();  V2 = Precision::Infinite();
}


//=======================================================================
//function : Coefficients
//purpose  : 
//=======================================================================

void Geom_ConicalSurface::Coefficients (Standard_Real& A1, Standard_Real& A2, Standard_Real& A3,
					Standard_Real& B1, Standard_Real& B2, Standard_Real& B3,
					Standard_Real& C1, Standard_Real& C2, Standard_Real& C3, 
					Standard_Real& D)  const 
{
   // Dans le repere du cone :
   // X**2 + Y**2 - (Myradius - Z * Tan(semiAngle))**2 = 0.0

      Trsf T;
      T.SetTransformation (pos);
      Standard_Real KAng = Tan (semiAngle);
      Standard_Real T11 = T.Value (1, 1);
      Standard_Real T12 = T.Value (1, 2);
      Standard_Real T13 = T.Value (1, 3);
      Standard_Real T14 = T.Value (1, 4);
      Standard_Real T21 = T.Value (2, 1);
      Standard_Real T22 = T.Value (2, 2);
      Standard_Real T23 = T.Value (2, 3);
      Standard_Real T24 = T.Value (2, 4);
      Standard_Real T31 = T.Value (3, 1) * KAng;
      Standard_Real T32 = T.Value (3, 2) * KAng;
      Standard_Real T33 = T.Value (3, 3) * KAng;
      Standard_Real T34 = T.Value (3, 4) * KAng;
      A1 = T11 * T11 + T21 * T21 - T31 * T31;
      A2 = T12 * T12 + T22 * T22 - T32 * T32;
      A3 = T13 * T13 + T23 * T23 - T33 * T33;
      B1 = T11 * T12 + T21 * T22 - T31 * T32;
      B2 = T11 * T13 + T21 * T23 - T31 * T33;
      B3 = T12 * T13 + T22 * T23 - T32 * T33;
      C1 = T11 * T14 + T21 * T24 + radius * T31;
      C2 = T12 * T14 + T22 * T24 + radius * T32;
      C3 = T13 * T14 + T23 * T24 + radius * T33;
      D = T14 * T14 + T24 * T24 - radius * radius - T34 * T34 +
          2.0 * radius * T34;  
}



//=======================================================================
//function : D0
//purpose  : 
//=======================================================================

void Geom_ConicalSurface::D0 (const Standard_Real U, const Standard_Real V, Pnt& P) const 
{

  P = ElSLib::ConeValue (U, V, pos, radius, semiAngle);
}


//=======================================================================
//function : D1
//purpose  : 
//=======================================================================

void Geom_ConicalSurface::D1 (const Standard_Real U  , const Standard_Real V, 
			            Pnt& P  , 
			            Vec& D1U, Vec& D1V     ) const 
{
  ElSLib::ConeD1 (U, V, pos, radius, semiAngle, P, D1U, D1V);
}


//=======================================================================
//function : D2
//purpose  : 
//=======================================================================

void Geom_ConicalSurface::D2 ( const Standard_Real U  , const Standard_Real V, 
                                     Pnt& P  ,  
			             Vec& D1U, Vec& D1V, 
			             Vec& D2U, Vec& D2V, Vec& D2UV) const 
{
  ElSLib::ConeD2 (U, V, pos, radius, semiAngle, P, D1U, D1V, 
		  D2U, D2V, D2UV);
}


//=======================================================================
//function : D3
//purpose  : 
//=======================================================================

void Geom_ConicalSurface::D3 (const Standard_Real U, const Standard_Real V, 
			      Pnt& P      , 
			      Vec& D1U    , Vec& D1V,
			      Vec& D2U    , Vec& D2V, Vec& D2UV,
			      Vec& D3U    , Vec& D3V, Vec& D3UUV, Vec& D3UVV
			      ) const
{
  ElSLib::ConeD3 (U, V, pos, radius, semiAngle, P, D1U, D1V, D2U, D2V,
		  D2UV, D3U, D3V, D3UUV, D3UVV);
}


//=======================================================================
//function : DN
//purpose  : 
//=======================================================================

Vec Geom_ConicalSurface::DN (const Standard_Real    U , const Standard_Real     V, 
			     const Standard_Integer Nu, const Standard_Integer Nv ) const
{
  Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv < 0, " ");
  if (Nv > 1) { return Vec (0.0, 0.0, 0.0); }
  else {
    return ElSLib::ConeDN (U, V, pos, radius, semiAngle, Nu, Nv);
  }
}


//=======================================================================
//function : UIso
//purpose  : 
//=======================================================================

Handle(Geom_Curve) Geom_ConicalSurface::UIso (const Standard_Real U) const 
{
  Handle(Geom_Line) 
    GL = new Geom_Line(ElSLib::ConeUIso(pos,radius,semiAngle,U));
  return GL;
}


//=======================================================================
//function : VIso
//purpose  : 
//=======================================================================

Handle(Geom_Curve) Geom_ConicalSurface::VIso (const Standard_Real V) const 
{
  Handle(Geom_Circle) 
    GC = new Geom_Circle(ElSLib::ConeVIso(pos,radius,semiAngle,V));
  return GC;
}


//=======================================================================
//function : Transform
//purpose  : 
//=======================================================================

void Geom_ConicalSurface::Transform (const Trsf& T) 
{
  radius = radius * Abs(T.ScaleFactor());
  pos.Transform (T);
}

//=======================================================================
//function : TransformParameters
//purpose  : 
//=======================================================================

void Geom_ConicalSurface::TransformParameters(Standard_Real& ,
					      Standard_Real& V,
					      const gp_Trsf& T) 
const
{
  if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor());
}

//=======================================================================
//function : ParametricTransformation
//purpose  : 
//=======================================================================

gp_GTrsf2d Geom_ConicalSurface::ParametricTransformation(const gp_Trsf& T)
const
{
  gp_GTrsf2d T2;
  gp_Ax2d Axis(gp::Origin2d(),gp::DX2d());
  T2.SetAffinity(Axis, Abs(T.ScaleFactor()));
  return T2;
}