0030895: Coding Rules - specify std namespace explicitly for std::cout and streams
[occt.git] / src / IntAna2d / IntAna2d_AnaIntersection_8.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_8.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
b311480e 30// -----------------------------------------------------------------
31// ------ Verification de la validite des points obtenus ----------
32// --- Methode a implementer dans les autres routines si on constate
33// --- des problemes d'instabilite numerique sur
34// --- * la construction des polynomes en t (t:parametre)
35// --- * la resolution du polynome
36// --- * le retour : parametre t -> point d'intersection
37// --- Probleme : A partir de quelle Tolerance un point n'est
38// --- plus un point de la courbe. (f(x,y)=1e-10 ??)
39// --- ne donne pas d'info. sur la dist. du pt a la courbe
40// -----------------------------------------------------------------
41// ------ Methode non implementee pour les autres Intersections
42// --- Si un probleme est constate : Dupliquer le code entre les
43// --- commentaires VERIF-VALID
44// -----------------------------------------------------------------
7fd59977 45void IntAna2d_AnaIntersection::Perform(const gp_Hypr2d& H,
46 const IntAna2d_Conic& Conic)
47 {
48 Standard_Boolean HIsDirect = H.IsDirect();
49 Standard_Real A,B,C,D,E,F;
50 Standard_Real px0,px1,px2,px3,px4;
51 Standard_Real minor_radius=H.MinorRadius();
52 Standard_Real major_radius=H.MajorRadius();
53 Standard_Integer i;
54 Standard_Real tx,ty,S;
55
56 done = Standard_False;
57 nbp = 0;
58 para = Standard_False;
59 iden = Standard_False;
60 empt = Standard_False;
61
62 gp_Ax2d Axe_rep(H.XAxis());
63 Conic.Coefficients(A,B,C,D,E,F);
64 Conic.NewCoefficients(A,B,C,D,E,F,Axe_rep);
65
66 Standard_Real A_major_radiusP2=A*major_radius*major_radius;
67 Standard_Real B_minor_radiusP2=B*minor_radius*minor_radius;
68 Standard_Real C_2_major_minor_radius=C*2.0*major_radius*minor_radius;
69
70 // Parametre : t avec x=MajorRadius*Ch(t) y=:minorRadius*Sh(t)
71 // Le polynome est reecrit en Exp(t)
72 // Suivent les Coeffs du polynome P multiplie par 4*Exp(t)^2
73
74 px0=A_major_radiusP2 - C_2_major_minor_radius + B_minor_radiusP2;
75 px1=4.0*(D*major_radius-E*minor_radius);
76 px2=2.0*(A_major_radiusP2 + 2.0*F - B_minor_radiusP2);
77 px3=4.0*(D*major_radius+E*minor_radius);
78 px4=A_major_radiusP2 + C_2_major_minor_radius + B_minor_radiusP2;
79
80 MyDirectPolynomialRoots Sol(px4,px3,px2,px1,px0);
81
82 if(!Sol.IsDone()) {
04232180 83 //-- std::cout<<" Done = False ds IntAna2d_AnaIntersection_8.cxx "<<std::endl;
7fd59977 84 done=Standard_False;
85 return;
86 }
87 else {
88 if(Sol.InfiniteRoots()) {
89 iden=Standard_True;
90 done=Standard_True;
91 return;
92 }
93 // On a X=(CosH(t)*major_radius)/2 , Y=(SinH(t)*minor_radius)/2
94 // la Resolution est en S=Exp(t)
95 nbp=Sol.NbSolutions();
96 Standard_Integer nb_sol_valides=0;
97 for(i=1;i<=nbp;i++) {
98 S=Sol.Value(i);
99 if(S>RealEpsilon()) {
100 tx=0.5*major_radius*(S+1/S);
101 ty=0.5*minor_radius*(S-1/S);
102
103 //--- Est-on sur la bonne branche de l'Hyperbole
104 //--------------- VERIF-VALIDITE-INTERSECTION ----------
105 //--- On Suppose que l'ecart sur la courbe1 est nul
106 //--- (le point a ete obtenu par parametrage)
107 //--- ??? la tolerance a ete fixee a 1e-10 ?????????????
108
109#if 0
110 Standard_Real ecart_sur_courbe2;
111 ecart_sur_courbe2=Conic.Value(tx,ty);
112 if(ecart_sur_courbe2<=1e-10 && ecart_sur_courbe2>=-1e-10) {
113 nb_sol_valides++;
114 Coord_Ancien_Repere(tx,ty,Axe_rep);
115 lpnt[nb_sol_valides-1].SetValue(tx,ty,Log(S));
116 }
117#else
118
119 nb_sol_valides++;
120 Coord_Ancien_Repere(tx,ty,Axe_rep);
121 S = Log(S);
122 if(!HIsDirect)
123 S = -S;
124 lpnt[nb_sol_valides-1].SetValue(tx,ty,S);
125#endif
126 }
127 }
128 nbp=nb_sol_valides;
129 Traitement_Points_Confondus(nbp,lpnt);
130 }
131 done=Standard_True;
132 }
133
134
135
136
137