7fd59977 |
1 | // File: GeomFill_SweepSectionGenerator.cxx |
2 | // Created: Mon Feb 28 14:14:53 1994 |
3 | // Author: Bruno DUMORTIER |
4 | // <dub@fuegox> |
5 | |
6 | #include <GeomFill_SweepSectionGenerator.ixx> |
7 | |
8 | #include <GeomFill_Profiler.hxx> |
9 | |
10 | #include <gp_Dir.hxx> |
11 | #include <gp_Vec.hxx> |
12 | #include <gp_Trsf.hxx> |
13 | #include <gp_Pnt.hxx> |
14 | #include <gp_Ax3.hxx> |
15 | #include <gp_Ax2.hxx> |
16 | #include <Geom_TrimmedCurve.hxx> |
17 | #include <Geom_Circle.hxx> |
18 | #include <GeomConvert.hxx> |
19 | #include <Precision.hxx> |
20 | #include <ElCLib.hxx> |
21 | #include <GeomAdaptor.hxx> |
22 | #include <GeomAdaptor_Curve.hxx> |
23 | #include <GCPnts_QuasiUniformDeflection.hxx> |
24 | #include <TColStd_Array1OfReal.hxx> |
25 | |
26 | #include <stdio.h> |
27 | |
28 | #ifdef DRAW |
29 | #include <DrawTrSurf.hxx> |
30 | #endif |
31 | #ifdef DEB |
32 | static Standard_Boolean Affich = Standard_False; |
33 | static Standard_Integer NbSECTIONS = 0; |
34 | #endif |
35 | |
36 | //======================================================================= |
37 | //function : GeomFill_SweepSectionGenerator |
38 | //purpose : |
39 | //======================================================================= |
40 | |
41 | GeomFill_SweepSectionGenerator::GeomFill_SweepSectionGenerator() |
42 | { |
43 | myIsDone = Standard_False; |
44 | } |
45 | |
46 | |
47 | //======================================================================= |
48 | //function : GeomFill_SweepSectionGenerator |
49 | //purpose : |
50 | //======================================================================= |
51 | |
52 | GeomFill_SweepSectionGenerator::GeomFill_SweepSectionGenerator |
53 | (const Handle(Geom_Curve)& Path, |
54 | const Standard_Real Radius) |
55 | { |
56 | Init(Path,Radius); |
57 | } |
58 | |
59 | |
60 | //======================================================================= |
61 | //function : GeomFill_SweepSectionGenerator |
62 | //purpose : |
63 | //======================================================================= |
64 | |
65 | GeomFill_SweepSectionGenerator::GeomFill_SweepSectionGenerator |
66 | (const Handle(Geom_Curve)& Path, |
67 | const Handle(Geom_Curve)& FirstSect) |
68 | { |
69 | Init(Path,FirstSect); |
70 | } |
71 | |
72 | |
73 | //======================================================================= |
74 | //function : GeomFill_SweepSectionGenerator |
75 | //purpose : |
76 | //======================================================================= |
77 | |
78 | GeomFill_SweepSectionGenerator::GeomFill_SweepSectionGenerator |
79 | (const Handle(Geom_Curve)& Path, |
80 | const Handle(Geom_Curve)& FirstSect, |
81 | const Handle(Geom_Curve)& LastSect ) |
82 | { |
83 | Init(Path,FirstSect,LastSect); |
84 | } |
85 | |
86 | |
87 | //======================================================================= |
88 | //function : GeomFill_SweepSectionGenerator |
89 | //purpose : |
90 | //======================================================================= |
91 | |
92 | GeomFill_SweepSectionGenerator::GeomFill_SweepSectionGenerator |
93 | (const Handle(Adaptor3d_HCurve)& Path, |
94 | const Handle(Adaptor3d_HCurve)& Curve1, |
95 | const Handle(Adaptor3d_HCurve)& Curve2, |
96 | const Standard_Real Radius) |
97 | { |
98 | Init(Path,Curve1,Curve2,Radius); |
99 | } |
100 | |
101 | |
102 | //======================================================================= |
103 | //function : Init |
104 | //purpose : |
105 | //======================================================================= |
106 | |
107 | void GeomFill_SweepSectionGenerator::Init(const Handle(Geom_Curve)& Path, |
108 | const Standard_Real Radius) |
109 | { |
110 | myIsDone = Standard_False; |
111 | myRadius = Radius; |
112 | GeomAdaptor_Curve ThePath(Path); |
113 | |
114 | if (ThePath.GetType() == GeomAbs_Circle) { |
115 | |
116 | myCircPathAxis = ThePath.Circle().Axis(); |
117 | myType = 4; |
118 | } |
119 | else myType = 1; |
120 | if ( Path->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { |
121 | myPath = Handle(Geom_BSplineCurve)::DownCast(Path->Copy()); |
122 | } |
123 | else { |
124 | myPath = GeomConvert::CurveToBSplineCurve(Path); |
125 | } |
126 | } |
127 | |
128 | |
129 | //======================================================================= |
130 | //function : Init |
131 | //purpose : |
132 | //======================================================================= |
133 | void GeomFill_SweepSectionGenerator::Init |
134 | (const Handle(Geom_Curve)& Path, |
135 | const Handle(Geom_Curve)& FirstSect) |
136 | { |
137 | myIsDone = Standard_False; |
138 | myRadius = 0; |
139 | GeomAdaptor_Curve ThePath(Path); |
140 | |
141 | if (ThePath.GetType() == GeomAbs_Circle) { |
142 | myCircPathAxis = ThePath.Circle().Axis(); |
143 | myType = 5; |
144 | } |
145 | |
146 | else myType = 2; |
147 | |
148 | if ( Path->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { |
149 | myPath = Handle(Geom_BSplineCurve)::DownCast(Path->Copy()); |
150 | } |
151 | else { |
152 | myPath = GeomConvert::CurveToBSplineCurve(Path); |
153 | } |
154 | if ( FirstSect->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { |
155 | myFirstSect = Handle(Geom_BSplineCurve)::DownCast(FirstSect->Copy()); |
156 | } |
157 | else { |
158 | // JAG |
159 | myFirstSect = GeomConvert::CurveToBSplineCurve(FirstSect, |
160 | Convert_QuasiAngular); |
161 | } |
162 | if ( myFirstSect->IsPeriodic()) myFirstSect->SetNotPeriodic(); |
163 | } |
164 | |
165 | |
166 | //======================================================================= |
167 | //function : Init |
168 | //purpose : |
169 | //======================================================================= |
170 | |
171 | void GeomFill_SweepSectionGenerator::Init |
172 | (const Handle(Geom_Curve)& Path, |
173 | const Handle(Geom_Curve)& FirstSect, |
174 | const Handle(Geom_Curve)& LastSect ) |
175 | { |
176 | myIsDone = Standard_False; |
177 | myRadius = 0; |
178 | GeomAdaptor_Curve ThePath(Path); |
179 | |
180 | if (ThePath.GetType() == GeomAbs_Circle) { |
181 | |
182 | myCircPathAxis = ThePath.Circle().Axis(); |
183 | myType = 6; |
184 | } |
185 | else myType = 3; |
186 | |
187 | if ( Path->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { |
188 | myPath = Handle(Geom_BSplineCurve)::DownCast(Path->Copy()); |
189 | } |
190 | else { |
191 | myPath = GeomConvert::CurveToBSplineCurve(Path); |
192 | } |
193 | |
194 | // JAG |
195 | if ( FirstSect->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { |
196 | myFirstSect = Handle(Geom_BSplineCurve)::DownCast(FirstSect->Copy()); |
197 | } |
198 | else { |
199 | myFirstSect = GeomConvert::CurveToBSplineCurve(FirstSect, |
200 | Convert_QuasiAngular); |
201 | } |
202 | if ( LastSect->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { |
203 | myLastSect = Handle(Geom_BSplineCurve)::DownCast(LastSect->Copy()); |
204 | } |
205 | else { |
206 | myLastSect = GeomConvert::CurveToBSplineCurve(LastSect, |
207 | Convert_QuasiAngular); |
208 | } |
209 | |
210 | if ( myFirstSect->IsPeriodic()) myFirstSect->SetNotPeriodic(); |
211 | if ( myLastSect->IsPeriodic()) myLastSect->SetNotPeriodic(); |
212 | |
213 | |
214 | // JAG |
215 | |
216 | GeomFill_Profiler Profil; |
217 | Profil.AddCurve(myFirstSect); |
218 | Profil.AddCurve(myLastSect); |
219 | Profil.Perform(Precision::Confusion()); |
220 | |
221 | myFirstSect = Handle(Geom_BSplineCurve)::DownCast(Profil.Curve(1)); |
222 | myLastSect = Handle(Geom_BSplineCurve)::DownCast(Profil.Curve(2)); |
223 | } |
224 | |
225 | |
226 | //======================================================================= |
227 | //function : Init |
228 | //purpose : |
229 | //======================================================================= |
230 | |
231 | void GeomFill_SweepSectionGenerator::Init |
232 | (const Handle(Adaptor3d_HCurve)& Path, |
233 | const Handle(Adaptor3d_HCurve)& Curve1, |
234 | const Handle(Adaptor3d_HCurve)& Curve2, |
235 | const Standard_Real Radius) |
236 | { |
237 | myIsDone = Standard_False; |
238 | myRadius = Radius; |
239 | myType = 0; |
240 | |
241 | Handle(Geom_Curve) CC = GeomAdaptor::MakeCurve(Path->Curve()); |
242 | myPath = GeomConvert::CurveToBSplineCurve(CC); |
243 | myAdpPath = Path; |
244 | myAdpFirstSect = Curve1; |
245 | myAdpLastSect = Curve2; |
246 | } |
247 | |
248 | |
249 | //======================================================================= |
250 | //function : Perform |
251 | //purpose : |
252 | //======================================================================= |
253 | |
254 | void GeomFill_SweepSectionGenerator::Perform(const Standard_Boolean Polynomial) |
255 | { |
256 | myPolynomial = Polynomial; |
257 | |
258 | // eval myNbSections. |
259 | #ifdef DEB |
260 | Standard_Integer Deg = myPath->Degree(); |
261 | #else |
262 | myPath->Degree(); |
263 | #endif |
264 | Standard_Integer NSpans = myPath->NbKnots()-1; |
265 | |
266 | myNbSections = 21 * NSpans; |
267 | |
268 | Standard_Real U; |
269 | |
270 | Standard_Real U1 = myPath->FirstParameter(); |
271 | Standard_Real U2 = myPath->LastParameter(); |
272 | |
273 | GCPnts_QuasiUniformDeflection Samp; |
274 | // Calcul de la longueur approximative de la courbe |
275 | GeomAdaptor_Curve AdpPath(myPath); |
276 | gp_Pnt P1 = AdpPath.Value(U1); |
277 | gp_Pnt P2 = AdpPath.Value((U1+U2)/2.); |
278 | gp_Pnt P3 = AdpPath.Value(U2); |
279 | Standard_Real Length = |
280 | P1.Distance(P2) + P2.Distance(P3); |
281 | Standard_Real Fleche = 1.e-5 * Length; |
282 | Samp.Initialize(AdpPath,Fleche); |
283 | |
284 | if ( Samp.IsDone() && (Samp.NbPoints() > myNbSections) ) { |
285 | myNbSections = Samp.NbPoints(); |
286 | } |
287 | // the transformations are calculate on differents points of <myPath> |
288 | // corresponding to the path parameter uniformly reparted. |
289 | Standard_Real DeltaU = (U2-U1)/(Standard_Real)(myNbSections-1); |
290 | TColStd_Array1OfReal Parameters(1,myNbSections); |
291 | // Parameters(1) = U1; |
292 | // for (Standard_Integer i = 2; i < myNbSections; i++) { |
293 | // Parameters(i) = U1 + (i-1) * DeltaU; |
294 | // } |
295 | // Parameters(myNbSections) = U2; |
296 | |
297 | Parameters(1) = 0.; |
298 | for (Standard_Integer i = 2; i < myNbSections; i++) { |
299 | Parameters(i) = (i-1) * DeltaU; |
300 | } |
301 | Parameters(myNbSections) = U2 - U1; |
302 | |
303 | gp_Vec D1Ref, D1; |
304 | gp_Pnt PRef , P; |
305 | gp_Trsf TR, cumulTR, Trans; |
306 | |
307 | myPath->D1( U1, PRef, D1Ref); |
308 | |
309 | if ( ( myType == 1) || (myType == 4) ) { |
310 | // We create a circle with radius <myRadius>. This axis is create with |
311 | // main direction <DRef> (first derivate vector of <myPath> on the first |
312 | // point <PRef> ). This circle is, after transform to BSpline curve, |
313 | // put in <myFirstSect>. |
314 | |
315 | gp_Ax2 CircleAxis (PRef,D1Ref); |
316 | /* |
317 | Handle(Geom_Circle) Circ = new Geom_Circle( CircleAxis, myRadius); |
318 | |
319 | myFirstSect = GeomConvert::CurveToBSplineCurve(Circ); |
320 | // le cercle est segmente car AppBlend_AppSurf ne gere |
321 | // pas les courbes periodiques. |
c6541a0c |
322 | myFirstSect->Segment(0., 2.*M_PI); |
7fd59977 |
323 | */ |
324 | Handle(Geom_TrimmedCurve) Circ = |
325 | new Geom_TrimmedCurve(new Geom_Circle( CircleAxis, myRadius), |
c6541a0c |
326 | 0., 2.*M_PI); |
7fd59977 |
327 | |
328 | myFirstSect = GeomConvert::CurveToBSplineCurve(Circ,Convert_QuasiAngular); |
329 | } |
330 | |
331 | if (myType <= 3 && myType >=1 ) { |
332 | |
333 | for (Standard_Integer i = 2; i <= myNbSections; i++) { |
334 | |
335 | U = Parameters(i) + U1; |
336 | if (i == myNbSections) U = U2; |
337 | |
338 | myPath->D1( U, P, D1); |
339 | |
340 | // Eval the translation between the (i-1) section and the i-th. |
341 | Trans.SetTranslation(PRef, P); |
342 | |
343 | gp_Trsf Rot; |
344 | if (! D1Ref.IsParallel(D1, Precision::Angular())) { |
345 | // Eval the Rotation between (i-1) section and the i-th. |
346 | Rot.SetRotation(gp_Ax1(P, gp_Dir(D1Ref^D1)), |
347 | D1Ref.AngleWithRef(D1, D1Ref^D1)); |
348 | } |
349 | else |
350 | if (D1Ref.IsOpposite(D1, Precision::Angular())) |
351 | cout <<"Que fais-je ???? " << endl; |
352 | |
353 | // TR is the transformation between (i-1) section and the i-th. |
354 | TR = Rot * Trans; |
355 | // cumulTR is the transformation between <myFirstSec> and |
356 | // the i-th section. |
357 | cumulTR = TR * cumulTR; |
358 | |
359 | myTrsfs.Append(cumulTR); |
360 | |
361 | PRef = P; |
362 | D1Ref = D1; |
363 | } |
364 | } |
365 | else if ( myType != 0) { |
366 | for (Standard_Integer i = 2; i<= myNbSections; i++) { |
367 | cumulTR.SetRotation(myCircPathAxis, Parameters(i)); |
368 | myTrsfs.Append(cumulTR); |
369 | } |
370 | } |
371 | |
372 | myIsDone = Standard_True; |
373 | } |
374 | |
375 | //======================================================================= |
376 | //function : GetShape |
377 | //purpose : |
378 | //======================================================================= |
379 | |
380 | void GeomFill_SweepSectionGenerator::GetShape |
381 | (Standard_Integer& NbPoles, |
382 | Standard_Integer& NbKnots, |
383 | Standard_Integer& Degree, |
384 | Standard_Integer& NbPoles2d) const |
385 | { |
386 | /* |
387 | if ( myType == 1) { |
388 | NbPoles = 7; |
389 | NbKnots = 4; |
390 | Degree = 2; |
391 | } |
392 | else { |
393 | */ |
394 | if ( myType != 0) { |
395 | NbPoles = myFirstSect->NbPoles(); |
396 | NbKnots = myFirstSect->NbKnots(); |
397 | Degree = myFirstSect->Degree(); |
398 | } |
399 | else { // myType == 0 |
400 | NbPoles = 7; |
401 | NbKnots = 2; |
402 | Degree = 6; |
403 | } |
404 | NbPoles2d = 0; |
405 | } |
406 | |
407 | |
408 | //======================================================================= |
409 | //function : Knots |
410 | //purpose : |
411 | //======================================================================= |
412 | |
413 | void GeomFill_SweepSectionGenerator::Knots(TColStd_Array1OfReal& TKnots) const |
414 | { |
415 | /* |
416 | if (myType == 1) { |
c6541a0c |
417 | Standard_Real U = 2.*M_PI/3.; |
7fd59977 |
418 | for ( Standard_Integer i = 1; i <= 4; i++) |
419 | TKnots(i) = ( i-1) * U; |
420 | } |
421 | else { |
422 | */ |
423 | if (myType !=0) { |
424 | myFirstSect->Knots(TKnots); |
425 | } |
426 | else { |
427 | TKnots(1) = 0.; |
428 | TKnots(2) = 1.; |
429 | } |
430 | // } |
431 | } |
432 | |
433 | |
434 | //======================================================================= |
435 | //function : Mults |
436 | //purpose : |
437 | //======================================================================= |
438 | |
439 | void GeomFill_SweepSectionGenerator::Mults(TColStd_Array1OfInteger& TMults) |
440 | const |
441 | { |
442 | /* |
443 | if ( myType == 1) { |
444 | TMults( 1) = TMults( 4) = 3; |
445 | TMults( 2) = TMults( 3) = 2; |
446 | } |
447 | else { |
448 | */ |
449 | if ( myType != 0) { |
450 | myFirstSect->Multiplicities(TMults); |
451 | } |
452 | else { |
453 | TMults( 1) = TMults( 2) = 7; |
454 | } |
455 | // } |
456 | } |
457 | |
458 | |
459 | //======================================================================= |
460 | //function : Section |
461 | //purpose : |
462 | //======================================================================= |
463 | |
464 | Standard_Boolean GeomFill_SweepSectionGenerator::Section |
465 | (const Standard_Integer P, |
466 | TColgp_Array1OfPnt& Poles, |
467 | TColgp_Array1OfVec& DPoles, |
468 | TColgp_Array1OfPnt2d& Poles2d, |
469 | TColgp_Array1OfVec2d& , //DPoles2d, |
470 | TColStd_Array1OfReal& Weigths, |
471 | TColStd_Array1OfReal& DWeigths |
472 | ) const |
473 | { |
474 | Section( P, Poles, Poles2d, Weigths); |
475 | |
476 | // pour les tuyaux sur aretes pour l'instant on ne calcule pas les derivees |
477 | if ( myType == 0 ) return Standard_False; // a voir pour mieux. |
478 | |
479 | // calcul des derivees sur la surface |
480 | // on calcule les derivees en approximant le path au voisinage du point |
481 | // P(u) par le cercle osculateur au path . |
482 | |
483 | // calcul du cercle osculateur. |
484 | |
485 | Standard_Real U; |
486 | if ( P == 1) { |
487 | U = myPath->FirstParameter(); |
488 | } |
489 | else if ( P == myNbSections ) { |
490 | U = myPath->LastParameter(); |
491 | } |
492 | else |
493 | return Standard_False; |
494 | |
495 | gp_Vec D1, D2; |
496 | gp_Pnt Pt; |
497 | |
498 | myPath->D2(U,Pt,D1,D2); |
499 | Standard_Real l = D1.Magnitude(); |
500 | |
501 | if ( l < Epsilon(1.)) |
502 | return Standard_False; |
503 | |
504 | gp_Dir T = D1; |
505 | Standard_Real m = D2.Dot(T); |
506 | gp_Vec D = D2 - m * T; |
507 | Standard_Real c = D.Magnitude() / (l*l); |
508 | |
509 | if ( c < Epsilon(1.)) { |
510 | // null curvature : equivalent to a translation of the section |
511 | for (Standard_Integer i = 1; i <= myFirstSect->NbPoles(); i++) { |
512 | DPoles(i) = D1; |
513 | } |
514 | } |
515 | else { |
516 | gp_Dir N = D; |
517 | gp_Pnt Q = Pt.Translated( (1./c) * gp_Vec(N)); |
518 | Standard_Real x, y; |
519 | gp_Vec V; |
520 | for ( Standard_Integer i = 1; i <= myFirstSect->NbPoles(); i++) { |
521 | V = gp_Vec(Q, Poles(i)); |
522 | x = V * gp_Vec(T); |
523 | y = V * gp_Vec(N); |
524 | DPoles(i) = x * gp_Vec(N) - y * gp_Vec(T); |
525 | if ( DPoles(i).Magnitude() > Epsilon(1.)) { |
526 | DPoles(i).Normalize(); |
527 | DPoles(i) *= Sqrt( x*x + y*y); |
528 | } |
529 | } |
530 | } |
531 | |
532 | for ( Standard_Integer i = 1; i <= myFirstSect->NbPoles(); i++) { |
533 | DWeigths(i) = 0.; |
534 | } |
535 | |
536 | return Standard_True; |
537 | } |
538 | |
539 | |
540 | //======================================================================= |
541 | //function : Section |
542 | //purpose : |
543 | //======================================================================= |
544 | |
545 | void GeomFill_SweepSectionGenerator::Section |
546 | (const Standard_Integer P, |
547 | TColgp_Array1OfPnt& Poles, |
548 | TColgp_Array1OfPnt2d& , //Poles2d, |
549 | TColStd_Array1OfReal& Weigths) const |
550 | { |
551 | if (myType != 0) { |
552 | myFirstSect->Poles(Poles); |
553 | myFirstSect->Weights(Weigths); |
554 | gp_Trsf cumulTR; |
555 | if (P > 1) { |
556 | cumulTR = myTrsfs(P - 1); |
557 | // <cumulTR> transform <myFirstSect> to the P ieme Section. In fact |
558 | // each points of the array <poles> will be transformed. |
559 | |
560 | if ( (myType == 3 ) || (myType == 6) ){ |
561 | for (Standard_Integer i = 1; i <= myFirstSect->NbPoles(); i++) { |
562 | Poles(i).SetXYZ( (myNbSections - P) * myFirstSect->Pole(i).XYZ() + |
563 | (P - 1) * myLastSect->Pole(i).XYZ() ); |
564 | Poles(i).SetXYZ( Poles(i).XYZ() / (myNbSections - 1)); |
565 | |
566 | Weigths(i) = (myNbSections - P) * myFirstSect->Weight(i) + |
567 | (P - 1) * myLastSect->Weight(i); |
568 | Weigths(i) /= myNbSections - 1; |
569 | } |
570 | } |
571 | |
572 | for (Standard_Integer i = 1; i<=Poles.Length(); i++) |
573 | Poles(i).Transform(cumulTR); |
574 | } |
575 | #ifdef DRAW |
576 | if ( Affich) { |
577 | //POP pour NT |
578 | // char name[100]; |
579 | char* name = new char[100]; |
580 | sprintf(name,"SECTION_%d",++NbSECTIONS); |
581 | DrawTrSurf::Set(name,myFirstSect->Transformed(cumulTR)); |
582 | } |
583 | #endif |
584 | } |
585 | else { |
586 | |
587 | Standard_Real Coef = (P -1. ) / ( myNbSections - 1.); |
588 | Standard_Real U = |
589 | ( 1- Coef) * myAdpPath->FirstParameter() + |
590 | Coef * myAdpPath->LastParameter(); |
591 | |
592 | gp_Pnt PPath = myAdpPath->Value(U); |
593 | |
594 | Standard_Real Alpha = U - myAdpPath->FirstParameter(); |
595 | Alpha /= myAdpPath->LastParameter() - myAdpPath->FirstParameter(); |
596 | |
597 | Standard_Real U1 = |
598 | ( 1- Alpha) * myAdpFirstSect->FirstParameter() + |
599 | Alpha * myAdpFirstSect->LastParameter(); |
600 | |
601 | gp_Pnt P1 = myAdpFirstSect->Value(U1); |
602 | |
603 | Standard_Real U2 = |
604 | ( 1- Alpha) * myAdpLastSect->FirstParameter() + |
605 | Alpha * myAdpLastSect->LastParameter(); |
606 | |
607 | gp_Pnt P2 = myAdpLastSect->Value(U2); |
608 | |
609 | gp_Ax2 Axis; |
610 | Standard_Real Angle; |
611 | if ( P1.Distance(P2) < Precision::Confusion()) { |
612 | Angle = 0.; |
613 | } |
614 | else { |
615 | Axis = gp_Ax2(PPath, |
616 | gp_Vec(PPath,P1) ^ gp_Vec(PPath,P2), |
617 | gp_Vec(PPath,P1)); |
618 | Angle = ElCLib::CircleParameter(Axis,P2); |
619 | } |
620 | #ifdef DEB |
621 | if (Standard_False) { |
622 | gp_Vec dummyD1 = myAdpPath->DN(U,1); |
623 | gp_Vec dummyTg = Axis.Direction(); |
624 | Standard_Real Cos = dummyD1.Dot(dummyTg); |
625 | if ( Cos > 0.) cout << "+" ; |
626 | else cout << "-" ; |
627 | } |
628 | #endif |
629 | if ( Angle < Precision::Angular()) { |
630 | for ( Standard_Integer i = 1; i <= Poles.Upper(); i++) { |
631 | Poles(i) = P1; |
632 | Weigths(i) = 1; |
633 | } |
634 | } |
635 | else { |
636 | Handle(Geom_Circle) Circ = |
637 | new Geom_Circle( Axis, myRadius); |
638 | Handle(Geom_TrimmedCurve) CT = |
639 | new Geom_TrimmedCurve(Circ, 0., Angle); |
640 | Handle(Geom_BSplineCurve) BS; |
641 | if ( myPolynomial) |
642 | BS = GeomConvert::CurveToBSplineCurve( CT, Convert_Polynomial); |
643 | else |
644 | BS = GeomConvert::CurveToBSplineCurve( CT, Convert_QuasiAngular); |
645 | |
646 | #ifdef DRAW |
647 | if ( Affich) { |
648 | // POP pour NT |
649 | // char name[100]; |
650 | char* name = new char[100]; |
651 | sprintf(name,"SECTION_%d",++NbSECTIONS); |
652 | DrawTrSurf::Set(name,BS); |
653 | } |
654 | #endif |
655 | |
656 | BS->Poles(Poles); |
657 | BS->Weights(Weigths); |
658 | } |
659 | } |
660 | } |
661 | |
662 | //======================================================================= |
663 | //function : Transformation |
664 | //purpose : |
665 | //======================================================================= |
666 | const gp_Trsf& GeomFill_SweepSectionGenerator::Transformation |
667 | (const Standard_Integer Index) const |
668 | { |
669 | if (Index > myTrsfs.Length()) |
670 | Standard_RangeError::Raise |
671 | ("GeomFill_SweepSectionGenerator::Transformation"); |
672 | |
673 | return myTrsfs(Index); |
674 | } |
675 | |
676 | |
677 | //======================================================================= |
678 | //function : Parameter |
679 | //purpose : |
680 | //======================================================================= |
681 | |
682 | Standard_Real GeomFill_SweepSectionGenerator::Parameter |
683 | (const Standard_Integer P) const |
684 | { |
685 | if (P == 1) { |
686 | return myPath->FirstParameter(); |
687 | } |
688 | else if (P == myNbSections) { |
689 | return myPath->LastParameter(); |
690 | } |
691 | else { |
692 | Standard_Real U1 = myPath->FirstParameter(); |
693 | Standard_Real U2 = myPath->LastParameter(); |
694 | Standard_Real prm = ((myNbSections-P)*U1 + (P-1)*U2)/ |
695 | (Standard_Real)(myNbSections-1); |
696 | return prm; |
697 | } |
698 | } |