b311480e |
1 | // Created on: 1992-10-13 |
2 | // Created by: Laurent BUCHARD |
3 | // Copyright (c) 1992-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
7fd59977 |
18 | #include <ElCLib.hxx> |
42cf5bc1 |
19 | #include <gp_Pnt2d.hxx> |
20 | #include <IntCurve_PConic.hxx> |
21 | #include <IntCurve_ProjectOnPConicTool.hxx> |
7fd59977 |
22 | |
23 | Standard_Real IntCurve_ProjectOnPConicTool::FindParameter |
24 | (const IntCurve_PConic& ThePConic, |
25 | const gp_Pnt2d& P, |
26 | const Standard_Real LowParameter, |
27 | const Standard_Real HighParameter, |
28 | const Standard_Real) { |
29 | |
30 | |
31 | Standard_Real ParamSup,ParamInf,Param=0; |
32 | if(LowParameter>HighParameter) { |
33 | ParamSup=LowParameter; |
34 | ParamInf=HighParameter; |
35 | } |
36 | else { |
37 | ParamInf=LowParameter; |
38 | ParamSup=HighParameter; |
39 | } |
40 | |
41 | switch(ThePConic.TypeCurve()) { |
42 | |
43 | case GeomAbs_Line: |
44 | Param=ElCLib::LineParameter(ThePConic.Axis2().XAxis(),P); |
45 | break; |
46 | |
47 | case GeomAbs_Circle: |
48 | Param=ElCLib::CircleParameter(ThePConic.Axis2(),P); |
c6541a0c |
49 | if(Param<0.0) { Param+=M_PI+M_PI; } |
7fd59977 |
50 | break; |
51 | |
52 | case GeomAbs_Ellipse: { |
53 | Param=ElCLib::EllipseParameter(ThePConic.Axis2() |
54 | ,ThePConic.Param1() |
55 | ,ThePConic.Param2() |
56 | ,P); |
c6541a0c |
57 | if (Param < 0.0) { Param+=M_PI+M_PI; } |
7fd59977 |
58 | break; |
59 | } |
60 | |
61 | case GeomAbs_Parabola: { |
62 | Param=ElCLib::ParabolaParameter(ThePConic.Axis2(),P); |
63 | break; |
64 | } |
65 | case GeomAbs_Hyperbola: { |
66 | Param=ElCLib::HyperbolaParameter(ThePConic.Axis2() |
67 | ,ThePConic.Param1() |
68 | ,ThePConic.Param2(),P); |
69 | break; |
70 | } |
7fd59977 |
71 | default: |
72 | break; |
7fd59977 |
73 | } |
74 | if(ParamInf!=ParamSup) { |
75 | if(Param<ParamInf) return(ParamInf); |
76 | if(Param>ParamSup) return(ParamSup); |
77 | } |
78 | return(Param); |
79 | } |
80 | |
81 | |
82 | Standard_Real IntCurve_ProjectOnPConicTool::FindParameter |
83 | (const IntCurve_PConic& ThePConic, |
84 | const gp_Pnt2d& P, |
85 | const Standard_Real) { |
86 | |
04232180 |
87 | //std::cout<<"\n\n---- Dans ProjectOnPConicTool::FindParameter Point : "<<P.X()<<","<<P.Y(); |
7fd59977 |
88 | |
89 | Standard_Real Param=0; |
90 | |
91 | switch(ThePConic.TypeCurve()) { |
92 | |
93 | case GeomAbs_Line: |
94 | Param=ElCLib::LineParameter(ThePConic.Axis2().XAxis(),P); |
95 | break; |
96 | |
97 | case GeomAbs_Circle: |
98 | Param=ElCLib::CircleParameter(ThePConic.Axis2(),P); |
c6541a0c |
99 | if(Param<0.0) { Param+=M_PI+M_PI; } |
7fd59977 |
100 | break; |
101 | |
102 | case GeomAbs_Ellipse: { |
103 | Param=ElCLib::EllipseParameter(ThePConic.Axis2() |
104 | ,ThePConic.Param1() |
105 | ,ThePConic.Param2() |
106 | ,P); |
c6541a0c |
107 | if (Param < 0.0) { Param+=M_PI+M_PI; } |
7fd59977 |
108 | break; |
109 | } |
110 | |
111 | case GeomAbs_Parabola: { |
112 | Param=ElCLib::ParabolaParameter(ThePConic.Axis2(),P); |
113 | break; |
114 | } |
115 | case GeomAbs_Hyperbola: { |
116 | Param=ElCLib::HyperbolaParameter(ThePConic.Axis2() |
117 | ,ThePConic.Param1() |
118 | ,ThePConic.Param2(),P); |
119 | break; |
120 | } |
7fd59977 |
121 | default: |
122 | break; |
7fd59977 |
123 | } |
124 | |
125 | return(Param); |
126 | } |