0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / IntAna2d / IntAna2d_AnaIntersection_6.cxx
CommitLineData
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_6.cxx
16//============================================================================
7fd59977 17
42cf5bc1 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
30void IntAna2d_AnaIntersection::Perform(const gp_Elips2d& Elips,
31 const IntAna2d_Conic& Conic)
32{
33 Standard_Boolean EIsDirect = Elips.IsDirect();
34 Standard_Real A,B,C,D,E,F;
35 Standard_Real pcte,ps,pc,p2sc,pcc,pss;
36 Standard_Real minor_radius=Elips.MinorRadius();
37 Standard_Real major_radius=Elips.MajorRadius();
38 Standard_Integer i;
39 Standard_Real tx,ty,S;
40
41 done = Standard_False;
42 nbp = 0;
43 para = Standard_False;
44 iden = Standard_False;
45 empt = Standard_False;
46
47
48 gp_Ax2d Axe_rep(Elips.XAxis());
49
50 Conic.Coefficients(A,B,C,D,E,F);
51 Conic.NewCoefficients(A,B,C,D,E,F,Axe_rep);
52
53 // Parametre : a avec x=MajorRadius Cos(a) et y=MinorRadius Sin(a)
54
55 pss= B*minor_radius*minor_radius; // SIN ^2
56 pcc= A*major_radius*major_radius-pss; // COS ^2
57 p2sc=C*major_radius*minor_radius; // 2 SIN COS
58 pc= 2.0*D*major_radius; // COS
59 ps= 2.0*E*minor_radius; // SIN
60 pcte=F+pss; // 1
61
c6541a0c 62 math_TrigonometricFunctionRoots Sol(pcc,p2sc,pc,ps,pcte,0.0,2.0*M_PI);
7fd59977 63
64 if (!Sol.IsDone()) {
65 done=Standard_False;
66 return;
67 }
68 else {
69 if(Sol.InfiniteRoots()) {
70 iden=Standard_True;
71 done=Standard_True;
72 return;
73 }
74 nbp=Sol.NbSolutions();
75 for(i=1;i<=nbp;i++) {
76 S = Sol.Value(i);
77 tx=major_radius*Cos(S);
78 ty=minor_radius*Sin(S);
79 Coord_Ancien_Repere(tx,ty,Axe_rep);
80 if(!EIsDirect)
c6541a0c 81 S = M_PI+M_PI-S;
7fd59977 82 lpnt[i-1].SetValue(tx,ty,S);
83 }
84 Traitement_Points_Confondus(nbp,lpnt);
85 }
86 done = Standard_True;
87}
88