Warnings on vc14 were eliminated
[occt.git] / src / IntAna2d / IntAna2d_AnaIntersection_1.cxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15
16 #include <gp_Circ2d.hxx>
17 #include <gp_Elips2d.hxx>
18 #include <gp_Hypr2d.hxx>
19 #include <gp_Lin2d.hxx>
20 #include <gp_Parab2d.hxx>
21 #include <IntAna2d_AnaIntersection.hxx>
22 #include <IntAna2d_Conic.hxx>
23 #include <IntAna2d_IntPoint.hxx>
24 #include <Standard_OutOfRange.hxx>
25 #include <StdFail_NotDone.hxx>
26
27 void IntAna2d_AnaIntersection::Perform (const gp_Lin2d& L1,
28                                         const gp_Lin2d& L2) {
29
30  
31   done = Standard_False;
32
33   Standard_Real A1,B1,C1;
34   Standard_Real A2,B2,C2;
35   L1.Coefficients(A1,B1,C1);
36   L2.Coefficients(A2,B2,C2);
37
38   Standard_Real al1,be1,ga1;
39   Standard_Real al2,be2,ga2;
40   
41   Standard_Real Det =Max (Abs(A1),Max(Abs(A2),Max(Abs(B1),Abs(B2))));
42
43   if (Abs(A1)==Det) {
44     al1=A1;
45     be1=B1;
46     ga1=C1;
47     al2=A2;
48     be2=B2;
49     ga2=C2;
50   }
51   else if (Abs(B1)==Det) {
52     al1=B1;
53     be1=A1;
54     ga1=C1;
55     al2=B2;
56     be2=A2;
57     ga2=C2;
58   }
59   else if (Abs(A2)==Det) {
60     al1=A2;
61     be1=B2;
62     ga1=C2;
63     al2=A1;
64     be2=B1;
65     ga2=C1;
66   }
67   else {
68     al1=B2;
69     be1=A2;
70     ga1=C2;
71     al2=B1;
72     be2=A1;
73     ga2=C1;
74   }
75
76   Standard_Real rap=al2/al1;
77   Standard_Real denom=be2-rap*be1;
78
79   if (Abs(denom)<=RealEpsilon()) {                // Directions confondues
80     para=Standard_True;
81     nbp=0;
82     if (Abs(ga2-rap*ga1)<=RealEpsilon()) {          // Droites confondues
83       iden=Standard_True;
84       empt=Standard_False;
85     }
86     else {                                       // Droites paralleles
87       iden=Standard_False;
88       empt=Standard_True;
89     }
90   }
91   else {
92     para=Standard_False;
93     iden=Standard_False;
94     empt=Standard_False;
95     nbp=1;
96     Standard_Real XS = (be1*ga2/al1-be2*ga1/al1)/denom;
97     Standard_Real YS = (rap*ga1-ga2)/denom;
98
99     if (((Abs(A1)!=Det)&&(Abs(B1)==Det))||
100         ((Abs(A1)!=Det)&&(Abs(B1)!=Det)&&(Abs(A2)!=Det))) {
101       Standard_Real temp=XS;
102       XS=YS;
103       YS=temp;
104     }
105
106     Standard_Real La,Mu;
107     if (Abs(A1)>=Abs(B1)) {
108       La=(YS-L1.Location().Y())/A1;
109     }
110     else {
111       La=(L1.Location().X()-XS)/B1;
112     }
113     if (Abs(A2)>=Abs(B2)) {
114       Mu=(YS-L2.Location().Y())/A2;
115     }
116     else {
117       Mu=(L2.Location().X()-XS)/B2;
118     }
119     lpnt[0].SetValue(XS,YS,La,Mu);
120   }
121   done=Standard_True;
122 }
123
124