1 // Created on: 1992-10-19
2 // Created by: Remi GILET
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Modified by skv - Fri Jul 1 16:23:17 2005 IDEM(Airbus)
18 // Modified by skv - Wed Jul 7 17:21:09 2004 IDEM(Airbus)
20 #include <Bisector_BisecAna.hxx>
22 #include <GccAna_Circ2dBisec.hxx>
23 #include <GccAna_CircLin2dBisec.hxx>
24 #include <GccAna_CircPnt2dBisec.hxx>
25 #include <GccAna_LinPnt2dBisec.hxx>
26 #include <GccAna_Pnt2dBisec.hxx>
27 #include <GccInt_BLine.hxx>
28 #include <GccInt_IType.hxx>
29 #include <Geom2d_Circle.hxx>
30 #include <Geom2d_Curve.hxx>
31 #include <Geom2d_Ellipse.hxx>
32 #include <Geom2d_Geometry.hxx>
33 #include <Geom2d_Hyperbola.hxx>
34 #include <Geom2d_Line.hxx>
35 #include <Geom2d_Parabola.hxx>
36 #include <Geom2d_Point.hxx>
37 #include <Geom2d_TrimmedCurve.hxx>
38 #include <Geom2dAdaptor_Curve.hxx>
39 #include <gp_Pnt2d.hxx>
40 #include <gp_Trsf2d.hxx>
41 #include <gp_Vec2d.hxx>
42 #include <IntAna2d_AnaIntersection.hxx>
43 #include <Precision.hxx>
44 #include <Standard_Type.hxx>
45 #include <StdFail_NotDone.hxx>
47 IMPLEMENT_STANDARD_RTTIEXT(Bisector_BisecAna,Bisector_Curve)
49 static Standard_Boolean Degenerate(Handle(GccInt_Bisec)& aBisector,
50 const Standard_Real Tolerance);
52 //=============================================================================
54 //=============================================================================
55 Bisector_BisecAna::Bisector_BisecAna()
59 //=============================================================================
60 // calcul the distance between the point and the bissectrice. +
61 // and orientation of the bissectrice. +
62 // apoint : point of passage. +
63 // abisector : calculated bissectrice. +
64 // afirstvector : first vector. \ +
65 // asecondvector : second vector./ to choose the proper sector. +
66 // adirection : shows if the bissectrice is interior or exterior. +
67 // aparameter : out : the start parameter of the bissectrice. +
68 // asense : out : the direction of the bissectrice. +
69 // astatus : out : shows if the bissectrice is preserved. +
70 //=============================================================================
71 Standard_Real Bisector_BisecAna::Distance (
72 const gp_Pnt2d& apoint,
73 const Handle(GccInt_Bisec)& abisector,
74 const gp_Vec2d& afirstvector ,
75 const gp_Vec2d& asecondvector,
76 const gp_Vec2d& VecRef,
77 const Standard_Real adirection,
78 Standard_Real& aparameter,
79 Standard_Boolean& asense,
80 Standard_Boolean& astatus,
81 Standard_Boolean IsBisecOfTwoLines)
83 astatus = Standard_True;
85 gp_Hypr2d gphyperbola;
86 gp_Parab2d gpparabola ;
87 gp_Elips2d gpellipse ;
91 Standard_Real distance = 0.;
95 GccInt_IType type = abisector->ArcType();
97 if (type == GccInt_Lin) {
98 gpline = abisector->Line();
99 aparameter = ElCLib::Parameter(gpline,apoint);
100 ElCLib::D1(aparameter,gpline,point,tangent);
102 else if (type == GccInt_Cir) {
103 gpcircle = abisector->Circle();
104 aparameter = ElCLib::Parameter(gpcircle,apoint);
105 ElCLib::D1(aparameter,gpcircle,point,tangent);
107 else if (type == GccInt_Hpr) {
108 gphyperbola = abisector->Hyperbola();
109 aparameter = ElCLib::Parameter(gphyperbola,apoint);
110 ElCLib::D1(aparameter,gphyperbola,point,tangent);
112 else if (type == GccInt_Par) {
113 gpparabola = abisector->Parabola();
114 aparameter = ElCLib::Parameter(gpparabola,apoint);
115 ElCLib::D1(aparameter,gpparabola,point,tangent);
117 else if (type == GccInt_Ell) {
118 gpellipse = abisector->Ellipse();
119 aparameter = ElCLib::Parameter(gpellipse,apoint);
120 ElCLib::D1(aparameter,gpellipse,point,tangent);
123 distance = apoint.Distance(point);
125 gp_Dir2d afirstdir (afirstvector);
126 gp_Dir2d aseconddir(asecondvector);
127 gp_Dir2d tangdir (tangent);
128 gp_Dir2d secdirrev = aseconddir.Reversed();
131 // 1st passage to learn if the curve is in the proper sector
134 // the status is determined only in case on curve ie:
135 // tangent to the bissectrice is bisectrice of two vectors.
136 Standard_Real SinPlat = 1.e-3;
137 if (Abs(afirstdir^aseconddir) < SinPlat) { //flat
138 if (afirstdir*aseconddir >= 0.0) { //tangent mixed
139 // correct if the scalar product is close to 1.
140 if (Abs(tangdir*afirstdir) < 0.5) {
141 astatus = Standard_False;
144 else { // opposed tangents.
145 // correct if the scalar product is close to 0.
146 if (Abs(tangdir*afirstdir) > 0.5 ) {
147 astatus = Standard_False;
151 else if ((afirstdir^tangdir)*(tangdir^aseconddir) < -1.E-8) {
152 astatus = Standard_False;
156 asense = Standard_True;
158 if (!IsBisecOfTwoLines)
160 // Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 Begin
161 // Replacement of -1.E-8 for a tolerance 1.e-4
162 Standard_Real aTol = 1.e-4;
164 if ((afirstdir^secdirrev)*adirection < -0.1) { // input
165 if((afirstdir^tangdir)*adirection < aTol &&
166 (secdirrev^tangdir)*adirection < aTol)
167 asense = Standard_False;
169 else if((afirstdir^secdirrev)*adirection > 0.1) { // output
170 if((afirstdir^tangdir)*adirection < aTol ||
171 (secdirrev^tangdir)*adirection < aTol)
172 asense = Standard_False;
175 if (afirstdir.Dot(secdirrev) > 0.) { // tangent
176 if ((afirstdir^tangdir)*adirection < 0.)
177 asense = Standard_False;
180 // Modified by Sergey KHROMOV - Thu Oct 31 14:16:53 2002
181 // if ((afirstdir.Dot(tangdir))*adirection > 0.) asense = Standard_False;
182 if (afirstdir.Dot(tangdir) < 0.) asense = Standard_False;
183 // Modified by Sergey KHROMOV - Thu Oct 31 14:16:54 2002
187 if (VecRef.SquareMagnitude() != 0)
189 gp_Dir2d DirRef = VecRef;
190 if (tangdir * DirRef < 0.)
191 asense = Standard_False;
194 // Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 End
200 //===========================================================================
201 // calculate the bissectrice between two curves coming from a point. +
203 // afirstcurve : \ curves the bissectrice between which will be calculated. +
204 // asecondcurve : / +
205 // apoint : point through which the bissectrice should pass. +
206 // afirstvector : \ vectors to find the sector where +
207 // asecondvector : / the bissectrice should be located. +
208 // adirection : shows the side of the bissectrice to be preserved. +
209 // tolerance : threshold starting from which the bisectrices are degenerated +
210 //===========================================================================
211 void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
212 const Handle(Geom2d_Curve)& asecondcurve ,
213 const gp_Pnt2d& apoint ,
214 const gp_Vec2d& afirstvector ,
215 const gp_Vec2d& asecondvector ,
216 const Standard_Real adirection ,
217 const GeomAbs_JoinType ajointype ,
218 const Standard_Real tolerance ,
219 const Standard_Boolean oncurve )
223 Standard_Real distanceptsol,parameter,firstparameter =0.;
224 Standard_Boolean thesense = Standard_False,sense;
225 Standard_Real distancemini;
226 Standard_Integer nbsolution;
227 Standard_Real PreConf = Precision::Confusion();
229 Handle(Standard_Type) type1 = afirstcurve->DynamicType();
230 Handle(Standard_Type) type2 = asecondcurve->DynamicType();
231 Handle(Geom2d_Curve) CurveF;
232 Handle(Geom2d_Curve) CurveE;
233 Handle(GccInt_Bisec) TheSol;
236 gp_Vec2d LineBisVec(0.,0.);
239 afirstcurve->D1(afirstcurve->LastParameter(), Pnt1, tan1);
240 asecondcurve->D1(asecondcurve->FirstParameter(), Pnt2, tan2);
243 LineBisVec = gp_Vec2d(Pnt1, Pnt2);
244 LineBisVec.Rotate(M_PI/2.);
250 if (type1 == STANDARD_TYPE(Geom2d_TrimmedCurve))
251 CurveF = Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)->BasisCurve();
253 CurveF = afirstcurve;
255 if (type2 == STANDARD_TYPE(Geom2d_TrimmedCurve))
256 CurveE = Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)->BasisCurve();
258 CurveE = asecondcurve;
260 type1 = CurveF->DynamicType();
261 type2 = CurveE->DynamicType();
262 Standard_Integer cas =0;
263 gp_Circ2d circle1,circle2;
264 gp_Lin2d line1,line2;
266 //=============================================================================
267 // Determination of the nature of arguments. +
268 //=============================================================================
270 if (type1 == STANDARD_TYPE(Geom2d_Circle)) {
271 if (type2 == STANDARD_TYPE(Geom2d_Circle)) {
273 Handle(Geom2d_Circle) C1 = Handle(Geom2d_Circle)::DownCast(CurveF);
274 circle1 = C1->Circ2d();
275 Handle(Geom2d_Circle) C2 = Handle(Geom2d_Circle)::DownCast(CurveE);
276 circle2 = C2->Circ2d();
278 else if (type2 == STANDARD_TYPE(Geom2d_Line)) {
280 Handle(Geom2d_Circle) C1 = Handle(Geom2d_Circle)::DownCast(CurveF);
281 circle1 = C1->Circ2d();
282 Handle(Geom2d_Line) L2 = Handle(Geom2d_Line)::DownCast(CurveE);
286 std::cout << "Not yet implemented" << std::endl;
289 else if (type1 == STANDARD_TYPE(Geom2d_Line)) {
290 if (type2 == STANDARD_TYPE(Geom2d_Circle)) {
292 Handle(Geom2d_Circle) C1 = Handle(Geom2d_Circle)::DownCast(CurveE);
293 circle1 = C1->Circ2d();
294 Handle(Geom2d_Line) L2 = Handle(Geom2d_Line)::DownCast(CurveF);
297 else if (type2 == STANDARD_TYPE(Geom2d_Line)) {
299 Handle(Geom2d_Line) L1 = Handle(Geom2d_Line)::DownCast(CurveF);
301 Handle(Geom2d_Line) L2 = Handle(Geom2d_Line)::DownCast(CurveE);
305 std::cout << "Not yet implemented" << std::endl;
309 std::cout << "Not yet implemented" << std::endl;
314 //=============================================================================
315 // Bissectrice circle - circle. +
316 //=============================================================================
319 Standard_Real radius1 = circle1.Radius();
320 Standard_Real radius2 = circle2.Radius();
322 //-----------------------------------------------------
323 // Particular case when two circles are mixed.
324 //-----------------------------------------------------
325 if (circle1.Location().IsEqual(circle2.Location(),PreConf)&&
326 (Abs(radius1 - radius2) <= PreConf)){
327 gp_Pnt2d P1 = afirstcurve ->Value(afirstcurve ->LastParameter());
328 gp_Pnt2d P2 = asecondcurve->Value(asecondcurve->FirstParameter());
331 PMil = gp_Pnt2d((P1.X() + P2.X())/2.,
332 (P1.Y() + P2.Y())/2.);
333 // Modified by skv - Fri Jul 1 16:23:32 2005 IDEM(Airbus) Begin
334 // line = gp_Lin2d(PMil,
335 // gp_Dir2d(circle1.Location().X() - PMil.X(),
336 // circle1.Location().Y() - PMil.Y()));
337 if (!circle1.Location().IsEqual(PMil,PreConf)) {
338 // PMil doesn't coincide with the circle location.
339 line = gp_Lin2d(PMil,
340 gp_Dir2d(circle1.Location().X() - PMil.X(),
341 circle1.Location().Y() - PMil.Y()));
342 } else if (radius1 >= PreConf) {
343 // PMil coincides with the circle location and radius is greater then 0.
344 line = gp_Lin2d(circle1.Location(),
345 gp_Dir2d(P1.Y() - circle1.Location().Y(),
346 circle1.Location().X() - P1.X()));
348 // radius is equal to 0. No matter what direction to chose.
349 line = gp_Lin2d(circle1.Location(), gp_Dir2d(1., 0.));
351 // Modified by skv - Fri Jul 1 16:23:32 2005 IDEM(Airbus) End
352 Handle(GccInt_Bisec) solution = new GccInt_BLine(line);
353 sense = Standard_False;
354 // Modified by skv - Tue Feb 15 17:51:29 2005 Integration Begin
355 // distanceptsol = Distance(apoint,solution,
356 // afirstvector,asecondvector,
357 // adirection,parameter,sense,ok);
359 distanceptsol = Distance(apoint,solution,
360 tan2,tan1,LineBisVec,
361 adirection,parameter,sense,ok);
363 distanceptsol = Distance(apoint,solution,
364 afirstvector,asecondvector,LineBisVec,
365 adirection,parameter,sense,ok);
366 // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
367 Handle(Geom2d_Curve) bisectorcurve = new Geom2d_Line(line);
369 thebisector =new Geom2d_TrimmedCurve(bisectorcurve,
371 - Precision::Infinite());
373 Standard_Real parameter2;
374 parameter2 = ElCLib::Parameter(line,circle1.Location());
376 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
381 } //end of case mixed circles.
383 if (radius1 < radius2) {
384 gp_Circ2d circle = circle1;
388 Standard_Real radius = radius1;
393 // small reframing of circles. in the case when the circles
394 // are OnCurve , if they are almost tangent they become tangent.
395 Standard_Real EntreAxe = circle1.Location().Distance(circle2.Location());
396 Standard_Real D1 = 0.5*(radius1 - EntreAxe - radius2);
397 Standard_Boolean CirclesTangent = Standard_False;
399 // Modified by Sergey KHROMOV - Thu Oct 31 12:42:21 2002 End
400 // if ( oncurve && Abs(D1) < PreConf) {
401 if ( oncurve && Abs(D1) < PreConf && tan1.IsParallel(tan2, 1.e-8)) {
402 // Modified by Sergey KHROMOV - Thu Oct 31 12:42:22 2002 Begin
403 // C2 included in C1 and tangent.
404 circle1.SetRadius(radius1 - D1);
405 circle2.SetRadius(radius2 + D1);
406 CirclesTangent = Standard_True;
409 D1 = 0.5*(radius1 - EntreAxe + radius2);
410 // Modified by Sergey KHROMOV - Thu Oct 31 12:44:24 2002 Begin
411 // if (oncurve && Abs(D1) < PreConf) {
412 if (oncurve && Abs(D1) < PreConf && tan1.IsParallel(tan2, 1.e-8)) {
413 // Modified by Sergey KHROMOV - Thu Oct 31 12:44:25 2002 End
414 // C2 and C1 tangent and disconnected.
415 circle1.SetRadius(radius1 - D1);
416 circle2.SetRadius(radius2 - D1);
417 CirclesTangent = Standard_True;
419 } // end of reframing.
421 GccAna_Circ2dBisec Bisector(circle1,circle2);
423 distancemini = Precision::Infinite();
425 if (Bisector.IsDone()) {
426 nbsolution = Bisector.NbSolutions();
427 for (Standard_Integer i = 1; i <= nbsolution; i++) {
428 Handle(GccInt_Bisec) solution = Bisector.ThisSolution(i);
429 Degenerate(solution,tolerance);
430 sense = Standard_True;
432 distanceptsol = Distance(apoint,solution,
433 tan1,tan2,LineBisVec,
434 adirection,parameter,sense,ok);
436 else {ok = Standard_True;}
439 sense = Standard_False;
440 // Modified by skv - Tue Feb 15 17:51:29 2005 Integration Begin
441 // distanceptsol = Distance(apoint,solution,
442 // afirstvector,asecondvector,
443 // adirection,parameter,sense,ok);
445 distanceptsol = Distance(apoint,solution,
446 tan2,tan1,LineBisVec,
447 adirection,parameter,sense,ok);
449 distanceptsol = Distance(apoint,solution,
450 afirstvector,asecondvector,LineBisVec,
451 adirection,parameter,sense,ok);
452 // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
453 if (distanceptsol <= distancemini) {
455 firstparameter = parameter;
457 distancemini = distanceptsol;
461 if (!TheSol.IsNull()) {
462 Handle(Geom2d_Curve) bisectorcurve;
463 GccInt_IType type = TheSol->ArcType();
464 if (type == GccInt_Lin) {
465 gp_Lin2d gpline = TheSol->Line();
466 bisectorcurve = new Geom2d_Line(gpline);
468 Standard_Real secondparameter = Precision::Infinite();
469 if (!thesense) secondparameter = - Precision::Infinite();
472 // bisectrice right and oncurve
473 // is cut between two circle of the same radius if circles are tangent.
475 // if tangent flat and the bissectrice at the side of the concavity
476 // of one of the circles. the bissectrice is a segment of the point common to
477 // first of 2 centers of circle that it meets.
478 // in this case it is important to set a segmnent for
479 // intersection in Tool2d.
481 if (CirclesTangent) {
482 // Modified by skv - Tue Apr 13 17:23:31 2004 IDEM(Airbus) Begin
483 // Trying to correct the line if the distance between it
484 // and the reference point is too big.
485 if (distancemini > tolerance) {
486 gp_Pnt2d aPloc = gpline.Location();
487 gp_Dir2d aNewDir(apoint.XY() - aPloc.XY());
488 gp_Lin2d aNewLin(aPloc, aNewDir);
489 gp_Pnt2d aCC2 = circle2.Location();
490 Standard_Real aNewDMin = aNewLin.Distance(apoint);
491 Standard_Real aTolConf = 1.e-3;
492 // Hope, aNewDMin is equal to 0...
494 if (aNewLin.Distance(aCC2) <= aTolConf) {
495 distancemini = aNewDMin;
496 firstparameter = ElCLib::Parameter(aNewLin, apoint);
497 bisectorcurve = new Geom2d_Line(aNewLin);
500 // Modified by skv - Tue Apr 13 17:23:32 2004 IDEM(Airbus) End
501 if (tan1.Dot(tan2) < 0.) {
502 // flat and not turn back.
503 Standard_Real Par1 = ElCLib::Parameter(gpline, circle1.Location());
504 Standard_Real Par2 = ElCLib::Parameter(gpline, circle2.Location());
505 Standard_Real MinPar = Min(Par1,Par2);
506 Standard_Real MaxPar = Max(Par1,Par2);
509 if (MaxPar < firstparameter)
510 secondparameter = MaxPar - 1.E-8;
511 else if (MinPar < firstparameter)
512 secondparameter = MinPar - 1.E-8;
515 if (MinPar > firstparameter)
516 secondparameter = MinPar + 1.E-8;
517 else if (MaxPar > firstparameter)
518 secondparameter = MaxPar + 1.E-8;
524 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
528 else if (type == GccInt_Cir) {
529 bisectorcurve = new Geom2d_Circle(TheSol->Circle());
531 thebisector = new Geom2d_TrimmedCurve
532 (bisectorcurve,firstparameter-2.0*M_PI,firstparameter,thesense);
534 thebisector = new Geom2d_TrimmedCurve
535 (bisectorcurve,firstparameter,firstparameter+2.0*M_PI,thesense);
537 else if (type == GccInt_Hpr) {
538 bisectorcurve = new Geom2d_Hyperbola(TheSol->Hyperbola());
540 thebisector = new Geom2d_TrimmedCurve
541 (bisectorcurve,firstparameter, - Precision::Infinite());
543 thebisector = new Geom2d_TrimmedCurve
544 (bisectorcurve,firstparameter,Precision::Infinite());
546 else if (type == GccInt_Ell) {
547 bisectorcurve = new Geom2d_Ellipse(TheSol->Ellipse());
549 thebisector = new Geom2d_TrimmedCurve
550 (bisectorcurve,firstparameter-2.0*M_PI,firstparameter,thesense);
552 thebisector = new Geom2d_TrimmedCurve
553 (bisectorcurve,firstparameter,firstparameter+2.0*M_PI,thesense);
560 //=============================================================================
561 // Bissectrice circle - straight. +
562 //=============================================================================
565 // small reframing of circles. in case OnCurve.
566 // If the circle and the straight line are almost tangent they become tangent.
568 Standard_Real radius1 = circle1.Radius();
569 Standard_Real D1 = (line2.Distance(circle1.Location()) - radius1);
570 // Modified by Sergey KHROMOV - Wed Oct 30 14:48:43 2002 Begin
571 // if (Abs(D1) < PreConf) {
572 if (Abs(D1) < PreConf && tan1.IsParallel(tan2, 1.e-8)) {
573 // Modified by Sergey KHROMOV - Wed Oct 30 14:48:44 2002 End
574 circle1.SetRadius(radius1+D1);
578 GccAna_CircLin2dBisec Bisector(circle1,line2);
580 distancemini = Precision::Infinite();
582 if (Bisector.IsDone()) {
583 nbsolution = Bisector.NbSolutions();
584 for (Standard_Integer i = 1; i <= nbsolution; i++) {
585 Handle(GccInt_Bisec) solution = Bisector.ThisSolution(i);
586 Degenerate(solution,tolerance);
587 sense = Standard_True;
588 distanceptsol = Distance(apoint,solution,tan1,tan2,LineBisVec,
589 adirection,parameter,sense,ok);
590 if (ok || !oncurve) {
591 sense = Standard_False;
592 // Modified by skv - Tue Feb 15 17:51:29 2005 Integration Begin
593 // distanceptsol = Distance(apoint,solution,
594 // afirstvector,asecondvector,
595 // adirection,parameter,sense,ok);
597 distanceptsol = Distance(apoint,solution,
598 tan2,tan1,LineBisVec,
599 adirection,parameter,sense,ok);
601 distanceptsol = Distance(apoint,solution,
602 afirstvector,asecondvector,LineBisVec,
603 adirection,parameter,sense,ok);
604 // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
605 if (distanceptsol <= distancemini) {
607 firstparameter = parameter;
609 distancemini = distanceptsol+1.e-8;
613 if (!TheSol.IsNull()) {
614 GccInt_IType type = TheSol->ArcType();
615 Handle(Geom2d_Curve) bisectorcurve;
616 if (type == GccInt_Lin) {
617 // -----------------------------------------------------------------
618 // If the bisectrice is a line
619 // => the straight line is tangent to the circle.
620 // It the part of bisectrice concerned is at the side of the center.
621 // => the bisectrice is limited by the point and the center of the circle.
622 // Note : In the latter case the bisectrice is a degenerated parabole.
623 // -----------------------------------------------------------------
624 gp_Pnt2d circlecenter;
626 Standard_Real secondparameter;
628 circlecenter = circle1.Location();
629 gpline = TheSol->Line();
630 secondparameter = ElCLib::Parameter(gpline, circlecenter);
631 bisectorcurve = new Geom2d_Line(gpline);
634 if (secondparameter > firstparameter) {
635 secondparameter = - Precision::Infinite();
638 secondparameter = secondparameter - 1.E-8;
642 if (secondparameter < firstparameter) {
643 secondparameter = Precision::Infinite();
646 secondparameter = secondparameter + 1.E-8;
650 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
654 else if (type == GccInt_Par) {
655 bisectorcurve = new Geom2d_Parabola(TheSol->Parabola());
656 gp_Pnt2d apex = bisectorcurve->Value(0.);
657 gp_Pnt2d firstpnt = bisectorcurve->Value(firstparameter);
658 Standard_Real ChordLen = apex.Distance(firstpnt);
659 const Standard_Real TolPar = 1.e-5;
660 Standard_Real secondparameter = Precision::Infinite();
663 if (ajointype == GeomAbs_Intersection &&
664 TolPar < firstparameter &&
665 ChordLen >= circle1.Radius()) //first parameter is too far from peak of parabola
666 secondparameter = 0.;
667 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
673 if (ajointype == GeomAbs_Intersection &&
674 firstparameter < -TolPar &&
675 ChordLen >= circle1.Radius()) //first parameter is too far from peak of parabola
676 secondparameter = 0.;
677 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
687 //=============================================================================
688 // Bissectrice straight - straight. +
689 //=============================================================================
691 gp_Dir2d Direc1(line1.Direction());
692 gp_Dir2d Direc2(line2.Direction());
694 distancemini = Precision::Infinite();
696 // Modified by Sergey KHROMOV - Tue Sep 10 15:58:43 2002 Begin
697 // Change to the same criterion as in MAT2d_Circuit.cxx:
698 // method MAT2d_Circuit::InitOpen(..)
699 // if (Direc1.IsParallel(Direc2,RealEpsilon())) {
700 if (Direc1.IsParallel(Direc2,1.e-8)) {
701 // Modified by Sergey KHROMOV - Tue Sep 10 15:58:45 2002 End
702 if (line1.Distance(line2.Location())/2. <= Precision::Confusion())
703 line = gp_Lin2d(apoint,gp_Dir2d(-line1.Direction().Y(),
704 line1.Direction().X()));
706 line = gp_Lin2d(apoint,line2.Direction());
708 Handle(GccInt_Bisec) solution = new GccInt_BLine(line);
709 // Modified by skv - Wed Jul 7 17:21:09 2004 IDEM(Airbus) Begin
710 // sense = Standard_True;
711 // distanceptsol = Distance(apoint,solution,
713 // adirection,parameter,sense,ok);
715 // if (ok || !oncurve) {
716 sense = Standard_False;
717 // Modified by skv - Tue Feb 15 17:51:29 2005 Integration Begin
718 // distanceptsol = Distance(apoint,solution,
719 // afirstvector,asecondvector,
720 // adirection,parameter,sense,ok);
722 distanceptsol = Distance(apoint,solution,
723 tan2,tan1,LineBisVec,
724 adirection,parameter,sense,ok);
726 distanceptsol = Distance(apoint,solution,
727 afirstvector,asecondvector,LineBisVec,
728 adirection,parameter,sense,ok);
729 // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
730 // if (distanceptsol <= distancemini) {
731 firstparameter = parameter;
732 Handle(Geom2d_Curve) bisectorcurve;
733 bisectorcurve = new Geom2d_Line(line);
735 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
737 - Precision::Infinite());
739 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
741 Precision::Infinite());
744 // Modified by skv - Wed Jul 7 17:21:09 2004 IDEM(Airbus) End
747 gp_Lin2d l(apoint,gp_Dir2d(Direc2.XY()-Direc1.XY()));
748 Handle(GccInt_Bisec) solution = new GccInt_BLine(l);
749 Standard_Boolean isOk;
750 sense = Standard_False;
751 // Modified by skv - Tue Feb 15 17:51:29 2005 Integration Begin
752 // distanceptsol = Distance(apoint,solution,
753 // afirstvector,asecondvector,
754 // adirection,parameter,sense,ok);
756 distanceptsol = Distance(apoint,solution,
757 tan2,tan1,LineBisVec,
758 adirection,parameter,sense, isOk);
760 distanceptsol = Distance(apoint,solution,
761 afirstvector,asecondvector,LineBisVec,
762 adirection,parameter,sense, isOk, Standard_True);
763 // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
764 if (isOk || !oncurve) {
766 distancemini = distanceptsol;
768 TheSol = new GccInt_BLine(l);
769 Handle(Geom2d_Curve) bisectorcurve;
770 bisectorcurve = new Geom2d_Line(TheSol->Line());
772 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
773 0.,- Precision::Infinite());
775 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
776 0., Precision::Infinite());
782 throw StdFail_NotDone();
788 //===========================================================================
789 // calculate the bissectrice between a curve and a point and starting in a point. +
791 // afirstcurve : \ curve and point the bissectrice between which is calculated +
792 // asecondpoint : / +
793 // apoint : point through which the bissectrice should pass. +
794 // afirstvector : \ vectors to determine the sector in which +
795 // asecondvector : / the bissectrice should be located. +
796 // adirection : shows the side of the bissectrice to be preserved. +
797 // tolerance : threshold starting from which the bisectrices are degenerated+
798 //===========================================================================
800 void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
801 const Handle(Geom2d_Point)& asecondpoint ,
802 const gp_Pnt2d& apoint ,
803 const gp_Vec2d& afirstvector ,
804 const gp_Vec2d& asecondvector,
805 const Standard_Real adirection ,
806 const Standard_Real tolerance ,
807 const Standard_Boolean oncurve )
810 Standard_Boolean thesense = Standard_False,sense;
811 Standard_Real distanceptsol,parameter,firstparameter =0.,secondparameter;
812 gp_Vec2d VecRef(0.,0.);
813 Handle(Geom2d_Curve) curve;
814 Handle(GccInt_Bisec) TheSol;
818 gp_Pnt2d circlecenter;
820 Standard_Integer cas = 0;
822 Handle(Standard_Type) aFirstCurveType = afirstcurve->DynamicType();
824 if (aFirstCurveType == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
825 curve = Handle(Geom2d_TrimmedCurve)::DownCast (afirstcurve)->BasisCurve();
831 aFirstCurveType = curve->DynamicType();
832 const gp_Pnt2d aPoint(asecondpoint->Pnt2d());
834 if (aFirstCurveType == STANDARD_TYPE(Geom2d_Circle)) {
836 Handle(Geom2d_Circle) C1 = Handle(Geom2d_Circle)::DownCast(curve);
837 circle = C1->Circ2d();
839 else if (aFirstCurveType == STANDARD_TYPE(Geom2d_Line)) {
841 Handle(Geom2d_Line) L1 = Handle(Geom2d_Line)::DownCast(curve);
845 std::cout << "Not yet implemented" << std::endl;
850 //=============================================================================
851 // Bissectrice point - circle. +
852 //=============================================================================
854 GccAna_CircPnt2dBisec Bisector(circle, asecondpoint->Pnt2d(), tolerance);
855 Standard_Real distancemini = Precision::Infinite();
856 if (Bisector.IsDone()) {
857 Standard_Integer nbsolution = Bisector.NbSolutions();
858 for (Standard_Integer i = 1; i <= nbsolution; i++) {
859 Handle(GccInt_Bisec) solution = Bisector.ThisSolution(i);
860 Degenerate(solution,tolerance);
861 sense = Standard_False;
862 distanceptsol = Distance(apoint,solution,
863 afirstvector,asecondvector,VecRef,
864 adirection,parameter,sense,ok);
866 if (distanceptsol <= distancemini) {
868 firstparameter = parameter;
870 distancemini = distanceptsol;
873 if (!TheSol.IsNull()) {
874 GccInt_IType aSolType = TheSol->ArcType();
875 Handle(Geom2d_Curve) bisectorcurve;
876 if (aSolType == GccInt_Lin) {
878 // ----------------------------------------------------------------------------
879 // If the bisectrice is a line
880 // => the point is on the circle.
881 // If the part of bisectrice concerned is at the side of the center.
882 // => the bisectrice is limited by the point and the center of the circle.
883 // Note : In this latter case the bisectrice is actually an ellipse of small null axis.
884 // ----------------------------------------------------------------------------
886 circlecenter = circle.Location();
887 line = TheSol->Line();
888 secondparameter = ElCLib::Parameter(line, circlecenter);
889 bisectorcurve = new Geom2d_Line(line);
892 if (secondparameter > firstparameter) {
893 secondparameter = - Precision::Infinite();
896 secondparameter = secondparameter - 1.E-8;
900 if (secondparameter < firstparameter) {
901 secondparameter = Precision::Infinite();
904 secondparameter = secondparameter + 1.E-8;
908 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
913 else if (aSolType == GccInt_Cir) {
914 bisectorcurve = new Geom2d_Circle(TheSol->Circle());
916 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
917 firstparameter-2.0*M_PI,
921 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
923 firstparameter+2.0*M_PI,
926 else if (aSolType == GccInt_Hpr) {
927 bisectorcurve=new Geom2d_Hyperbola(TheSol->Hyperbola());
929 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
931 - Precision::Infinite());
933 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
935 Precision::Infinite());
937 else if (aSolType == GccInt_Ell) {
938 bisectorcurve = new Geom2d_Ellipse(TheSol->Ellipse());
940 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
941 firstparameter-2.0*M_PI,
945 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
947 firstparameter+2.0*M_PI,
955 //=============================================================================
956 // Bissectrice point - straight. +
957 //=============================================================================
959 GccAna_LinPnt2dBisec Bisector(line,asecondpoint->Pnt2d());
962 gp_Vec2d V(line.Direction());
966 Handle(GccInt_Bisec) solution = Bisector.ThisSolution();
967 Degenerate(solution,tolerance);
968 GccInt_IType type = solution->ArcType();
969 Handle(Geom2d_Curve) bisectorcurve;
971 if (type == GccInt_Lin) {
972 bisectorcurve = new Geom2d_Line(solution->Line());
974 else if (type == GccInt_Par) {
975 bisectorcurve = new Geom2d_Parabola(solution->Parabola());
977 sense = Standard_False;
978 distanceptsol = Distance(apoint,solution,
979 afirstvector,asecondvector,VecRef,
980 adirection,parameter,sense,ok);
982 if (ok || !oncurve) {
983 firstparameter = parameter;
988 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
990 - Precision::Infinite());
992 thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
994 Precision::Infinite());
1000 std::cout << "Not yet implemented" << std::endl;
1007 //===========================================================================
1008 // calculate the bissectrice between a curve and a point starting at a point. +
1010 // afirstpoint : \ curves between which the +
1011 // asecondcurve : / bissectrice is calculated. +
1012 // apoint : point through which the bissectrice should pass. +
1013 // afirstvector : \ vectors to determine the secteur in which +
1014 // asecondvector : / the bissectrice should be located. +
1015 // adirection : shows the side of the bissectrice to be preserved. +
1016 // tolerance : threshold at which the bisectrices become degenerated+
1017 //===========================================================================
1019 void Bisector_BisecAna::Perform(const Handle(Geom2d_Point)& afirstpoint ,
1020 const Handle(Geom2d_Curve)& asecondcurve ,
1021 const gp_Pnt2d& apoint ,
1022 const gp_Vec2d& afirstvector ,
1023 const gp_Vec2d& asecondvector,
1024 const Standard_Real adirection ,
1025 // const Standard_Real tolerance ,
1026 const Standard_Real ,
1027 const Standard_Boolean oncurve )
1030 Standard_Real adirectionreverse = - adirection;
1031 Perform(asecondcurve ,
1037 // Modified by skv - Tue Feb 15 17:51:29 2005 Integration Begin
1039 // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
1043 //===========================================================================
1044 // calculate the bissectrice between two points starting at a point. +
1046 // afirstpoint : \ curves between which the +
1047 // asecondpoint : / bissectrice is calculated. +
1048 // apoint : point through which the bissectrice should pass. +
1049 // afirstvector : \ vectors to determine the sector in which the +
1050 // asecondvector : / bissectrice should be located. +
1051 // adirection : shows the side of the bissectrice to be preserved. +
1052 //===========================================================================
1054 void Bisector_BisecAna::Perform(const Handle(Geom2d_Point)& afirstpoint ,
1055 const Handle(Geom2d_Point)& asecondpoint ,
1056 const gp_Pnt2d& apoint ,
1057 const gp_Vec2d& afirstvector ,
1058 const gp_Vec2d& asecondvector,
1059 const Standard_Real adirection ,
1060 // const Standard_Real tolerance ,
1061 const Standard_Real ,
1062 const Standard_Boolean oncurve )
1064 Standard_Boolean sense,ok;
1065 Standard_Real parameter;
1066 gp_Vec2d VecRef(0.,0.);
1068 GccAna_Pnt2dBisec bisector(afirstpoint->Pnt2d(),asecondpoint->Pnt2d());
1069 gp_Lin2d line = bisector.ThisSolution();
1070 Handle(GccInt_Bisec) solution = new GccInt_BLine(line);
1072 sense = Standard_False;
1073 Distance(apoint,solution,
1074 afirstvector,asecondvector,VecRef,
1075 adirection,parameter,sense,ok);
1076 if (ok || !oncurve) {
1077 Handle(Geom2d_Curve) bisectorcurve = new Geom2d_Line(line);
1079 thebisector=new Geom2d_TrimmedCurve(bisectorcurve,
1080 parameter,- Precision::Infinite());
1082 thebisector =new Geom2d_TrimmedCurve(bisectorcurve,
1083 parameter,Precision::Infinite());
1087 //=============================================================================
1088 //function : IsExtendAtStart
1090 //=============================================================================
1091 Standard_Boolean Bisector_BisecAna::IsExtendAtStart() const
1093 return Standard_False;
1096 //=============================================================================
1097 //function : IsExtendAtEnd
1099 //=============================================================================
1100 Standard_Boolean Bisector_BisecAna::IsExtendAtEnd() const
1102 return Standard_False;
1105 //=============================================================================
1106 //function : SetTrim
1107 //purpose : Restriction of the bissectrice by the domain of the curve Cu.
1108 // The domain of the curve is the set of points that are closer to the
1109 // than to its extremities.
1110 // For the calculation the domain is extended. Extension of Epsilon1 of the
1111 // First and the Last parameter of the curve.
1112 //=============================================================================
1113 //void Bisector_BisecAna::SetTrim(const Handle(Geom2d_Curve)& Cu)
1114 void Bisector_BisecAna::SetTrim(const Handle(Geom2d_Curve)& )
1117 Handle(Standard_Type) Type;
1118 Handle(Geom2d_Curve) TheCurve;
1119 Handle(Geom2d_Circle) CircleCu;
1120 Handle(Geom2d_Line) LineCu;
1121 Handle(Geom2d_Curve) FirstLimit;
1122 Handle(Geom2d_Curve) LastLimit;
1125 gp_Pnt2d P, PFirst, PLast, FirstPointBisector, Center;
1126 gp_Vec2d TanFirst, TanLast;
1128 IntRes2d_Domain FirstDomain;
1129 IntRes2d_Domain LastDomain ;
1131 Standard_Real UFirst, ULast, UB1, UB2;
1132 Standard_Real UBisInt1, UBisInt2, Utrim;
1133 Standard_Real Distance;
1134 Standard_Real Radius;
1136 Standard_Real Epsilon1 = 1.E-6; // Epsilon sur le parametre de la courbe.
1137 Standard_Real Tolerance = 1.E-8; // Tolerance pour les intersections.
1139 Type = Cu->DynamicType();
1141 if (Type == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
1142 TheCurve = Handle(Geom2d_TrimmedCurve)::DownCast(Cu)->BasisCurve();
1143 Type = TheCurve->DynamicType();
1149 if (Type == STANDARD_TYPE(Geom2d_Circle)) {
1150 CircleCu = Handle(Geom2d_Circle)::DownCast(TheCurve);
1153 LineCu = Handle(Geom2d_Line)::DownCast(TheCurve);
1156 // Recuperation de UFirst, ULast.
1157 // -------------------------------
1158 UFirst = Cu->FirstParameter();
1159 ULast = Cu->LastParameter();
1161 // Creation des lignes Limites du domaine si elles existent.
1162 // et Determination de leur domaine d intersection.
1163 // ---------------------------------------------------------
1164 if (Type == STANDARD_TYPE(Geom2d_Circle)) {
1165 CircleCu->D1(UFirst,PFirst,TanFirst);
1166 CircleCu->D1(ULast ,PLast ,TanLast);
1167 Radius = CircleCu->Radius();
1169 if (PFirst.Distance(PLast) > 2.*Epsilon1 && Radius > Epsilon1) {
1170 Center = CircleCu->Location();
1171 P = PFirst.Translated( - (Epsilon1/Radius)*TanFirst );
1173 FirstLimit = new Geom2d_Line(P,
1174 gp_Dir2d(PFirst.X() - Center.X(),
1175 PFirst.Y() - Center.Y()));
1176 P = PLast .Translated( (Epsilon1/Radius)*TanLast );
1178 LastLimit = new Geom2d_Line(P,
1179 gp_Dir2d(PLast.X() - Center.X(),
1180 PLast.Y() - Center.Y()));
1182 Geom2dAdaptor_Curve AFirstLimit(FirstLimit);
1183 Geom2dAdaptor_Curve ALastLimit (LastLimit);
1184 Geom2dInt_GInter Intersect(AFirstLimit , FirstDomain,
1185 ALastLimit , LastDomain ,
1186 Tolerance , Tolerance );
1188 if (Intersect.IsDone() && !Intersect.IsEmpty()) {
1189 if (Intersect.NbPoints() >= 1) {
1190 FirstDomain.SetValues(Intersect.Point(1).Value(),
1191 Intersect.Point(1).ParamOnFirst(),
1192 Tolerance,Standard_True);
1193 LastDomain. SetValues(Intersect.Point(1).Value(),
1194 Intersect.Point(1).ParamOnSecond(),
1195 Tolerance,Standard_True);
1200 else if (Type == STANDARD_TYPE(Geom2d_Line)) {
1201 gpLine = LineCu->Lin2d();
1202 if (UFirst > - Precision::Infinite()){
1203 P = LineCu->Value(UFirst - Epsilon1);
1204 FirstLimit = new Geom2d_Line(gpLine.Normal(P)) ;
1206 if (ULast < Precision::Infinite()) {
1207 P = LineCu->Value(ULast + Epsilon1);
1208 LastLimit = new Geom2d_Line(gpLine.Normal(P));
1212 throw Standard_NotImplemented();
1215 // Determination domaine d intersection de la Bissectrice.
1216 // -------------------------------------------------------
1217 UB1 = thebisector->FirstParameter();
1218 UB2 = thebisector->LastParameter();
1221 Handle(Geom2d_Curve) BasisCurve = thebisector->BasisCurve();
1222 Handle(Standard_Type) Type1 = BasisCurve->DynamicType();
1223 gp_Parab2d gpParabola;
1224 gp_Hypr2d gpHyperbola;
1225 Standard_Real Focus;
1226 Standard_Real Limit = 50000.;
1227 if (Type1 == STANDARD_TYPE(Geom2d_Parabola)) {
1228 gpParabola = Handle(Geom2d_Parabola)::DownCast(BasisCurve)->Parab2d();
1229 Focus = gpParabola.Focal();
1230 Standard_Real Val1 = Sqrt(Limit*Focus);
1231 Standard_Real Val2 = Sqrt(Limit*Limit);
1232 UB2 = (Val1 <= Val2 ? Val1:Val2);
1234 else if (Type1 == STANDARD_TYPE(Geom2d_Hyperbola)) {
1235 gpHyperbola = Handle(Geom2d_Hyperbola)::DownCast(BasisCurve)->Hypr2d();
1236 Standard_Real Majr = gpHyperbola.MajorRadius();
1237 Standard_Real Minr = gpHyperbola.MinorRadius();
1238 Standard_Real Valu1 = Limit/Majr;
1239 Standard_Real Valu2 = Limit/Minr;
1240 Standard_Real Val1 = Log(Valu1+Sqrt(Valu1*Valu1-1));
1241 Standard_Real Val2 = Log(Valu2+Sqrt(Valu2*Valu2+1));
1242 UB2 = (Val1 <= Val2 ? Val1:Val2);
1246 IntRes2d_Domain DomainBisector(thebisector->Value(UB1), UB1, Tolerance,
1247 thebisector->Value(UB2), UB2, Tolerance);
1249 if (thebisector->BasisCurve()->IsPeriodic()) {
1250 DomainBisector.SetEquivalentParameters(0.0,2.*M_PI);
1252 FirstPointBisector = thebisector->Value(UB1);
1255 // Intersection Bisectrice avec FirstLimit => UBisInt1.
1256 // ----------------------------------------------------
1257 UBisInt1 = Precision::Infinite();
1258 if (!FirstLimit.IsNull()) {
1259 Geom2dAdaptor_Curve AdapBis (thebisector);
1260 Geom2dAdaptor_Curve AFirstLimit(FirstLimit);
1261 Geom2dInt_GInter Intersect(AFirstLimit , FirstDomain,
1262 AdapBis , DomainBisector,
1263 Tolerance , Tolerance );
1265 if (Intersect.IsDone() && !Intersect.IsEmpty()) {
1266 for (Standard_Integer i=1; i<=Intersect.NbPoints(); i++) {
1267 Distance = FirstPointBisector.Distance(Intersect.Point(i).Value());
1268 if (Distance > 2.*Tolerance) {
1269 UBisInt1 = Intersect.Point(i).ParamOnSecond();
1275 // Intersection Bisectrice avec LastLimit => UBisInt2.
1276 // ---------------------------------------------------
1277 UBisInt2 = Precision::Infinite();
1278 if (!LastLimit.IsNull()) {
1279 Geom2dAdaptor_Curve AdapBis (thebisector);
1280 Geom2dAdaptor_Curve ALastLimit (LastLimit);
1281 Geom2dInt_GInter Intersect(ALastLimit , LastDomain ,
1282 AdapBis , DomainBisector,
1283 Tolerance , Tolerance );
1285 if (Intersect.IsDone() && !Intersect.IsEmpty()) {
1286 for (Standard_Integer i=1; i<=Intersect.NbPoints(); i++) {
1287 Distance = FirstPointBisector.Distance(Intersect.Point(i).Value());
1288 if (Distance > 2.*Tolerance) {
1289 UBisInt2 = Intersect.Point(i).ParamOnSecond();
1295 // Restriction de la Bissectrice par le point d intersection de plus petit
1297 //------------------------------------------------------------------------
1298 Utrim = (UBisInt1 < UBisInt2) ? UBisInt1 : UBisInt2;
1300 if (Utrim < UB2 && Utrim > UB1) thebisector->SetTrim(UB1,Utrim);
1304 void Bisector_BisecAna::SetTrim(const Standard_Real uf, const Standard_Real ul)
1306 thebisector->SetTrim(uf, ul);
1308 //=============================================================================
1309 //function : Reverse
1311 //=============================================================================
1312 void Bisector_BisecAna::Reverse()
1314 thebisector->Reverse();
1317 //=============================================================================
1318 //function : ReversedParameter
1320 //=============================================================================
1321 Standard_Real Bisector_BisecAna::ReversedParameter(const Standard_Real U) const
1323 return thebisector->ReversedParameter(U);
1326 //=============================================================================
1329 //=============================================================================
1330 Standard_Boolean Bisector_BisecAna::IsCN(const Standard_Integer N) const
1332 return thebisector->IsCN(N);
1335 //=============================================================================
1338 //=============================================================================
1339 Handle(Geom2d_Geometry) Bisector_BisecAna::Copy() const
1341 Handle(Bisector_BisecAna) C = new Bisector_BisecAna();
1342 C->Init (Handle(Geom2d_TrimmedCurve)::DownCast(thebisector->Copy()));
1346 //=============================================================================
1347 //function : Transform
1349 //=============================================================================
1350 void Bisector_BisecAna::Transform(const gp_Trsf2d& T)
1352 thebisector->Transform(T);
1355 //=============================================================================
1356 //function : FirstParameter
1358 //=============================================================================
1359 Standard_Real Bisector_BisecAna::FirstParameter() const
1361 // modified by NIZHNY-EAP Thu Feb 3 17:23:42 2000 ___BEGIN___
1362 // return thebisector->BasisCurve()->FirstParameter();
1363 return thebisector->FirstParameter();
1364 // modified by NIZHNY-EAP Thu Feb 3 17:23:48 2000 ___END___
1367 //=============================================================================
1368 //function : LastParameter
1370 //=============================================================================
1371 Standard_Real Bisector_BisecAna::LastParameter() const
1373 return thebisector->LastParameter();
1376 //=============================================================================
1377 //function : IsClosed
1379 //=============================================================================
1380 Standard_Boolean Bisector_BisecAna::IsClosed() const
1382 return thebisector->BasisCurve()->IsClosed();
1385 //=============================================================================
1386 //function : IsPeriodic
1388 //=============================================================================
1389 Standard_Boolean Bisector_BisecAna::IsPeriodic() const
1391 return thebisector->BasisCurve()->IsPeriodic();
1394 //=============================================================================
1395 //function : Continuity
1397 //=============================================================================
1398 GeomAbs_Shape Bisector_BisecAna::Continuity() const
1400 return thebisector->Continuity();
1403 //=============================================================================
1406 //=============================================================================
1407 void Bisector_BisecAna::D0(const Standard_Real U, gp_Pnt2d& P) const
1409 thebisector->BasisCurve()->D0(U,P);
1412 //=============================================================================
1415 //=============================================================================
1416 void Bisector_BisecAna::D1(const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const
1418 thebisector->BasisCurve()->D1(U,P,V1);
1420 //=============================================================================
1423 //=============================================================================
1424 void Bisector_BisecAna::D2(const Standard_Real U,
1429 thebisector->BasisCurve()->D2(U,P,V1,V2);
1431 //=============================================================================
1434 //=============================================================================
1435 void Bisector_BisecAna::D3(const Standard_Real U,
1441 thebisector->BasisCurve()->D3(U,P,V1,V2,V3);
1443 //=============================================================================
1446 //=============================================================================
1447 gp_Vec2d Bisector_BisecAna::DN(const Standard_Real U, const Standard_Integer N) const
1449 return thebisector->BasisCurve()->DN (U, N);
1452 //=============================================================================
1453 //function : Geom2dCurve
1455 //=============================================================================
1456 Handle(Geom2d_Curve) Bisector_BisecAna::Geom2dCurve() const
1458 return thebisector->BasisCurve();
1461 //==========================================================================
1462 //function : ParameterOfStartPoint
1464 //==========================================================================
1465 Standard_Real Bisector_BisecAna::ParameterOfStartPoint() const
1467 return thebisector->FirstParameter();
1470 //==========================================================================
1471 //function : ParameterOfEndPoint
1473 //==========================================================================
1474 Standard_Real Bisector_BisecAna::ParameterOfEndPoint() const
1476 return thebisector->LastParameter();
1479 //==========================================================================
1480 //function : Parameter
1482 //==========================================================================
1483 Standard_Real Bisector_BisecAna::Parameter(const gp_Pnt2d& P) const
1485 gp_Hypr2d gphyperbola;
1486 gp_Parab2d gpparabola ;
1487 gp_Elips2d gpellipse ;
1488 gp_Circ2d gpcircle ;
1491 Handle(Geom2d_Curve) BasisCurve = thebisector->BasisCurve();
1492 Handle(Standard_Type) Type = BasisCurve ->DynamicType();
1494 if (Type == STANDARD_TYPE(Geom2d_Line)) {
1495 gpline = Handle(Geom2d_Line)::DownCast(BasisCurve)->Lin2d();
1496 return ElCLib::Parameter(gpline,P);
1498 else if (Type == STANDARD_TYPE(Geom2d_Circle)) {
1499 gpcircle = Handle(Geom2d_Circle)::DownCast(BasisCurve)->Circ2d();
1500 return ElCLib::Parameter(gpcircle,P);
1502 else if (Type == STANDARD_TYPE(Geom2d_Hyperbola)) {
1503 gphyperbola = Handle(Geom2d_Hyperbola)::DownCast(BasisCurve)->Hypr2d();
1504 return ElCLib::Parameter(gphyperbola,P);
1506 else if (Type == STANDARD_TYPE(Geom2d_Parabola)) {
1507 gpparabola = Handle(Geom2d_Parabola)::DownCast(BasisCurve)->Parab2d();
1508 return ElCLib::Parameter(gpparabola,P);
1510 else if (Type == STANDARD_TYPE(Geom2d_Ellipse)) {
1511 gpellipse = Handle(Geom2d_Ellipse)::DownCast(BasisCurve)->Elips2d();
1512 return ElCLib::Parameter(gpellipse,P);
1517 //=============================================================================
1518 //function : NbIntervals
1520 //=============================================================================
1521 Standard_Integer Bisector_BisecAna::NbIntervals() const
1526 //=============================================================================
1527 //function : IntervalFirst
1529 //=============================================================================
1530 Standard_Real Bisector_BisecAna::IntervalFirst(const Standard_Integer I) const
1532 if (I != 1) throw Standard_OutOfRange();
1533 return FirstParameter();
1536 //=============================================================================
1537 //function : IntervalLast
1539 //=============================================================================
1540 Standard_Real Bisector_BisecAna::IntervalLast(const Standard_Integer I) const
1542 if (I != 1) throw Standard_OutOfRange();
1543 return LastParameter();
1546 //=============================================================================
1548 //=============================================================================
1549 void Bisector_BisecAna::Init(const Handle(Geom2d_TrimmedCurve)& Bis)
1554 //=============================================================================
1555 //function : Degenerate
1556 //purpose : Replace the bisectrice by a straight line,
1557 // if the bisectrice is an ellipse, a parabole or a degenerated ellipse.
1558 //=============================================================================
1559 Standard_Boolean Degenerate(Handle(GccInt_Bisec)& aBisector,
1560 const Standard_Real Tolerance)
1562 Standard_Boolean Degeneree = Standard_False;
1564 gp_Hypr2d gphyperbola;
1565 gp_Parab2d gpparabola ;
1566 gp_Elips2d gpellipse ;
1567 //gp_Circ2d gpcircle ;
1569 Handle(GccInt_Bisec) NewBisector;
1571 GccInt_IType type = aBisector->ArcType();
1573 if (type == GccInt_Hpr) {
1574 gphyperbola = aBisector->Hyperbola();
1576 // If the Hyperbola is degenerated, it is replaced by the straight line
1577 // with direction to the axis if symmetry.
1579 if (gphyperbola.MajorRadius() < Tolerance) {
1580 gp_Lin2d gpline(gphyperbola.YAxis());
1581 NewBisector = new GccInt_BLine(gpline);
1582 aBisector = NewBisector;
1583 Degeneree = Standard_True;
1585 if (gphyperbola.MinorRadius() < Tolerance) {
1586 gp_Lin2d gpline(gphyperbola.XAxis());
1587 NewBisector = new GccInt_BLine(gpline);
1588 aBisector = NewBisector;
1589 Degeneree = Standard_True;
1592 else if (type == GccInt_Par) {
1593 gpparabola = aBisector->Parabola();
1595 // If the parabole is degenerated, it is replaces by the straight
1596 // line starting at the Top and with direction of the axis of symmetry.
1598 if (gpparabola.Focal() < Tolerance) {
1599 gp_Lin2d gpline(gpparabola.MirrorAxis());
1600 NewBisector = new GccInt_BLine(gpline);
1601 aBisector = NewBisector;
1602 Degeneree = Standard_True;
1605 else if (type == GccInt_Ell) {
1606 gpellipse = aBisector->Ellipse();
1608 // If the ellipse is degenerated, it is replaced by the straight line
1609 // defined by the great axis.
1611 if (gpellipse.MinorRadius() < Tolerance) {
1612 gp_Lin2d gpline(gpellipse.XAxis());
1613 NewBisector = new GccInt_BLine(gpline);
1614 aBisector = NewBisector;
1615 Degeneree = Standard_True;
1621 static void Indent (const Standard_Integer Offset) {
1623 for (Standard_Integer i = 0; i < Offset; i++) { std::cout << " "; }
1627 //=============================================================================
1630 //=============================================================================
1631 //void Bisector_BisecAna::Dump(const Standard_Integer Deep,
1632 void Bisector_BisecAna::Dump(const Standard_Integer ,
1633 const Standard_Integer Offset) const
1636 std::cout<<"Bisector_BisecAna"<<std::endl;
1638 // thebisector->Dump();