Commit | Line | Data |
---|---|---|
b311480e | 1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 | 2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 3 | // |
973c2be1 | 4 | // This file is part of Open CASCADE Technology software library. |
b311480e | 5 | // |
d5f74e42 | 6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
10 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 11 | // |
973c2be1 | 12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. | |
b311480e | 14 | |
42cf5bc1 | 15 | |
7fd59977 | 16 | #include <ElCLib.hxx> |
42cf5bc1 | 17 | #include <gp_Circ2d.hxx> |
18 | #include <gp_Elips2d.hxx> | |
19 | #include <gp_Hypr2d.hxx> | |
20 | #include <gp_Lin2d.hxx> | |
21 | #include <gp_Parab2d.hxx> | |
22 | #include <IntAna2d_AnaIntersection.hxx> | |
23 | #include <IntAna2d_Conic.hxx> | |
24 | #include <IntAna2d_IntPoint.hxx> | |
25 | #include <Standard_OutOfRange.hxx> | |
26 | #include <StdFail_NotDone.hxx> | |
b311480e | 27 | |
7fd59977 | 28 | //======================================================================= |
29 | //function : Perform | |
30 | //purpose : | |
31 | //======================================================================= | |
32 | void IntAna2d_AnaIntersection::Perform(const gp_Lin2d& L, | |
33 | const gp_Circ2d& C) | |
34 | { | |
35 | ||
36 | done=Standard_False; | |
37 | ||
38 | iden=Standard_False; | |
39 | para=Standard_False; | |
40 | // | |
41 | Standard_Real A,B,C0, d; | |
42 | gp_Pnt2d aP2D, aP2D1, aP2D2; | |
43 | // | |
44 | L.Coefficients(A,B,C0); | |
45 | d=A*C.Location().X() + B*C.Location().Y() + C0; | |
46 | ||
47 | if (Abs(d)-C.Radius()>Epsilon(C.Radius())) { | |
48 | empt=Standard_True; | |
49 | nbp=0; | |
50 | } | |
51 | else { // Au moins 1 solution | |
52 | empt=Standard_False; | |
53 | // | |
54 | //modified by NIZNHY-PKV Fri Jun 15 09:55:00 2007f | |
55 | //Standard_Real ang; | |
56 | //ang = C.XAxis().Direction().Angle(L.Direction()); | |
c6541a0c | 57 | //ang = ang + M_PI / 2.0; |
7fd59977 | 58 | //modified by NIZNHY-PKV Fri Jun 15 09:55:29 2007t |
59 | if (Abs(Abs(d)-C.Radius())<=Epsilon(C.Radius())) { // Cas de tangence | |
60 | ||
61 | Standard_Real u, XS, YS, ang; | |
62 | // | |
63 | nbp=1; | |
64 | XS=C.Location().X() - d*A; | |
65 | YS=C.Location().Y() - d*B; | |
66 | // | |
67 | //modified by NIZNHY-PKV Fri Jun 15 09:55:35 2007f | |
68 | aP2D.SetCoord(XS, YS); | |
69 | u=ElCLib::Parameter(L, aP2D); | |
70 | ang=ElCLib::Parameter(C, aP2D); | |
71 | /* | |
72 | u=B*(L.Location().X()-C.Location().X()) - | |
73 | A*(L.Location().Y()-C.Location().Y()); | |
c6541a0c D |
74 | if (d<0.0) {ang=ang+M_PI;} |
75 | if (ang>=2.0*M_PI) { | |
76 | ang=ang-2.0*M_PI; | |
7fd59977 | 77 | } |
78 | else if (ang<0.0) { | |
c6541a0c | 79 | ang=ang+2.0*M_PI; |
7fd59977 | 80 | } |
81 | */ | |
82 | //modified by NIZNHY-PKV Fri Jun 15 09:55:41 2007t | |
83 | lpnt[0].SetValue(XS,YS,u,ang); | |
84 | } | |
85 | else { // 2 points d intersection | |
86 | Standard_Real h, XS1,YS1, XS2,YS2, ang1,ang2, u1,u2;//,cost,sint angt; | |
87 | nbp=2; | |
88 | h=Sqrt(C.Radius()*C.Radius()-d*d); | |
89 | //modified by NIZNHY-PKV Fri Jun 15 09:55:47 2007f | |
90 | //cost=d/C.Radius(); | |
91 | //sint=h/C.Radius(); | |
92 | //modified by NIZNHY-PKV Fri Jun 15 09:55:52 2007t | |
93 | XS1=C.Location().X() - d*A - h*B; | |
94 | YS1=C.Location().Y() - d*B + h*A; | |
95 | XS2=C.Location().X() - d*A + h*B; | |
96 | YS2=C.Location().Y() - d*B - h*A; | |
97 | // | |
98 | //modified by NIZNHY-PKV Fri Jun 15 09:55:57 2007f | |
99 | aP2D1.SetCoord(XS1, YS1); | |
100 | aP2D2.SetCoord(XS2, YS2); | |
101 | u1=ElCLib::Parameter(L, aP2D1); | |
102 | u2=ElCLib::Parameter(L, aP2D2); | |
103 | ang1=ElCLib::Parameter(C, aP2D1); | |
104 | ang2=ElCLib::Parameter(C, aP2D2); | |
105 | // | |
106 | /* | |
107 | if (Abs(cost)<=0.707) { | |
108 | angt=ACos(cost); | |
109 | } | |
110 | else { | |
111 | angt=ASin(sint); | |
c6541a0c | 112 | if (cost<0) {angt=M_PI-angt;} |
7fd59977 | 113 | } |
114 | ||
115 | ang1=ang-angt; | |
116 | ang2=ang+angt; | |
117 | if (ang1<0.0) { | |
c6541a0c | 118 | ang1=ang1+2.0*M_PI; |
7fd59977 | 119 | } |
c6541a0c D |
120 | else if (ang1>=2.0*M_PI) { |
121 | ang1=ang1-2.0*M_PI; | |
7fd59977 | 122 | } |
123 | if (ang2<0.0) { | |
c6541a0c | 124 | ang2=ang2+2.0*M_PI; |
7fd59977 | 125 | } |
c6541a0c D |
126 | else if (ang2>=2.0*M_PI) { |
127 | ang2=ang2-2.0*M_PI; | |
7fd59977 | 128 | } |
129 | ||
130 | u1=B*(L.Location().X()-C.Location().X()) - | |
131 | A*(L.Location().Y()-C.Location().Y()) +h; | |
132 | u2=u1-2.0*h; | |
133 | */ | |
134 | //modified by NIZNHY-PKV Fri Jun 15 09:56:19 2007t | |
135 | lpnt[0].SetValue(XS1,YS1,u1,ang1); | |
136 | lpnt[1].SetValue(XS2,YS2,u2,ang2); | |
137 | } | |
138 | } | |
139 | done=Standard_True; | |
140 | } | |
141 |