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
|
// File: GeomProjLib.cxx
// Created: Wed Sep 21 10:38:50 1994
// Author: Bruno DUMORTIER
// <dub@fuegox>
// Modified by skv - Wed Aug 11 17:26:03 2004 OCC6272
#include <stdio.h>
#include <GeomProjLib.ixx>
#include <ProjLib_ProjectedCurve.hxx>
#include <ProjLib_CompProjectedCurve.hxx>
#include <ProjLib_ProjectOnPlane.hxx>
#include <ProjLib_ProjectOnSurface.hxx>
#include <Approx_CurveOnSurface.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <GeomAdaptor_HSurface.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_Parabola.hxx>
#include <Geom_Hyperbola.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <gp_Pln.hxx>
#include <Precision.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#ifdef DRAW
#include <DrawTrSurf.hxx>
static Standard_Boolean Affich = Standard_False;
static Standard_Integer NBPROJ = 1;
#endif
//=======================================================================
//function : Curve2d
//purpose :
//=======================================================================
Handle(Geom2d_Curve) GeomProjLib::Curve2d(const Handle(Geom_Curve)& C,
const Standard_Real First,
const Standard_Real Last,
const Handle(Geom_Surface)& S,
const Standard_Real UDeb,
const Standard_Real UFin,
const Standard_Real VDeb,
const Standard_Real VFin,
Standard_Real& Tolerance)
{
#ifdef DRAW
if ( Affich) {
//POP pour NT
// char name[100];
char* name = new char[100];
sprintf(name,"PROJCURV_%d",NBPROJ);
DrawTrSurf::Set(name,C);
sprintf(name,"PROJSURF_%d",NBPROJ);
DrawTrSurf::Set(name,S);
NBPROJ++;
}
#endif
Tolerance = Max(Precision::PConfusion(),Tolerance);
GeomAdaptor_Curve AC(C,First,Last);
GeomAdaptor_Surface AS(S,
UDeb,
UFin,
VDeb,
VFin);
Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface(AS);
Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(AC);
ProjLib_ProjectedCurve Proj(HS,HC,Tolerance);
Handle(Geom2d_Curve) G2dC;
switch ( Proj.GetType()) {
case GeomAbs_Line:
G2dC = new Geom2d_Line(Proj.Line());
break;
case GeomAbs_Circle:
G2dC = new Geom2d_Circle(Proj.Circle());
break;
case GeomAbs_Ellipse:
G2dC = new Geom2d_Ellipse(Proj.Ellipse());
break;
case GeomAbs_Parabola:
G2dC = new Geom2d_Parabola(Proj.Parabola());
break;
case GeomAbs_Hyperbola:
G2dC = new Geom2d_Hyperbola(Proj.Hyperbola());
break;
case GeomAbs_BezierCurve:
G2dC = Proj.Bezier();
break;
case GeomAbs_BSplineCurve:
G2dC = Proj.BSpline();
break;
default:
return G2dC;
}
if(G2dC.IsNull()) {
Tolerance = Proj.GetTolerance();
return G2dC;
}
if ( C->IsKind(STANDARD_TYPE(Geom_TrimmedCurve)) ) {
Handle(Geom_TrimmedCurve) CTrim = Handle(Geom_TrimmedCurve)::DownCast(C);
Standard_Real U1 = CTrim->FirstParameter();
Standard_Real U2 = CTrim->LastParameter();
G2dC = new Geom2d_TrimmedCurve( G2dC, U1, U2);
}
#ifdef DRAW
if ( Affich) {
static Standard_CString aprojcurv = "projcurv" ;
DrawTrSurf::Set(aprojcurv,G2dC);
}
#endif
Tolerance = Proj.GetTolerance();
return G2dC;
}
//=======================================================================
//function : Curve2d
//purpose :
//=======================================================================
Handle(Geom2d_Curve) GeomProjLib::Curve2d(const Handle(Geom_Curve)& C,
const Standard_Real First,
const Standard_Real Last,
const Handle(Geom_Surface)& S,
Standard_Real& Tolerance)
{
Standard_Real UFirst,
ULast,
VFirst,
VLast ;
S->Bounds(UFirst,
ULast,
VFirst,
VLast) ;
return Curve2d(C,
First,
Last,
S,
UFirst,
ULast,
VFirst,
VLast,
Tolerance) ;
}
// Modified by skv - Wed Aug 11 17:26:03 2004 OCC6272 Begin
// Add not implemented method.
//=======================================================================
//function : Curve2d
//purpose :
//=======================================================================
Handle(Geom2d_Curve) GeomProjLib::Curve2d( const Handle(Geom_Curve)& C,
const Handle(Geom_Surface)& S,
const Standard_Real UDeb,
const Standard_Real UFin,
const Standard_Real VDeb,
const Standard_Real VFin)
{
Standard_Real First = C->FirstParameter();
Standard_Real Last = C->LastParameter();
Standard_Real Tol = Precision::PConfusion();
return GeomProjLib::Curve2d(C,First,Last,S,UDeb,UFin,VDeb,VFin,Tol);
}
// Modified by skv - Wed Aug 11 17:26:03 2004 OCC6272 End
//=======================================================================
//function : Curve2d
//purpose :
//=======================================================================
Handle(Geom2d_Curve) GeomProjLib::Curve2d( const Handle(Geom_Curve)& C,
const Handle(Geom_Surface)& S,
const Standard_Real UDeb,
const Standard_Real UFin,
const Standard_Real VDeb,
const Standard_Real VFin,
Standard_Real& Tolerance)
{
Standard_Real First = C->FirstParameter();
Standard_Real Last = C->LastParameter();
return GeomProjLib::Curve2d(C,First,Last,S,UDeb,UFin,VDeb,VFin,Tolerance);
}
//=======================================================================
//function : Curve2d
//purpose :
//=======================================================================
Handle(Geom2d_Curve) GeomProjLib::Curve2d( const Handle(Geom_Curve)& C,
const Handle(Geom_Surface)& S)
{
Standard_Real First = C->FirstParameter();
Standard_Real Last = C->LastParameter();
Standard_Real Tol = Precision::PConfusion();
return GeomProjLib::Curve2d(C,First,Last,S,Tol);
}
//=======================================================================
//function : Curve2d
//purpose :
//=======================================================================
Handle(Geom2d_Curve) GeomProjLib::Curve2d( const Handle(Geom_Curve)& C,
const Standard_Real First,
const Standard_Real Last,
const Handle(Geom_Surface)& S)
{
Standard_Real Tol = Precision::PConfusion();
return GeomProjLib::Curve2d(C,First,Last,S,Tol);
}
//=======================================================================
//function : Project
//purpose :
//=======================================================================
Handle(Geom_Curve) GeomProjLib::Project( const Handle(Geom_Curve)& C,
const Handle(Geom_Surface)& S)
{
GeomAdaptor_Curve AC(C);
GeomAdaptor_Surface AS(S);
Handle(Geom_Curve) GC;
if ( AS.GetType() == GeomAbs_Plane) {
ProjLib_ProjectOnPlane Proj( AS.Plane().Position());
Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(AC);
Proj.Load(HC,Precision::PApproximation());
switch ( Proj.GetType()) {
case GeomAbs_Line:
GC = new Geom_Line(Proj.Line());
break;
case GeomAbs_Circle:
GC = new Geom_Circle(Proj.Circle());
break;
case GeomAbs_Ellipse:
GC = new Geom_Ellipse(Proj.Ellipse());
break;
case GeomAbs_Parabola:
GC = new Geom_Parabola(Proj.Parabola());
break;
case GeomAbs_Hyperbola:
GC = new Geom_Hyperbola(Proj.Hyperbola());
break;
case GeomAbs_BezierCurve:
GC = Proj.Bezier();
break;
case GeomAbs_BSplineCurve:
GC = Proj.BSpline();
break;
default:
return GC;
}
if ( C->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) CTrim = Handle(Geom_TrimmedCurve)::DownCast(C);
Standard_Real U1 = CTrim->FirstParameter();
Standard_Real U2 = CTrim->LastParameter();
GC = new Geom_TrimmedCurve( GC, U1, U2);
}
}
else {
Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface(AS);
Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(AC);
// Standard_Real Tol = Precision::Approximation();
// Standard_Real TolU = Precision::PApproximation();
// Standard_Real TolV = Precision::PApproximation();
Standard_Real Tol = 0.0001;
Standard_Real TolU = Pow(Tol, 2./3);
Standard_Real TolV = Pow(Tol, 2./3);
ProjLib_CompProjectedCurve Proj(HS,HC,TolU,TolV,-1.);
Standard_Real f,l;
Proj.Bounds(1,f,l);
Handle(Adaptor2d_HCurve2d) HC2d = Proj.Trim(f,l,TolU);
Approx_CurveOnSurface Approx(HC2d, HS, f, l, Tol,
GeomAbs_C2,14,16,Standard_True);
// ici, on a toujours un type BSpline.
if (Approx.IsDone() && Approx.HasResult())
GC = Approx.Curve3d();
}
return GC;
}
//=======================================================================
//function : ProjectOnPlane
//purpose :
//=======================================================================
Handle(Geom_Curve) GeomProjLib::ProjectOnPlane
(const Handle(Geom_Curve)& Curve,
const Handle(Geom_Plane)& Plane,
const gp_Dir& Dir,
const Standard_Boolean KeepParametrization)
{
GeomAdaptor_Curve AC(Curve);
Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(AC);
ProjLib_ProjectOnPlane Proj(Plane->Position(), Dir);
Proj.Load(HC,Precision::Approximation(), KeepParametrization);
Handle(Geom_Curve) GC;
switch ( Proj.GetType()) {
case GeomAbs_Line:
GC = new Geom_Line(Proj.Line());
break;
case GeomAbs_Circle:
GC = new Geom_Circle(Proj.Circle());
break;
case GeomAbs_Ellipse:
GC = new Geom_Ellipse(Proj.Ellipse());
break;
case GeomAbs_Parabola:
GC = new Geom_Parabola(Proj.Parabola());
break;
case GeomAbs_Hyperbola:
GC = new Geom_Hyperbola(Proj.Hyperbola());
break;
case GeomAbs_BezierCurve:
GC = Proj.Bezier();
break;
case GeomAbs_BSplineCurve:
GC = Proj.BSpline();
break;
default:
return GC;
}
if ( Curve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve)) ) {
Handle(Geom_TrimmedCurve) CTrim
= Handle(Geom_TrimmedCurve)::DownCast(Curve);
GC = new Geom_TrimmedCurve( GC, Proj.FirstParameter(),
Proj.LastParameter());
}
return GC;
}
|