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