b311480e |
1 | // Created on: 1992-09-02 |
2 | // Created by: Remi GILET |
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 | |
18 | #include <gce_MakeElips2d.hxx> |
7fd59977 |
19 | #include <gp.hxx> |
42cf5bc1 |
20 | #include <gp_Ax2d.hxx> |
21 | #include <gp_Ax22d.hxx> |
22 | #include <gp_Elips2d.hxx> |
7fd59977 |
23 | #include <gp_Lin2d.hxx> |
42cf5bc1 |
24 | #include <gp_Pnt2d.hxx> |
7fd59977 |
25 | #include <StdFail_NotDone.hxx> |
26 | |
27 | //========================================================================= |
28 | // Creation d une Ellipse 2d de gp de centre <Center> et de sommets + |
29 | // <S1> et <S2>. + |
30 | // <CenterS1> donne le grand axe . + |
31 | // <S1> donne le grand rayon et <S2> le petit rayon. + |
32 | //========================================================================= |
7fd59977 |
33 | gce_MakeElips2d::gce_MakeElips2d(const gp_Pnt2d& S1 , |
34 | const gp_Pnt2d& S2 , |
35 | const gp_Pnt2d& Center ) |
36 | { |
37 | Standard_Real D1 = S1.Distance(Center); |
38 | gp_Dir2d XAxis(gp_XY(S1.XY()-Center.XY())); |
39 | gp_Dir2d YAxis(gp_XY(S2.XY()-Center.XY())); |
40 | Standard_Real D2 = gp_Lin2d(Center,XAxis).Distance(S2); |
41 | if (D1 < D2) { TheError = gce_InvertAxis; } |
42 | else if (D2 < gp::Resolution()) { TheError = gce_NullAxis; } |
43 | else { |
44 | TheElips2d = gp_Elips2d(gp_Ax22d(Center,XAxis,YAxis),D1,D2); |
45 | TheError = gce_Done; |
46 | } |
47 | } |
48 | |
49 | gce_MakeElips2d::gce_MakeElips2d(const gp_Ax2d& MajorAxis , |
50 | const Standard_Real MajorRadius , |
51 | const Standard_Real MinorRadius , |
52 | const Standard_Boolean Sense ) |
53 | { |
54 | if (MajorRadius < 0.0) { TheError = gce_NegativeRadius; } |
55 | else if (MajorRadius < MinorRadius) { TheError = gce_InvertRadius; } |
56 | else { |
57 | TheElips2d = gp_Elips2d(MajorAxis,MajorRadius,MinorRadius,Sense); |
58 | TheError = gce_Done; |
59 | } |
60 | } |
61 | |
62 | gce_MakeElips2d::gce_MakeElips2d(const gp_Ax22d& A , |
63 | const Standard_Real MajorRadius , |
64 | const Standard_Real MinorRadius ) |
65 | { |
66 | if (MajorRadius < 0.0) { TheError = gce_NegativeRadius; } |
67 | else if (MajorRadius < MinorRadius) { TheError = gce_InvertRadius; } |
68 | else { |
69 | TheElips2d = gp_Elips2d(A,MajorRadius,MinorRadius); |
70 | TheError = gce_Done; |
71 | } |
72 | } |
73 | |
74 | const gp_Elips2d& gce_MakeElips2d::Value() const |
75 | { |
2d2b3d53 |
76 | StdFail_NotDone_Raise_if (TheError != gce_Done, |
77 | "gce_MakeElips2d::Value() - no result"); |
7fd59977 |
78 | return TheElips2d; |
79 | } |
80 | |
81 | const gp_Elips2d& gce_MakeElips2d::Operator() const |
82 | { |
83 | return Value(); |
84 | } |
85 | |
86 | gce_MakeElips2d::operator gp_Elips2d() const |
87 | { |
88 | return Value(); |
89 | } |
90 | |