0024352: Add Shaders directory to OCCT resources
[occt.git] / src / GeomFill / GeomFill_LocationGuide.cxx
CommitLineData
b311480e 1// Created on: 1998-07-08
2// Created by: Stephanie HUMEAU
3// Copyright (c) 1998-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22
23#include <GeomFill_LocationGuide.ixx>
24#include <gp.hxx>
25#include <gp_Pnt.hxx>
26#include <gp_Vec.hxx>
27#include <gp_Dir.hxx>
28#include <gp_Trsf.hxx>
29#include <gp_GTrsf.hxx>
30#include <gp_XYZ.hxx>
31#include <gp_Ax1.hxx>
32#include <gp_Pnt2d.hxx>
33
34#include <math_Vector.hxx>
35#include <math_Gauss.hxx>
36#include <math_FunctionSetRoot.hxx>
37#include <Precision.hxx>
38
39#include <Geom_SurfaceOfRevolution.hxx>
40#include <Geom_BSplineCurve.hxx>
41#include <Geom_Curve.hxx>
42
43#include <Adaptor3d_SurfaceOfRevolution.hxx>
44#include <Adaptor3d_HSurface.hxx>
45
46#include <IntCurveSurface_IntersectionPoint.hxx>
47#include <IntCurveSurface_HInter.hxx>
48#include <Adaptor3d_Surface.hxx>
49#include <GeomAdaptor.hxx>
50#include <GeomAdaptor_HSurface.hxx>
51#include <GeomAdaptor_HCurve.hxx>
52
53
54#include <GeomFill_FunctionGuide.ixx>
55#include <GeomFill_UniformSection.hxx>
56#include <GeomFill_SectionPlacement.hxx>
57#include <Geom_TrimmedCurve.hxx>
58#include <GeomLib.hxx>
59#include <ElCLib.hxx>
60
61#include <TColStd_HArray1OfInteger.hxx>
62#include <TColStd_HArray1OfReal.hxx>
63#include <TColgp_HArray1OfPnt.hxx>
64
65#if DRAW
66static Standard_Integer Affich = 0;
67#include <Approx_Curve3d.hxx>
68#include <DrawTrSurf.hxx>
69#endif
70
71//=======================================================================
72//function : TraceRevol
73//purpose : Trace la surface de revolution (Debug)
74//=======================================================================
75#if DEB
76static void TraceRevol(const Standard_Real t,
77 const Standard_Real s,
78 const Handle(GeomFill_TrihedronWithGuide)& Law,
79 const Handle(GeomFill_SectionLaw)& Section,
80 const Handle(Adaptor3d_HCurve)& Curve,
81 const gp_Mat& Trans)
82
83{
84 gp_Vec T, N, B;
85 gp_Pnt P;
86 Standard_Boolean Ok;
87 gp_Ax3 Rep(gp::Origin(), gp::DZ(), gp::DX());
88
89 Curve->D0(t, P);
90 Ok = Law->D0(t, T, N, B);
91
92 gp_Mat M(N.XYZ(), B.XYZ(), T.XYZ());
93 M *= Trans;
94
95 gp_Dir D = M.Column(3);
96 gp_Ax1 Ax(P,D); // axe pour la surface de revoltuion
97
98 // calculer transfo entre triedre et Oxyz
99 gp_Dir N2 = N;
100 gp_Ax3 N3(P,D,N2);
101 gp_Trsf Transfo;
102 Transfo.SetTransformation(N3, Rep);
103
104 // transformer la section
105 Standard_Real f, l,e=1.e-7;
106 Handle (Geom_Curve) S, C;
107
108 if (Section->IsConstant(e)) {
109 C = Section->ConstantSection();
110 }
111 else {
112 Standard_Integer NbPoles, NbKnots, Deg;
113 Section->SectionShape(NbPoles, NbKnots, Deg);
114 TColStd_Array1OfInteger Mult(1,NbKnots);
115 Section->Mults( Mult);
116 TColStd_Array1OfReal Knots(1,NbKnots);
117 Section->Knots(Knots);
118 TColgp_Array1OfPnt Poles(1, NbPoles);
119 TColStd_Array1OfReal Weights(1, NbPoles);
120 Section->D0(s, Poles, Weights);
121 if (Section->IsRational())
122 C = new (Geom_BSplineCurve)
123 (Poles, Weights, Knots, Mult ,
124 Deg, Section->IsUPeriodic());
125 else
126 C = new (Geom_BSplineCurve)
127 (Poles, Knots, Mult,
128 Deg, Section->IsUPeriodic());
129
130 }
131
132 f = C->FirstParameter();
133 l = C->LastParameter();
134 S = new (Geom_TrimmedCurve) (C, f, l);
135 S->Transform(Transfo);
136
137 // Surface de revolution
138 Handle (Geom_Surface) Revol = new(Geom_SurfaceOfRevolution) (S, Ax);
139 cout << "Surf Revol at parameter t = " << t << endl;
140
141#if DRAW
142 Standard_CString aName = "TheRevol" ;
143 DrawTrSurf::Set(aName,Revol);
144#endif
145}
146#endif
147
148//==================================================================
149//Function: InGoodPeriod
150//Purpose : Recadre un paramtere
151//==================================================================
152static void InGoodPeriod(const Standard_Real Prec,
153 const Standard_Real Period,
154 Standard_Real& Current)
155{
156 Standard_Real Diff=Current-Prec;
157 Standard_Integer nb = (Standard_Integer ) IntegerPart(Diff/Period);
158 Current -= nb*Period;
159 Diff = Current-Prec;
160 if (Diff > Period/2) Current -= Period;
161 else if (Diff < -Period/2) Current += Period;
162}
163
164//==================================================================
165//Function: GeomFill_LocationGuide
166//Purpose : constructor
167//==================================================================
168 GeomFill_LocationGuide::
169 GeomFill_LocationGuide (const Handle(GeomFill_TrihedronWithGuide)& Triedre)
170 : TolRes(1,3), Inf(1,3,0.), Sup(1,3,0.),
171 X(1,3), R(1,3), myStatus(GeomFill_PipeOk)
172{
173 TolRes.Init(1.e-6);
174 myLaw = Triedre; // loi de triedre
175 mySec.Nullify(); // loi de section
176 myCurve.Nullify();
177 myFirstS = myLastS = -505e77;
178
179 myNbPts = 21; // nb points pour les calculs
180 myGuide = myLaw->Guide(); // courbe guide
181 if (!myGuide->IsPeriodic()) {
182 Standard_Real f, l, delta;
183 f = myGuide->FirstParameter();
184 l = myGuide->LastParameter();
185 delta = (l-f)/100;
186 f-=delta;
187 l+=delta;
188 myGuide = myGuide->Trim(f,l,delta*1.e-7); // courbe guide
189 }// if
190
191 myPoles2d = new (TColgp_HArray2OfPnt2d)(1, 2, 1, myNbPts);
192 rotation = Standard_False; // contact ou non
193 OrigParam1 = 0; // param pour ACR quand trajectoire
194 OrigParam2 = 1; // et guide pas meme sens de parcourt
195 Trans.SetIdentity();
196 WithTrans = Standard_False;
197
198#if DRAW
199 if (Affich) {
200 Approx_Curve3d approx(myGuide, 1.e-4,
201 GeomAbs_C1,
202 15+myGuide->NbIntervals(GeomAbs_CN),
203 14);
204 if (approx.HasResult()) {
205 Standard_CString aName = "TheGuide" ;
206 DrawTrSurf::Set(aName, approx.Curve());
207 }
208 }
209#endif
210}
211
212//==================================================================
213//Function: SetRotation
214//Purpose : init et force la Rotation
215//==================================================================
216 void GeomFill_LocationGuide::SetRotation(const Standard_Real PrecAngle,
217 Standard_Real& LastAngle)
218{
219 if (myCurve.IsNull())
220 Standard_ConstructionError::Raise(
221 "GeomFill_LocationGuide::The path is not setted !!");
222
223 //repere fixe
224 gp_Ax3 Rep(gp::Origin(), gp::DZ(), gp::DX());
225// gp_Pnt P,P1,P2;
226 gp_Pnt P;
227 gp_Vec T,N,B;
228 Standard_Integer ii, Deg;
229 Standard_Boolean isconst, israt=Standard_False;
230 Standard_Real t, v,w, OldAngle=0, Angle, DeltaG, DeltaU, Diff;
231 Standard_Real CurAngle = PrecAngle, a1, a2;
232 gp_Pnt2d p1,p2;
233 Handle(Geom_SurfaceOfRevolution) Revol; // surface de revolution
234 Handle(GeomAdaptor_HSurface) Pl; // = Revol
235 Handle(Geom_TrimmedCurve) S;
236 IntCurveSurface_IntersectionPoint PInt; // intersection guide/Revol
237 IntCurveSurface_HInter Int;
238 Handle(TColStd_HArray1OfInteger) Mult;
239 Handle(TColStd_HArray1OfReal) Knots, Weights;
240 Handle(TColgp_HArray1OfPnt) Poles;
241
242
243 Standard_Real U=0, UPeriod=0;
244 Standard_Real f = myCurve->FirstParameter();
245 Standard_Real l = myCurve->LastParameter();
246 Standard_Boolean Ok, uperiodic = mySec->IsUPeriodic();
247
248 DeltaG = (myGuide->LastParameter() - myGuide->FirstParameter())/5;
249 Handle(Geom_Curve) mySection;
250 Standard_Real Tol =1.e-9;
251
252 Standard_Integer NbPoles, NbKnots;
253 mySec->SectionShape(NbPoles, NbKnots, Deg);
254
255
256 if (mySec->IsConstant(Tol)) {
257 mySection = mySec->ConstantSection();
258 Uf = mySection->FirstParameter();
259 Ul = mySection->LastParameter();
260
261 isconst = Standard_True;
262 }
263 else {
264 isconst = Standard_False;
265 israt = mySec->IsRational();
266 Mult = new (TColStd_HArray1OfInteger) (1, NbKnots);
267 mySec->Mults( Mult->ChangeArray1());
268 Knots = new (TColStd_HArray1OfReal) (1, NbKnots);
269 mySec->Knots(Knots->ChangeArray1());
270 Poles = new (TColgp_HArray1OfPnt) (1, NbPoles);
271 Weights = new (TColStd_HArray1OfReal) (1, NbPoles);
272 Uf = Knots->Value(1);
273 Ul = Knots->Value(NbKnots);
274 }
275
276 // Bornes de calculs
277 Standard_Real Delta;
278// Standard_Integer bid1, bid2, NbK;
279 Delta = myGuide->LastParameter() - myGuide->FirstParameter();
280 Inf(1) = myGuide->FirstParameter() - Delta/10;
281 Sup(1) = myGuide->LastParameter() + Delta/10;
282
c6541a0c
D
283 Inf(2) = -M_PI;
284 Sup(2) = 3*M_PI;
7fd59977 285
286 Delta = Ul - Uf;
287 Inf(3) = Uf - Delta/10;
288 Sup(3) = Ul + Delta/10;
289
290 // JALONNEMENT
291 DeltaU = (Ul-Uf)/(2+NbKnots);
292 if (uperiodic) UPeriod = Ul-Uf;
293
294 for (ii=1; ii<=myNbPts; ii++) {
295 t = Standard_Real(myNbPts - ii)*f + Standard_Real(ii - 1)*l;
296 t /= (myNbPts-1);
297 myCurve->D0(t, P);
298 Ok = myLaw->D0(t, T, N, B);
299 if (!Ok) {
300 myStatus = myLaw->ErrorStatus();
301 return; //Y a rien a faire.
302 }
303 gp_Dir D = T;
304 if (WithTrans) {
305 gp_Mat M(N.XYZ(), B.XYZ(), T.XYZ());
306 M *= Trans;
307 D = M.Column(3);
308 }
309 gp_Ax1 Ax(P,D); // axe pour la surface de revoltuion
310
311 // calculer transfo entre triedre et Oxyz
312 gp_Dir N2 = N;
313 gp_Ax3 N3(P,D,N2);
314 gp_Trsf Transfo;
315 Transfo.SetTransformation(N3, Rep);
316
317 // transformer la section
318 if (! isconst) {
319 U = myFirstS + (t-myCurve->FirstParameter())*ratio;
320 mySec->D0(U, Poles->ChangeArray1(), Weights->ChangeArray1());
321 if (israt)
322 mySection = new (Geom_BSplineCurve)
323 (Poles->Array1(),
324 Weights->Array1(),
325 Knots->Array1(),
326 Mult->Array1(),
327 Deg, mySec->IsUPeriodic());
328 else
329 mySection = new (Geom_BSplineCurve)
330 (Poles->Array1(),
331 Knots->Array1(),
332 Mult->Array1(),
333 Deg, mySec->IsUPeriodic());
334 S = new (Geom_TrimmedCurve) (mySection, Uf, Ul);
335 }
336 else {
337 S = new (Geom_TrimmedCurve)
338 (Handle(Geom_Curve)::DownCast(mySection->Copy()), Uf, Ul);
339 }
340 S->Transform(Transfo);
341
342 // Surface de revolution
343 Revol = new(Geom_SurfaceOfRevolution) (S, Ax);
344
345 Pl = new (GeomAdaptor_HSurface)(Revol);
346 Int.Perform(myGuide, Pl); // intersection surf. revol / guide
347 if (Int.NbPoints() == 0) {
348#if DEB
349 cout <<"LocationGuide : Pas d'intersection"<<endl;
350 TraceRevol(t, U, myLaw, mySec, myCurve, Trans);
351#endif
352 Standard_Boolean SOS=Standard_False;
353 if (ii>1) {
354 // Intersection de secour entre surf revol et guide
355 // equation
356 X(1) = myPoles2d->Value(1,ii-1).Y();
357 X(2) = myPoles2d->Value(2,ii-1).X();
358 X(3) = myPoles2d->Value(2,ii-1).Y();
359 GeomFill_FunctionGuide E (mySec, myGuide, U);
360 E.SetParam(U, P, T.XYZ(), N.XYZ());
361 // resolution => angle
362 math_FunctionSetRoot Result(E, X, TolRes,
363 Inf, Sup);
364
365 if (Result.IsDone() &&
366 (Result.FunctionSetErrors().Norm() < TolRes(1)*TolRes(1)) ) {
367#if DEB
368 cout << "Ratrappage Reussi !" << endl;
369#endif
370 SOS = Standard_True;
371 math_Vector RR(1,3);
372 Result.Root(RR);
373 PInt.SetValues(P, RR(2), RR(3), RR(1), IntCurveSurface_Out);
374 }
375 else {
376#if DEB
377 cout << "Echec du Ratrappage !" << endl;
378#endif
379 }
380 }
381 if (!SOS) {
382 myStatus = GeomFill_ImpossibleContact;
383 return;
384 }
385 }
386 else { // on prend le point d'intersection
387 // d'angle le plus proche de P
388 PInt = Int.Point(1);
389 a1 = PInt.U();
c6541a0c 390 InGoodPeriod (CurAngle, 2*M_PI, a1);
7fd59977 391 Standard_Real Dmin = Abs(a1-CurAngle);
392 for (Standard_Integer jj=2;jj<=Int.NbPoints();jj++) {
393 a2 = Int.Point(jj).U();
c6541a0c 394 InGoodPeriod (CurAngle, 2*M_PI, a2);
7fd59977 395 if (Abs(a2-CurAngle) < Dmin) {
396 PInt = Int.Point(jj);
397 Dmin = Abs(a2-CurAngle);
398 }//if
399 }//for
400 }//else
401
402 // Controle de w
403 w = PInt.W();
404 if (ii>1) {
405 Diff = w - myPoles2d->Value(1, ii-1).Y();
406 if (Abs(Diff) > DeltaG) {
407 if (myGuide->IsPeriodic()) {
408 InGoodPeriod (myPoles2d->Value(1, ii-1).Y(),
409 myGuide->Period(), w);
410 Diff = w - myPoles2d->Value(1, ii-1).Y();
411 }
412 }
413
414#if DEB
415 if (Abs(Diff) > DeltaG) {
416 cout << "Location :: Diff on Guide : " <<
417 Diff << endl;
418 }
419#endif
420 }
421 //Recadrage de l'angle.
422 Angle = PInt.U();
423 if (ii > 1) {
424 Diff = Angle - OldAngle;
c6541a0c
D
425 if (Abs(Diff) > M_PI) {
426 InGoodPeriod (OldAngle, 2*M_PI, Angle);
7fd59977 427 Diff = Angle - OldAngle;
428 }
429#if DEB
c6541a0c 430 if (Abs(Diff) > M_PI/4) {
7fd59977 431 cout << "Diff d'angle trop grand !!" << endl;
432 }
433#endif
434 }
435
436
437 //Recadrage du V
438 v = PInt.V();
439 if (ii > 1) {
440 if (uperiodic) {
441 InGoodPeriod (myPoles2d->Value(2, ii-1).Y(), UPeriod, v);
442 }
443 Diff = v - myPoles2d->Value(2, ii-1).Y();
444#if DEB
445 if (Abs(Diff) > DeltaU) {
446 cout << "Diff sur section trop grand !!" << endl;
447 }
448#endif
449 }
450
451 p1.SetCoord(t, w); // on stocke les parametres
452 p2.SetCoord(Angle , v);
453 CurAngle = Angle;
454 myPoles2d->SetValue(1, ii, p1);
455 myPoles2d->SetValue(2, ii, p2);
456 OldAngle = Angle;
457 }
458
459 LastAngle = CurAngle;
460 rotation = Standard_True; //C'est pret !
461}
462
463
464//==================================================================
465//Function: Set
466//Purpose : init loi de section et force la Rotation
467//==================================================================
468 void GeomFill_LocationGuide::Set(const Handle(GeomFill_SectionLaw)& Section,
469 const Standard_Boolean rotat,
470 const Standard_Real SFirst,
471 const Standard_Real SLast,
472 const Standard_Real PrecAngle,
473 Standard_Real& LastAngle)
474{
475 myStatus = GeomFill_PipeOk;
476 myFirstS = SFirst;
477 myLastS = SLast;
478 LastAngle = PrecAngle;
479 if (myCurve.IsNull())
480 ratio = 0.;
481 else
482 ratio = (SLast-SFirst) / (myCurve->LastParameter() -
483 myCurve->FirstParameter());
484 mySec = Section;
485
486 if (rotat) SetRotation(PrecAngle, LastAngle);
487 else rotation = Standard_False;
488}
489
490//==================================================================
491//Function: EraseRotation
492//Purpose : Supprime la Rotation
493//==================================================================
494 void GeomFill_LocationGuide:: EraseRotation()
495{
496 rotation = Standard_False;
497 if (myStatus == GeomFill_ImpossibleContact) myStatus = GeomFill_PipeOk;
498}
499
500//==================================================================
501//Function: Copy
502//Purpose :
503//==================================================================
504 Handle(GeomFill_LocationLaw) GeomFill_LocationGuide::Copy() const
505{
506 Standard_Real la;
507 Handle(GeomFill_TrihedronWithGuide) L;
508 L = Handle(GeomFill_TrihedronWithGuide)::DownCast(myLaw->Copy());
509 Handle(GeomFill_LocationGuide) copy = new
510 (GeomFill_LocationGuide) (L);
511 copy->SetOrigine(OrigParam1, OrigParam2);
512 copy->Set(mySec, rotation, myFirstS, myLastS,
513 myPoles2d->Value(1,1).X(), la);
514 copy->SetTrsf(Trans);
515
516 return copy;
517}
518
519
520//==================================================================
521//Function: SetCurve
522//Purpose : Calcul des poles sur la surface d'arret (intersection
523// courbe guide / surface de revolution en myNbPts points)
524//==================================================================
525 void GeomFill_LocationGuide::SetCurve(const Handle(Adaptor3d_HCurve)& C)
526{
527 Standard_Real LastAngle;
528 myCurve = C;
529 myTrimmed = C;
530
531 if (!myCurve.IsNull()){
532 myLaw->SetCurve(C);
533 myLaw->Origine(OrigParam1, OrigParam2);
534 myStatus = myLaw->ErrorStatus();
535
536 if (rotation) SetRotation(myPoles2d->Value(1,1).X(), LastAngle);
537 }
538}
539
540//==================================================================
541//Function: GetCurve
542//Purpose : return the trajectoire
543//==================================================================
544 const Handle(Adaptor3d_HCurve)& GeomFill_LocationGuide::GetCurve() const
545{
546 return myCurve;
547}
548
549//==================================================================
550//Function: SetTrsf
551//Purpose :
552//==================================================================
553 void GeomFill_LocationGuide::SetTrsf(const gp_Mat& Transfo)
554{
555 Trans = Transfo;
556 gp_Mat Aux;
557 Aux.SetIdentity();
558 Aux -= Trans;
559 WithTrans = Standard_False; // Au cas ou Trans = I
560 for (Standard_Integer ii=1; ii<=3 && !WithTrans ; ii++)
561 for (Standard_Integer jj=1; jj<=3 && !WithTrans; jj++)
562 if (Abs(Aux.Value(ii, jj)) > 1.e-14) WithTrans = Standard_True;
563}
564
565//==================================================================
566//Function: D0
567//Purpose :
568//==================================================================
569 Standard_Boolean GeomFill_LocationGuide::D0(const Standard_Real Param,
570 gp_Mat& M,
571 gp_Vec& V)
572{
573 Standard_Boolean Ok;
574 gp_Vec T,N,B;
575 gp_Pnt P;
576
577 myCurve->D0(Param, P);
578 V.SetXYZ(P.XYZ());
579 Ok = myLaw->D0(Param, T, N, B);
580 if (!Ok) {
581 myStatus = myLaw->ErrorStatus();
582 return Ok;
583 }
584 M.SetCols(N.XYZ(), B.XYZ(), T.XYZ());
585
586 if (WithTrans) {
587 M *= Trans;
588 }
589
590 if(rotation) {
591 Standard_Real U = myFirstS +
592 (Param-myCurve->FirstParameter())*ratio;
593 // initialisations germe
594 InitX(Param);
595
596 Standard_Integer Iter = 100;
597 gp_XYZ t,b,n;
598 t = M.Column(3);
599 b = M.Column(2);
600 n = M.Column(1);
601
602 // Intersection entre surf revol et guide
603 // equation
604 GeomFill_FunctionGuide E (mySec, myGuide, U);
605 E.SetParam(Param, P, t, n);
606 // resolution => angle
607 math_FunctionSetRoot Result(E, X, TolRes,
608 Inf, Sup, Iter);
609
610 if (Result.IsDone()) {
611 // solution
612 Result.Root(R);
613
614 // rotation
615 gp_Mat Rot;
616 Rot.SetRotation(t, R(2));
617 b *= Rot;
618 n *= Rot;
619
620 M.SetCols(n, b, t);
621 }
622 else {
623#if DEB
624 cout << "LocationGuide::D0 : No Result !"<<endl;
625 TraceRevol(Param, U, myLaw, mySec, myCurve, Trans);
626#endif
627 myStatus = GeomFill_ImpossibleContact;
628 return Standard_False;
629 }
630 }
631
632 return Standard_True;
633}
634
635//==================================================================
636//Function: D0
637//Purpose : calcul de l'intersection (C0) surface revol / guide
638//==================================================================
639 Standard_Boolean GeomFill_LocationGuide::D0(const Standard_Real Param,
640 gp_Mat& M,
641 gp_Vec& V,
642// TColgp_Array1OfPnt2d& Poles2d)
643 TColgp_Array1OfPnt2d& )
644{
645 gp_Vec T, N, B;
646 gp_Pnt P;
647 Standard_Boolean Ok;
7fd59977 648
649 myCurve->D0(Param, P);
650 V.SetXYZ(P.XYZ());
651 Ok = myLaw->D0(Param, T, N, B);
652 if (!Ok) {
653 myStatus = myLaw->ErrorStatus();
654 return Ok;
655 }
656 M.SetCols(N.XYZ(), B.XYZ(), T.XYZ());
657
658 if (WithTrans) {
659 M *= Trans;
660 }
661
662 if (rotation) {
7fd59977 663 //initialisation du germe
664 InitX(Param);
665 Standard_Integer Iter = 100;
666 gp_XYZ b, n, t;
667 t = M.Column(3);
668 b = M.Column(2);
669 n = M.Column(1);
670
671 // equation d'intersection entre surf revol et guide => angle
672 GeomFill_FunctionGuide E (mySec, myGuide, myFirstS +
673 (Param-myCurve->FirstParameter())*ratio);
674 E.SetParam(Param, P, t, n);
675
676 // resolution
677 math_FunctionSetRoot Result(E, X, TolRes,
678 Inf, Sup, Iter);
679
680 if (Result.IsDone()) {
681 // solution
682 Result.Root(R);
683
684 // rotation
685 gp_Mat Rot;
686 Rot.SetRotation(t, R(2));
687
688
689 b *= Rot;
690 n *= Rot;
691
692 M.SetCols(n, b, t);
693 }
694 else {
695#if DEB
6e6cd5d9 696 Standard_Real U = myFirstS + ratio*(Param-myCurve->FirstParameter());
7fd59977 697 cout << "LocationGuide::D0 : No Result !"<<endl;
698 TraceRevol(Param, U, myLaw, mySec, myCurve, Trans);
699#endif
700 myStatus = GeomFill_ImpossibleContact;
701 return Standard_False;
702 }
703 }
704
705 return Standard_True;
706}
707
708
709//==================================================================
710//Function: D1
711//Purpose : calcul de l'intersection (C1) surface revol / guide
712//==================================================================
713 Standard_Boolean GeomFill_LocationGuide::D1(const Standard_Real Param,
714 gp_Mat& M,
715 gp_Vec& V,
716 gp_Mat& DM,
717 gp_Vec& DV,
718// TColgp_Array1OfPnt2d& Poles2d,
719 TColgp_Array1OfPnt2d& ,
720// TColgp_Array1OfVec2d& DPoles2d)
721 TColgp_Array1OfVec2d& )
722{
723// gp_Vec T, N, B, DT, DN, DB, T0, N0, B0;
724 gp_Vec T, N, B, DT, DN, DB;
725// gp_Pnt P, P0;
726 gp_Pnt P;
727 Standard_Boolean Ok;
728
729 myCurve->D1(Param, P, DV);
730 V.SetXYZ(P.XYZ());
731 Ok = myLaw->D1(Param, T, DT, N, DN, B, DB);
732 if (!Ok) {
733 myStatus = myLaw->ErrorStatus();
734 return Ok;
735 }
736 M.SetCols(N.XYZ(), B.XYZ(), T.XYZ());
737 DM.SetCols(DN.XYZ() , DB.XYZ(), DT.XYZ());
738
739 if (WithTrans) {
740 M *= Trans;
741 DM *= Trans;
742 }
743
744 if (rotation) {
745 return Standard_False;
4e76d93b 746 /*
7fd59977 747#ifdef DEB
748 Standard_Real U = myFirstS + ratio*(Param-myCurve->FirstParameter());
749#else
750 myCurve->FirstParameter() ;
751#endif
752
753 // initialisation du germe
754 InitX(Param);
755
756 Standard_Integer Iter = 100;
757 gp_XYZ t,b,n, dt, db, dn;
758 t = M.Column(3);
759 b = M.Column(2);
760 n = M.Column(1);
761 dt = M.Column(3);
762 db = M.Column(2);
763 dn = M.Column(1);
764
765 // equation d'intersection surf revol / guide => angle
766 GeomFill_FunctionGuide E (mySec, myGuide, myFirstS +
767 (Param-myCurve->FirstParameter())*ratio);
768 E.SetParam(Param, P, t, n);
769
770 // resolution
771 math_FunctionSetRoot Result(E, X, TolRes,
772 Inf, Sup, Iter);
773
774 if (Result.IsDone())
775 {
776 // solution de la fonction
777 Result.Root(R);
778
779 // derivee de la fonction
780 math_Vector DEDT(1,3);
781 E.DerivT(R, DV.XYZ(), dt, DEDT); // dE/dt => DEDT
782
783 math_Vector DSDT (1,3,0);
784 math_Matrix DEDX (1,3,1,3,0);
785 E.Derivatives(R, DEDX); // dE/dx au point R => DEDX
786
787 // resolution du syst. : DEDX*DSDT = -DEDT
788 math_Gauss Ga(DEDX);
789 if (Ga.IsDone())
790 {
791 Ga.Solve (DEDT.Opposite(), DSDT);// resolution du syst.
792 }//if
793 else {
794#if DEB
795 cout << "DEDX = " << DEDX << endl;
796 cout << "DEDT = " << DEDT << endl;
797#endif
798 Standard_ConstructionError::Raise(
799 "LocationGuide::D1 : No Result dans la derivee");
800 }
801
802 // transformation = rotation
803 gp_Mat Rot, DRot;
804 Rot.SetRotation(t, R(2));
805
806
807
808 M.SetCols(n*Rot, b*Rot, t);
809
810 // transfo entre triedre (en Q) et Oxyz
811 gp_Ax3 Rep(gp::Origin(),gp::DZ(), gp::DX());
812 gp_Ax3 RepTriedre(gp::Origin(),t,n);
813 gp_Trsf Transfo3;
814 Transfo3.SetTransformation(Rep,RepTriedre);
815 // on se place dans Oxyz
816 Transfo3.Transforms(n);
817 Transfo3.Transforms(b);
818 Transfo3.Transforms(dn);
819 Transfo3.Transforms(db);
820
821 // matrices de rotation et derivees
822 Standard_Real A = R(2);
823 Standard_Real Aprim = DSDT(2);
824
825#ifdef DEB
826 gp_Mat M2 (Cos(A), -Sin(A),0, // rotation autour de T
827 Sin(A), Cos(A),0,
828 0,0,1);
829#endif
830
831 gp_Mat M2prim (-Sin(A), -Cos(A), 0, // derivee rotation autour de T
832 Cos(A), -Sin(A), 0,
833 0, 0, 0);
834 M2prim.Multiply(Aprim);
835
836 // transformations
837
838
839 dn *= Rot;
840 db *= Rot;
841
842 n *= DRot;
843 b *= DRot;
844
845 dn += n;
846 db += b;
847
848 // on repasse dans repere triedre
849 gp_Trsf InvTrsf;
850 InvTrsf = Transfo3.Inverted();
851 InvTrsf.Transforms(dn);
852 InvTrsf.Transforms(db);
853
854 DM.SetCols(dn , db , dt);
855 }//if_Result
856
857 else {
858#if DEB
859 cout << "LocationGuide::D1 : No Result !!"<<endl;
860 TraceRevol(Param, U, myLaw, mySec, myCurve, Trans);
861#endif
862 myStatus = GeomFill_ImpossibleContact;
863 return Standard_False;
864 }
4e76d93b 865*/
7fd59977 866 }//if_rotation
867
868
869 return Standard_True;
870
871}
872
873//==================================================================
874//Function: D2
875//Purpose : calcul de l'intersection (C2) surface revol / guide
876//==================================================================
877Standard_Boolean GeomFill_LocationGuide::D2(const Standard_Real Param,
878 gp_Mat& M,
879 gp_Vec& V,
880 gp_Mat& DM,
881 gp_Vec& DV,
882 gp_Mat& D2M,
883 gp_Vec& D2V,
884// TColgp_Array1OfPnt2d& Poles2d,
885 TColgp_Array1OfPnt2d& ,
886// TColgp_Array1OfVec2d& DPoles2d,
887 TColgp_Array1OfVec2d& ,
888// TColgp_Array1OfVec2d& D2Poles2d)
889 TColgp_Array1OfVec2d& )
890{
891 gp_Vec T, N, B, DT, DN, DB, D2T, D2N, D2B;
892// gp_Vec T0, N0, B0, T1, N1, B1;
893// gp_Pnt P, P0, P1;
894 gp_Pnt P;
895 Standard_Boolean Ok;
896
897 myCurve->D2(Param, P, DV, D2V);
898 V.SetXYZ(P.XYZ());
899 Ok = myLaw->D2(Param, T, DT, D2T, N, DN, D2N, B, DB, D2B);
900 if (!Ok) {
901 myStatus = myLaw->ErrorStatus();
902 return Ok;
903 }
904
905 if (WithTrans) {
906 M *= Trans;
907 DM *= Trans;
908 D2M *= Trans;
909 }
910
911 if (rotation)
912 {
913 return Standard_False;
914/*
915 Standard_Real U = myFirstS +
916 (Param-myCurve->FirstParameter())*ratio;
917 // rotation
918 math_Vector X(1,3,0);
919 InitX(Param,X);
920 // tolerance sur X
921
922 TolRes.Init(1.e-6);
923 // tolerance sur E
924// Standard_Real ETol = 1.e-6;
925 Standard_Integer Iter = 100;
926
927
928 // resoudre equation d'intersection entre surf revol et guide => angle
929 GeomFill_FunctionGuide E (mySec, myGuide, myFirstS +
930 (Param-myCurve->FirstParameter())*ratio);
931 E.SetParam(Param, P, T, N);
932
933 // resolution
934 math_FunctionSetRoot Result(E, X, TolRes,
935 Inf, Sup, Iter);
936
937 if (Result.IsDone())
938 {
939 Result.Root(R); // solution
940
941 //gp_Pnt2d p (R(2), R(3)); // point sur la surface (angle, v)
942 //Poles2d.SetValue(1,p);
943
944 // derivee de la fonction
945 math_Vector DEDT(1,3,0);
946 E.DerivT(Param, Param0, R, R0, DEDT); // dE/dt => DEDT
947 math_Vector DSDT (1,3,0);
948 math_Matrix DEDX (1,3,1,3,0);
949 E.Derivatives(R, DEDX); // dE/dx au point R => DEDX
950
951 // resolution du syst. lin. : DEDX*DSDT = -DEDT
952 math_Gauss Ga(DEDX);
953 if (Ga.IsDone())
954 {
955 Ga.Solve (DEDT.Opposite(), DSDT); // resolution du syst. lin.
956 //gp_Vec2d dp (DSDT(2), DSDT(3)); // surface
957 //DPoles2d.SetValue(1, dp);
958 }//if
959 else cout <<"LocationGuide::D2 : No Result dans la derivee premiere"<<endl;
960
961 // deuxieme derivee
962 GeomFill_Tensor D2EDX2(3,3,3);
963 E.Deriv2X(R, D2EDX2); // d2E/dx2
964
965 math_Vector D2EDT2(1,3,0);
966
967 // if(Param1 < Param && Param < Param0)
968 E.Deriv2T(Param1, Param, Param0, R1, R, R0, D2EDT2); // d2E/dt2
969 // else if (Param < Param0 && Param0 < Param1)
970 // E.Deriv2T(Param, Param0, Param1, R, R0, R1, D2EDT2); // d2E/dt2
971 // else
972 // E.Deriv2T(Param0, Param1, Param, R0, R1, R, D2EDT2); // d2E/dt2
973
974 math_Matrix D2EDTDX(1,3,1,3,0);
975 E.DerivTX(Param, Param0, R, R0, D2EDTDX); // d2E/dtdx
976
977 math_Vector D2SDT2(1,3,0); // d2s/dt2
978 math_Matrix M1(1,3,1,3,0);
979 D2EDX2.Multiply(DSDT,M1);
980
981 // resolution du syst. lin.
982 math_Gauss Ga1 (DEDX);
983 if (Ga1.IsDone())
984 {
985 Ga1.Solve ( - M1*DSDT - 2*D2EDTDX*DSDT - D2EDT2 , D2SDT2);
986 //gp_Vec2d d2p (D2SDT2(2), D2SDT2(3)); // surface
987 //D2Poles2d.SetValue(1, d2p);
988 }//if
989 else {
990 cout <<"LocationGuide::D2 : No Result dans la derivee seconde"<<endl;
991 myStatus = GeomFill_ImpossibleContact;
992 }
993
994//------------------------------------------
995// rotation
996//------------------------------------------
997
998 gp_Trsf Tr;
999 gp_Pnt Q (0, 0 ,0);
1000 gp_Ax1 Axe (Q, D);
1001 Tr.SetRotation(Axe, R(2));
1002
1003 gp_Vec b,b2;
1004 b = b2 = B;
1005 gp_Vec n,n2;
1006 n = n2 = N;
1007
1008 B.Transform(Tr);
1009 N.Transform(Tr);
1010
1011 M.SetCols(N.XYZ(), B.XYZ(), T.XYZ());
1012
1013//------------------------------------------
1014// derivees de la rotation
1015// A VERIFIER !!!!
1016//-----------------------------------------
1017 gp_Vec db,dn,db3,dn3;
1018 db = db3 = DB;
1019 dn = dn3 = DN;
1020
1021 gp_Vec db1,dn1,db2,dn2;
1022
1023//transfo entre triedre et Oxyz
1024 gp_Ax3 RepTriedre4(Q,D,B2);
1025 gp_Trsf Transfo3;
1026 Transfo3.SetTransformation(Rep,RepTriedre4);
1027
1028//on passe dans le repere du triedre
1029 n.Transform(Transfo3);
1030 b.Transform(Transfo3);
1031 n2.Transform(Transfo3);
1032 b2.Transform(Transfo3);
1033 dn.Transform(Transfo3);
1034 db.Transform(Transfo3);
1035 dn3.Transform(Transfo3);
1036 db3.Transform(Transfo3);
1037 D2N.Transform(Transfo3);
1038 D2B.Transform(Transfo3);
1039
1040//matrices de rotation et derivees
1041 Standard_Real A = R(2);
1042 Standard_Real Aprim = DSDT(2);
1043 Standard_Real Asec = D2SDT2(2);
1044
1045 gp_Mat M2 (Cos(A),-Sin(A),0, // rotation autour de T
1046 Sin(A), Cos(A),0,
1047 0, 0, 1);
1048
1049 gp_Mat M2prim (-Sin(A),-Cos(A),0, // derivee 1ere rotation autour de T
1050 Cos(A), -Sin(A),0,
1051 0,0,0);
1052
1053 gp_Mat M2sec (-Cos(A), Sin(A), 0, // derivee 2nde rotation autour de T
1054 -Sin(A), -Cos(A), 0,
1055 0,0,0);
1056 M2sec.Multiply(Aprim*Aprim);
1057 gp_Mat M2p = M2prim.Multiplied(Asec);
1058 M2sec.Add(M2p);
1059
1060 M2prim.Multiply(Aprim);
1061
1062// transformation
1063 gp_Trsf Rot;
1064 Rot.SetValues(M2(1,1),M2(1,2),M2(1,3),0,
1065 M2(2,1),M2(2,2),M2(2,3),0,
1066 M2(3,1),M2(3,2),M2(3,3),0,
1067 1.e-8,1.e-8);
1068 gp_Trsf DRot;
1069 DRot.SetValues(M2prim(1,1),M2prim(1,2),M2prim(1,3),0,
1070 M2prim(2,1),M2prim(2,2),M2prim(2,3),0,
1071 M2prim(3,1),M2prim(3,2),M2prim(3,3),0,
1072 1.e-8,1.e-8);
1073
1074 gp_Trsf D2Rot;
1075 D2Rot.SetValues(M2sec(1,1),M2sec(1,2),M2sec(1,3),0,
1076 M2sec(2,1),M2sec(2,2),M2sec(2,3),0,
1077 M2sec(3,1),M2sec(3,2),M2sec(3,3),0,
1078 1.e-8,1.e-8);
1079
1080
1081//derivee premiere
1082 dn.Transform(Rot);
1083 db.Transform(Rot);
1084 n.Transform(DRot);
1085 b.Transform(DRot);
1086 dn1 = dn + n;
1087 db1 = db + b;
1088 dn1.Transform(Transfo3.Inverted());
1089 db1.Transform(Transfo3.Inverted());
1090
1091 DM.SetCols(dn1.XYZ(), db1.XYZ(), DT.XYZ());
1092
1093//derivee seconde
1094 D2N.Transform(Rot);
1095 D2B.Transform(Rot);
1096 dn3.Transform(DRot);
1097 db3.Transform(DRot);
1098 n2.Transform(D2Rot);
1099 b2.Transform(D2Rot);
1100 dn2 = n2 + 2*dn3 + D2N;
1101 db2 = b2 + 2*db3 + D2B;
1102 dn2.Transform(Transfo3.Inverted());
1103 db2.Transform(Transfo3.Inverted());
1104
1105 D2M.SetCols(dn2.XYZ(), db2.XYZ(), D2T.XYZ());
1106
1107 }//if_result
1108 else {
1109#if DEB
1110 cout << "LocationGuide::D2 : No Result !!" <<endl;
1111 TraceRevol(Param, U, myLaw, mySec, myCurve, Trans);
1112#endif
1113 return Standard_False;
1114 }*/
1115 }//if_rotation
1116
1117 else
1118 {
1119 M.SetCols(N.XYZ(), B.XYZ(), T.XYZ());
1120 DM.SetCols(DN.XYZ(), DB.XYZ(), DT.XYZ());
1121 D2M.SetCols(D2N.XYZ(), D2B.XYZ(), D2T.XYZ());
1122 }
1123
1124 return Standard_True;
1125// return Standard_False;
1126}
1127
1128//==================================================================
1129//Function : HasFirstRestriction
1130//Purpose :
1131//==================================================================
1132 Standard_Boolean GeomFill_LocationGuide::HasFirstRestriction() const
1133{
1134 return Standard_False;
1135}
1136
1137//==================================================================
1138//Function : HasLastRestriction
1139//Purpose :
1140//==================================================================
1141 Standard_Boolean GeomFill_LocationGuide::HasLastRestriction() const
1142{
1143 return Standard_False;
1144}
1145
1146//==================================================================
1147//Function : TraceNumber
1148//Purpose :
1149//==================================================================
1150 Standard_Integer GeomFill_LocationGuide::TraceNumber() const
1151{
1152 return 0;
1153}
1154
1155//==================================================================
1156//Function : ErrorStatus
1157//Purpose :
1158//==================================================================
1159 GeomFill_PipeError GeomFill_LocationGuide::ErrorStatus() const
1160{
1161 return myStatus;
1162}
1163
1164//==================================================================
1165//Function:NbIntervals
1166//Purpose :
1167//==================================================================
1168 Standard_Integer GeomFill_LocationGuide::NbIntervals
1169 (const GeomAbs_Shape S) const
1170{
1171 Standard_Integer Nb_Sec, Nb_Law;
1172 Nb_Sec = myTrimmed->NbIntervals(S);
1173 Nb_Law = myLaw->NbIntervals(S);
1174
1175 if (Nb_Sec==1) {
1176 return Nb_Law;
1177 }
1178 else if (Nb_Law==1) {
1179 return Nb_Sec;
1180 }
1181
1182 TColStd_Array1OfReal IntC(1, Nb_Sec+1);
1183 TColStd_Array1OfReal IntL(1, Nb_Law+1);
1184 TColStd_SequenceOfReal Inter;
1185 myTrimmed->Intervals(IntC, S);
1186 myLaw->Intervals(IntL, S);
1187
1188 GeomLib::FuseIntervals( IntC, IntL, Inter, Precision::PConfusion()*0.99);
1189 return Inter.Length()-1;
1190
1191}
1192
1193//==================================================================
1194//Function:Intervals
1195//Purpose :
1196//==================================================================
1197 void GeomFill_LocationGuide::Intervals(TColStd_Array1OfReal& T,
1198 const GeomAbs_Shape S) const
1199{
1200 Standard_Integer Nb_Sec, Nb_Law;
1201 Nb_Sec = myTrimmed->NbIntervals(S);
1202 Nb_Law = myLaw->NbIntervals(S);
1203
1204 if (Nb_Sec==1) {
1205 myLaw->Intervals(T, S);
1206 return;
1207 }
1208 else if (Nb_Law==1) {
1209 myTrimmed->Intervals(T, S);
1210 return;
1211 }
1212
1213 TColStd_Array1OfReal IntC(1, Nb_Sec+1);
1214 TColStd_Array1OfReal IntL(1, Nb_Law+1);
1215 TColStd_SequenceOfReal Inter;
1216 myTrimmed->Intervals(IntC, S);
1217 myLaw->Intervals(IntL, S);
1218
1219 GeomLib::FuseIntervals(IntC, IntL, Inter, Precision::PConfusion()*0.99);
1220 for (Standard_Integer ii=1; ii<=Inter.Length(); ii++)
1221 T(ii) = Inter(ii);
1222}
1223
1224//==================================================================
1225//Function:SetInterval
1226//Purpose :
1227//==================================================================
1228 void GeomFill_LocationGuide::SetInterval(const Standard_Real First,
1229 const Standard_Real Last)
1230{
1231 myLaw->SetInterval(First, Last);
1232 myTrimmed = myCurve->Trim(First, Last, 0);
1233}
1234//==================================================================
1235//Function: GetInterval
1236//Purpose :
1237//==================================================================
1238 void GeomFill_LocationGuide::GetInterval(Standard_Real& First,
1239 Standard_Real& Last) const
1240{
1241 First = myTrimmed->FirstParameter();
1242 Last = myTrimmed->LastParameter();
1243}
1244
1245//==================================================================
1246//Function: GetDomain
1247//Purpose :
1248//==================================================================
1249 void GeomFill_LocationGuide::GetDomain(Standard_Real& First,
1250 Standard_Real& Last) const
1251{
1252 First = myCurve->FirstParameter();
1253 Last = myCurve->LastParameter();
1254}
1255
1256//==================================================================
1257//function : SetTolerance
1258//purpose :
1259//==================================================================
1260void GeomFill_LocationGuide::SetTolerance(const Standard_Real Tol3d,
1261 const Standard_Real )
1262{
1263 TolRes(1) = myGuide->Resolution(Tol3d);
1264 Resolution(1, Tol3d, TolRes(2), TolRes(3));
1265
1266}
1267
1268//==================================================================
1269//function : Resolution
1270//purpose : A definir
1271//==================================================================
1272//void GeomFill_LocationGuide::Resolution (const Standard_Integer Index,
1273void GeomFill_LocationGuide::Resolution (const Standard_Integer ,
1274 const Standard_Real Tol,
1275 Standard_Real& TolU,
1276 Standard_Real& TolV) const
1277{
1278 TolU = Tol/100;
1279 TolV = Tol/100;
1280}
1281
1282//==================================================================
1283//Function:GetMaximalNorm
1284//Purpose : On suppose les triedres normes => return 1
1285//==================================================================
1286 Standard_Real GeomFill_LocationGuide::GetMaximalNorm()
1287{
1288 return 1.;
1289}
1290
1291//==================================================================
1292//Function:GetAverageLaw
1293//Purpose :
1294//==================================================================
1295 void GeomFill_LocationGuide::GetAverageLaw(gp_Mat& AM,
1296 gp_Vec& AV)
1297{
1298 Standard_Integer ii;
1299 Standard_Real U, delta;
1300 gp_Vec V, V1, V2, V3;
1301
1302 myLaw->GetAverageLaw(V1, V2, V3);
1303 AM.SetCols(V1.XYZ(), V2.XYZ(), V3.XYZ());
1304
1305 AV.SetCoord(0., 0., 0.);
1306 delta = (myTrimmed->LastParameter() - myTrimmed->FirstParameter())/10;
1307 U = myTrimmed->FirstParameter();
1308 for (ii=0; ii<=myNbPts; ii++, U+=delta) {
1309 V.SetXYZ( myTrimmed->Value(U).XYZ() );
1310 AV += V;
1311 }
1312 AV = AV/(myNbPts+1);
1313}
1314
1315
1316//==================================================================
1317//Function : Section
1318//Purpose :
1319//==================================================================
1320 Handle(Geom_Curve) GeomFill_LocationGuide::Section() const
1321{
1322 return mySec->ConstantSection();
1323}
1324
1325//==================================================================
1326//Function : Guide
1327//Purpose :
1328//==================================================================
1329 Handle(Adaptor3d_HCurve) GeomFill_LocationGuide::Guide() const
1330{
1331 return myGuide;
1332}
1333
1334//==================================================================
1335//Function : IsRotation
1336//Purpose :
1337//==================================================================
1338// Standard_Boolean GeomFill_LocationGuide::IsRotation(Standard_Real& Error) const
1339 Standard_Boolean GeomFill_LocationGuide::IsRotation(Standard_Real& ) const
1340{
1341 return Standard_False;
1342}
1343
1344//==================================================================
1345//Function : Rotation
1346//Purpose :
1347//==================================================================
1348// void GeomFill_LocationGuide::Rotation(gp_Pnt& Centre) const
1349 void GeomFill_LocationGuide::Rotation(gp_Pnt& ) const
1350{
1351 Standard_NotImplemented::Raise("GeomFill_LocationGuide::Rotation");
1352}
1353
1354//==================================================================
1355//Function : IsTranslation
1356//Purpose :
1357//==================================================================
1358// Standard_Boolean GeomFill_LocationGuide::IsTranslation(Standard_Real& Error) const
1359 Standard_Boolean GeomFill_LocationGuide::IsTranslation(Standard_Real& ) const
1360{
1361 return Standard_False;
1362}
1363
1364//==================================================================
1365//Function : InitX
1366//Purpose : recherche par interpolation d'une valeur initiale
1367//==================================================================
1368void GeomFill_LocationGuide::InitX(const Standard_Real Param) const
1369{
1370
1371 Standard_Integer Ideb = 1, Ifin = myPoles2d->RowLength(), Idemi;
1372 Standard_Real Valeur, t1, t2;
1373
1374
1375 Valeur = myPoles2d->Value(1, Ideb).X();
1376 if (Param == Valeur) {
1377 Ifin = Ideb+1;
1378 }
1379
1380 Valeur = myPoles2d->Value(1, Ifin).X();
1381 if (Param == Valeur) {
1382 Ideb = Ifin-1;
1383 }
1384
1385 while ( Ideb+1 != Ifin) {
1386 Idemi = (Ideb+Ifin)/2;
1387 Valeur = myPoles2d->Value(1, Idemi).X();
1388 if (Valeur < Param) {
1389 Ideb = Idemi;
1390 }
1391 else {
1392 if ( Valeur > Param) { Ifin = Idemi;}
1393 else {
1394 Ideb = Idemi;
1395 Ifin = Ideb+1;
1396 }
1397 }
1398 }
1399
1400 t1 = myPoles2d->Value(1,Ideb).X();
1401 t2 = myPoles2d->Value(1,Ifin).X();
1402 Standard_Real diff = t2-t1;
1403
1404 Standard_Real W1, W2;
1405 W1 = myPoles2d->Value(1,Ideb).Coord(2);
1406 W2 = myPoles2d->Value(1,Ifin).Coord(2);
1407 const gp_Pnt2d& P1 = myPoles2d->Value(2, Ideb);
1408 const gp_Pnt2d& P2 = myPoles2d->Value(2, Ifin);
1409
1410 if (diff > 1.e-7) {
1411 Standard_Real b = (Param-t1) / diff,
1412 a = (t2-Param) / diff;
1413 X(1) = a * W1 + b * W2;
1414 X(2) = a * P1.Coord(1) + b * P2.Coord(1); // angle
1415 X(3) = a * P1.Coord(2) + b * P2.Coord(2); // param isov
1416 }
1417 else {
1418 X(1) = (W1+W2) /2;
1419 X(2) = (P1.Coord(1) + P2.Coord(1)) /2;
1420 X(3) = (P1.Coord(2) + P2.Coord(2)) /2;
1421 }
1422
1423 if (myGuide->IsPeriodic()) {
1424 X(1) = ElCLib::InPeriod(X(1), myGuide->FirstParameter(),
1425 myGuide->LastParameter());
1426 }
c6541a0c 1427 X(2) = ElCLib::InPeriod(X(2), 0, 2*M_PI);
7fd59977 1428 if (mySec->IsUPeriodic()) {
1429 X(3) = ElCLib::InPeriod(X(3), Uf, Ul);
1430 }
1431}
1432
1433
1434//==================================================================
1435//Function : SetOrigine
1436//Purpose : utilise pour ACR dans le cas ou la trajectoire est multi-edges
1437//==================================================================
1438void GeomFill_LocationGuide::SetOrigine(const Standard_Real Param1,
1439 const Standard_Real Param2)
1440{
1441 OrigParam1 = Param1;
1442 OrigParam2 = Param2;
1443}
1444