b311480e |
1 | // Created on: 1992-09-02 |
2 | // Created by: Remi GILET |
3 | // Copyright (c) 1992-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | #include <gce_MakeHypr.ixx> |
23 | #include <StdFail_NotDone.hxx> |
24 | #include <gp_Lin.hxx> |
25 | |
26 | //========================================================================= |
27 | // Creation d une Hyperbole 3d de gp de centre <Center> et de sommets + |
28 | // <S1> et <S2>. + |
29 | // <CenterS1> donne le grand axe . + |
30 | // <S1> donne le grand rayon et <S2> le petit rayon. + |
31 | //========================================================================= |
32 | |
33 | gce_MakeHypr::gce_MakeHypr(const gp_Pnt& S1 , |
34 | const gp_Pnt& S2 , |
35 | const gp_Pnt& Center ) |
36 | { |
37 | gp_Dir XAxis(gp_XYZ(S1.XYZ()-Center.XYZ())); |
38 | gp_Lin L(Center,XAxis); |
39 | Standard_Real D = S1.Distance(Center); |
40 | Standard_Real d = L.Distance(S2); |
41 | if (d > D) { TheError = gce_InvertAxis; } |
42 | else { |
43 | gp_Dir Norm(XAxis.Crossed(gp_Dir(gp_XYZ(S2.XYZ()-Center.XYZ())))); |
44 | TheHypr = gp_Hypr(gp_Ax2(Center,Norm,XAxis),D,d); |
45 | TheError = gce_Done; |
46 | } |
47 | } |
48 | |
49 | gce_MakeHypr::gce_MakeHypr(const gp_Ax2& A2 , |
50 | const Standard_Real MajorRadius , |
51 | const Standard_Real MinorRadius ) |
52 | { |
53 | if (MajorRadius < MinorRadius) { TheError = gce_InvertRadius; } |
54 | else if (MajorRadius < 0.0) { TheError = gce_NegativeRadius; } |
55 | else { |
56 | TheHypr = gp_Hypr(A2,MajorRadius,MinorRadius); |
57 | TheError = gce_Done; |
58 | } |
59 | } |
60 | |
61 | const gp_Hypr& gce_MakeHypr::Value() const |
62 | { |
63 | StdFail_NotDone_Raise_if(!TheError == gce_Done,""); |
64 | return TheHypr; |
65 | } |
66 | |
67 | const gp_Hypr& gce_MakeHypr::Operator() const |
68 | { |
69 | return Value(); |
70 | } |
71 | |
72 | gce_MakeHypr::operator gp_Hypr() const |
73 | { |
74 | return Value(); |
75 | } |
76 | |