Test for 0022778: Bug in BRepMesh
[occt.git] / src / gp / gp_Hypr2d.cxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 //
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.
8 //
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.
11 //
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.
18
19
20 #define No_Standard_OutOfRange
21
22 #include <gp_Hypr2d.ixx>
23
24 void gp_Hypr2d::Coefficients (Standard_Real& A, 
25                               Standard_Real& B, 
26                               Standard_Real& C, 
27                               Standard_Real& D, 
28                               Standard_Real& E, 
29                               Standard_Real& F) const 
30 {
31   Standard_Real DMin = minorRadius * minorRadius;
32   Standard_Real DMaj = majorRadius * majorRadius;
33   if (DMin <= gp::Resolution() && DMaj <= gp::Resolution()) {
34     A = B = C = D = E = F = 0.0;
35   }
36   else {
37     gp_Trsf2d T;
38     T.SetTransformation (pos.XAxis());
39     Standard_Real T11 = T.Value (1, 1);
40     Standard_Real T12 = T.Value (1, 2);
41     Standard_Real T13 = T.Value (1, 3);
42     if (DMin <= gp::Resolution()) {
43       A = T11 * T11;   B = T12 * T12;   C = T11 * T12;
44       D = T11 * T13;   E = T12 * T13;   F = T13 * T13 - DMaj;
45     }
46     else {
47       Standard_Real T21 = T.Value (2, 1);
48       Standard_Real T22 = T.Value (2, 2);
49       Standard_Real T23 = T.Value (2, 3);
50       A = (T11 * T11 / DMaj) - (T21 * T21 / DMin);
51       B = (T12 * T12 / DMaj) - (T22 * T22 / DMin);
52       C = (T11 * T12 / DMaj) - (T21 * T22 / DMin);
53       D = (T11 * T13 / DMaj) - (T21 * T23 / DMin);
54       E = (T12 * T13 / DMaj) - (T22 * T23 / DMin);
55       F = (T13 * T13 / DMaj) - (T23 * T23 / DMin) - 1.0;
56     }
57   }
58 }
59
60 void gp_Hypr2d::Mirror (const gp_Pnt2d& P)
61 { pos.Mirror(P); }
62
63 gp_Hypr2d gp_Hypr2d::Mirrored (const gp_Pnt2d& P) const
64 {
65   gp_Hypr2d H = *this;
66   H.pos.Mirror (P);
67   return H; 
68 }
69
70 void gp_Hypr2d::Mirror (const gp_Ax2d& A)
71 { pos.Mirror(A); }
72
73 gp_Hypr2d gp_Hypr2d::Mirrored (const gp_Ax2d& A) const
74 {
75   gp_Hypr2d H = *this;
76   H.pos.Mirror (A);
77   return H; 
78 }
79