1 // File: GccAna_CircLin2dBisec.cxx
2 // Created: Fri Oct 11 08:19:14 1991
6 //=========================================================================
7 // CREATION of the BISSECTICE between a CIRCLE and a STRAIGHT LINE. +
8 //=========================================================================
10 #include <GccAna_CircLin2dBisec.ixx>
13 #include <gp_Dir2d.hxx>
14 #include <gp_Ax2d.hxx>
15 #include <GccInt_BParab.hxx>
16 #include <GccInt_BLine.hxx>
17 #include <Standard_OutOfRange.hxx>
18 #include <StdFail_NotDone.hxx>
21 //=========================================================================
23 GccAna_CircLin2dBisec::
24 GccAna_CircLin2dBisec (const gp_Circ2d& Circle ,
25 const gp_Lin2d& Line ):
31 //=========================================================================
32 // Initialization of fields : +
34 // - line (straight line.) +
35 // - NbrSol (number of solution.) +
36 // - WellDone (Booleen showing success or failure of algorithm). +
37 //=========================================================================
40 WellDone = Standard_True;
43 //=========================================================================
45 // Return coordinates of origins of the straight line (xloc,yloc) and the +
46 // circle (xcencir, ycencir). +
47 // Also return the coordinates of the direction of the straight line (xdir, +
48 // ydir) and the radius of circle R1. +
49 // Check at which side of the straight line is found the center of the circle +
50 // to orientate the parabola (sign). +
51 // Create axis of each parabola (axeparab1, axeparb2), then +
52 // two parabolas (biscirlin1, biscirlin1). +
53 //=========================================================================
55 Handle(GccInt_Bisec) GccAna_CircLin2dBisec::
56 ThisSolution (const Standard_Integer Index) const
59 if (!WellDone) StdFail_NotDone::Raise();
61 if ((Index <=0) || (Index > NbrSol)) Standard_OutOfRange::Raise();
63 Handle(GccInt_Bisec) bissol;
64 Standard_Real xdir = line.Direction().X();
65 Standard_Real ydir = line.Direction().Y();
66 Standard_Real xloc = line.Location().X();
67 Standard_Real yloc = line.Location().Y();
68 Standard_Real xcencir = circle.Location().X();
69 Standard_Real ycencir = circle.Location().Y();
70 Standard_Real R1 = circle.Radius();
71 Standard_Real dist = line.Distance(circle.Location());
72 if ((Abs(line.Distance(circle.Location())-circle.Radius())
73 <= gp::Resolution()) && (Index == 1)) {
74 gp_Lin2d biscirlin1(circle.Location(),gp_Dir2d(-ydir,xdir));
75 bissol = new GccInt_BLine(biscirlin1);
76 // ==========================================================
79 Standard_Integer signe;
80 if ((-ydir*(xcencir-xloc)+xdir*(ycencir-yloc)) > 0.0) {
91 axeparab1=gp_Ax2d(gp_Pnt2d(gp_XY(xcencir+signe*ydir*(dist+R1)/2,
92 ycencir-signe*xdir*(dist+R1)/2.)),
93 gp_Dir2d(-signe*ydir,signe*xdir));
94 biscirlin = gp_Parab2d(axeparab1,(dist+R1)/2.0);
98 axeparab1=gp_Ax2d(gp_Pnt2d(gp_XY(xcencir+signe*ydir*(dist-R1)/2,
99 ycencir-signe*xdir*(dist-R1)/2.)),
100 gp_Dir2d(signe*ydir,-signe*xdir));
103 axeparab1=gp_Ax2d(gp_Pnt2d(gp_XY(xcencir+signe*ydir*(dist-R1)/2,
104 ycencir-signe*xdir*(dist-R1)/2.)),
105 gp_Dir2d(-signe*ydir,signe*xdir));
107 biscirlin = gp_Parab2d(axeparab1,Abs(dist-R1)/2.0);
109 bissol = new GccInt_BParab(biscirlin);
110 // ==========================================================
113 axeparab1 = gp_Ax2d(gp_Pnt2d(gp_XY(xcencir+signe*ydir*(dist+R1)/2.,
114 ycencir-signe*xdir*(dist+R1)/2.)),
115 gp_Dir2d(signe*(-ydir),signe*xdir));
116 biscirlin = gp_Parab2d(axeparab1,R1);
117 bissol = new GccInt_BParab(biscirlin);
118 // ==========================================================
125 //=========================================================================
127 Standard_Boolean GccAna_CircLin2dBisec::
128 IsDone () const { return WellDone; }
130 Standard_Integer GccAna_CircLin2dBisec::
131 NbSolutions () const { return NbrSol; }