1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
19 //============================================ IntAna2d_AnaIntersection_8.cxx
20 //============================================================================
21 #include <IntAna2d_AnaIntersection.jxx>
23 #include <IntAna2d_Outils.hxx>
25 // -----------------------------------------------------------------
26 // ------ Verification de la validite des points obtenus ----------
27 // --- Methode a implementer dans les autres routines si on constate
28 // --- des problemes d'instabilite numerique sur
29 // --- * la construction des polynomes en t (t:parametre)
30 // --- * la resolution du polynome
31 // --- * le retour : parametre t -> point d'intersection
32 // --- Probleme : A partir de quelle Tolerance un point n'est
33 // --- plus un point de la courbe. (f(x,y)=1e-10 ??)
34 // --- ne donne pas d'info. sur la dist. du pt a la courbe
35 // -----------------------------------------------------------------
36 // ------ Methode non implementee pour les autres Intersections
37 // --- Si un probleme est constate : Dupliquer le code entre les
38 // --- commentaires VERIF-VALID
39 // -----------------------------------------------------------------
41 void IntAna2d_AnaIntersection::Perform(const gp_Hypr2d& H,
42 const IntAna2d_Conic& Conic)
44 Standard_Boolean HIsDirect = H.IsDirect();
45 Standard_Real A,B,C,D,E,F;
46 Standard_Real px0,px1,px2,px3,px4;
47 Standard_Real minor_radius=H.MinorRadius();
48 Standard_Real major_radius=H.MajorRadius();
50 Standard_Real tx,ty,S;
52 done = Standard_False;
54 para = Standard_False;
55 iden = Standard_False;
56 empt = Standard_False;
58 gp_Ax2d Axe_rep(H.XAxis());
59 Conic.Coefficients(A,B,C,D,E,F);
60 Conic.NewCoefficients(A,B,C,D,E,F,Axe_rep);
62 Standard_Real A_major_radiusP2=A*major_radius*major_radius;
63 Standard_Real B_minor_radiusP2=B*minor_radius*minor_radius;
64 Standard_Real C_2_major_minor_radius=C*2.0*major_radius*minor_radius;
66 // Parametre : t avec x=MajorRadius*Ch(t) y=:minorRadius*Sh(t)
67 // Le polynome est reecrit en Exp(t)
68 // Suivent les Coeffs du polynome P multiplie par 4*Exp(t)^2
70 px0=A_major_radiusP2 - C_2_major_minor_radius + B_minor_radiusP2;
71 px1=4.0*(D*major_radius-E*minor_radius);
72 px2=2.0*(A_major_radiusP2 + 2.0*F - B_minor_radiusP2);
73 px3=4.0*(D*major_radius+E*minor_radius);
74 px4=A_major_radiusP2 + C_2_major_minor_radius + B_minor_radiusP2;
76 MyDirectPolynomialRoots Sol(px4,px3,px2,px1,px0);
79 //-- cout<<" Done = False ds IntAna2d_AnaIntersection_8.cxx "<<endl;
84 if(Sol.InfiniteRoots()) {
89 // On a X=(CosH(t)*major_radius)/2 , Y=(SinH(t)*minor_radius)/2
90 // la Resolution est en S=Exp(t)
91 nbp=Sol.NbSolutions();
92 Standard_Integer nb_sol_valides=0;
96 tx=0.5*major_radius*(S+1/S);
97 ty=0.5*minor_radius*(S-1/S);
99 //--- Est-on sur la bonne branche de l'Hyperbole
100 //--------------- VERIF-VALIDITE-INTERSECTION ----------
101 //--- On Suppose que l'ecart sur la courbe1 est nul
102 //--- (le point a ete obtenu par parametrage)
103 //--- ??? la tolerance a ete fixee a 1e-10 ?????????????
106 Standard_Real ecart_sur_courbe2;
107 ecart_sur_courbe2=Conic.Value(tx,ty);
108 if(ecart_sur_courbe2<=1e-10 && ecart_sur_courbe2>=-1e-10) {
110 Coord_Ancien_Repere(tx,ty,Axe_rep);
111 lpnt[nb_sol_valides-1].SetValue(tx,ty,Log(S));
116 Coord_Ancien_Repere(tx,ty,Axe_rep);
120 lpnt[nb_sol_valides-1].SetValue(tx,ty,S);
125 Traitement_Points_Confondus(nbp,lpnt);