Test for 0022778: Bug in BRepMesh
[occt.git] / src / gp / gp_Cone.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 // LPA, JCV  07/92 passage sur C1.
20 // JCV 07/92 Introduction de la method Dump 
21
22 #include <gp_Cone.ixx>
23
24 void gp_Cone::Coefficients
25 (Standard_Real& A1, Standard_Real& A2, Standard_Real& A3, 
26  Standard_Real& B1, Standard_Real& B2, Standard_Real& B3,
27  Standard_Real& C1, Standard_Real& C2, Standard_Real& C3,
28  Standard_Real& D) const
29 {
30   // Dans le repere du cone :
31   // X**2 + Y**2 - (radius + Z * Tan(semiAngle))**2 = 0.0
32   gp_Trsf T;
33   T.SetTransformation (pos);
34   Standard_Real KAng = Tan (semiAngle);
35   Standard_Real T11 = T.Value (1, 1);
36   Standard_Real T12 = T.Value (1, 2);
37   Standard_Real T13 = T.Value (1, 3);
38   Standard_Real T14 = T.Value (1, 4);
39   Standard_Real T21 = T.Value (2, 1);
40   Standard_Real T22 = T.Value (2, 2);
41   Standard_Real T23 = T.Value (2, 3);
42   Standard_Real T24 = T.Value (2, 4);
43   Standard_Real T31 = T.Value (3, 1) * KAng;
44   Standard_Real T32 = T.Value (3, 2) * KAng;
45   Standard_Real T33 = T.Value (3, 3) * KAng;
46   Standard_Real T34 = T.Value (3, 4) * KAng;
47   A1 = T11 * T11 + T21 * T21 - T31 * T31;
48   A2 = T12 * T12 + T22 * T22 - T32 * T32;
49   A3 = T13 * T13 + T23 * T23 - T33 * T33;
50   B1 = T11 * T12 + T21 * T22 - T31 * T32;
51   B2 = T11 * T13 + T21 * T23 - T31 * T33;
52   B3 = T12 * T13 + T22 * T23 - T32 * T33;
53   C1 = T11 * T14 + T21 * T24 - T31 * (radius + T34);
54   C2 = T12 * T14 + T22 * T24 - T32 * (radius + T34);
55   C3 = T13 * T14 + T23 * T24 - T33 * (radius + T34);
56   D = T14*T14 + T24*T24 - radius*radius - T34*T34 - 2.0*radius*T34;  
57 }
58
59 void gp_Cone::Mirror (const gp_Pnt& P)
60 { pos.Mirror (P); }
61
62 gp_Cone gp_Cone::Mirrored (const gp_Pnt& P) const
63 {
64   gp_Cone C = *this;
65   C.pos.Mirror (P);
66   return C;
67 }
68
69 void gp_Cone::Mirror (const gp_Ax1& A1)
70 { pos.Mirror (A1); }
71
72 gp_Cone gp_Cone::Mirrored (const gp_Ax1& A1) const
73 {
74   gp_Cone C = *this;
75   C.pos.Mirror (A1);
76   return C;
77 }
78
79 void gp_Cone::Mirror (const gp_Ax2& A2)
80 { pos.Mirror (A2); }
81
82 gp_Cone gp_Cone::Mirrored (const gp_Ax2& A2) const
83 {
84   gp_Cone C = *this;
85   C.pos.Mirror (A2);
86   return C;
87 }
88