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 | |
7fd59977 |
15 | //============================================ IntAna2d_AnaIntersection_4.cxx |
16 | //============================================================================ |
42cf5bc1 |
17 | |
18 | #include <gp_Circ2d.hxx> |
19 | #include <gp_Elips2d.hxx> |
20 | #include <gp_Hypr2d.hxx> |
21 | #include <gp_Lin2d.hxx> |
22 | #include <gp_Parab2d.hxx> |
23 | #include <IntAna2d_AnaIntersection.hxx> |
24 | #include <IntAna2d_Conic.hxx> |
25 | #include <IntAna2d_IntPoint.hxx> |
7fd59977 |
26 | #include <IntAna2d_Outils.hxx> |
42cf5bc1 |
27 | #include <Standard_OutOfRange.hxx> |
28 | #include <StdFail_NotDone.hxx> |
7fd59977 |
29 | |
30 | void IntAna2d_AnaIntersection::Perform (const gp_Lin2d& L, |
31 | const IntAna2d_Conic& Conic) |
32 | { |
33 | Standard_Real A,B,C,D,E,F; |
34 | Standard_Real px0,px1,px2; |
35 | Standard_Real DR_A,DR_B,DR_C,X0,Y0; |
36 | Standard_Integer i; |
37 | Standard_Real tx,ty,S; |
38 | |
39 | done = Standard_False; |
40 | nbp = 0; |
41 | para = Standard_False; |
42 | iden = Standard_False; |
43 | |
44 | Conic.Coefficients(A,B,C,D,E,F); |
45 | L.Coefficients(DR_A,DR_B,DR_C); |
46 | X0=L.Location().X(); |
47 | Y0=L.Location().Y(); |
48 | |
49 | // Parametre: L |
50 | // X = Xo - L DR_B et Y = Yo + L DR_A |
51 | |
52 | px0=F + X0*(D+D + A*X0 + 2.0*C*Y0) + Y0*(E+E + B*Y0); |
53 | px1=2.0*(E*DR_A - D*DR_B + X0*(C*DR_A - A*DR_B) + Y0*(B*DR_A - C*DR_B)); |
54 | px2=DR_A*(B*DR_A - 2.0*C*DR_B) + A*(DR_B*DR_B); |
55 | |
56 | MyDirectPolynomialRoots Sol(px2,px1,px0); |
57 | |
58 | if(!Sol.IsDone()) { |
59 | done=Standard_False; |
60 | return; |
61 | } |
62 | else { |
63 | if(Sol.InfiniteRoots()) { |
64 | iden=Standard_True; |
65 | done=Standard_True; |
66 | return; |
67 | } |
68 | nbp=Sol.NbSolutions(); |
69 | for(i=1;i<=nbp;i++) { |
70 | S=Sol.Value(i); |
71 | tx=X0 - S*DR_B; |
72 | ty=Y0 + S*DR_A; |
73 | lpnt[i-1].SetValue(tx,ty,S); |
74 | } |
75 | Traitement_Points_Confondus(nbp,lpnt); |
76 | } |
77 | done=Standard_True; |
78 | } |