0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / gp / gp_Cylinder.cxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 // LPA, JCV  07/92 passage sur C1.
16 // JCV 07/92 Introduction de la method Dump 
17 // LBO 08/93 passage aux Ax3
18
19 #include <gp_Ax1.hxx>
20 #include <gp_Ax2.hxx>
21 #include <gp_Ax3.hxx>
22 #include <gp_Cylinder.hxx>
23 #include <gp_Pnt.hxx>
24 #include <gp_Trsf.hxx>
25 #include <gp_Vec.hxx>
26 #include <Standard_ConstructionError.hxx>
27
28 void gp_Cylinder::Coefficients
29 (Standard_Real& A1, Standard_Real& A2, Standard_Real& A3, 
30  Standard_Real& B1, Standard_Real& B2, Standard_Real& B3, 
31  Standard_Real& C1, Standard_Real& C2, Standard_Real& C3, Standard_Real& D) const
32 {
33   // Dans le repere local du cylindre :
34   // X**2 + Y**2 - radius = 0.0
35   gp_Trsf T;
36   T.SetTransformation (pos);
37   Standard_Real T11 = T.Value (1, 1);
38   Standard_Real T12 = T.Value (1, 2);
39   Standard_Real T13 = T.Value (1, 3);
40   Standard_Real T14 = T.Value (1, 4);
41   Standard_Real T21 = T.Value (2, 1);
42   Standard_Real T22 = T.Value (2, 2);
43   Standard_Real T23 = T.Value (2, 3);
44   Standard_Real T24 = T.Value (2, 4);
45
46   A1 = T11 * T11 + T21 * T21;
47   A2 = T12 * T12 + T22 * T22;
48   A3 = T13 * T13 + T23 * T23;
49   B1 = T11 * T12 + T21 * T22;
50   B2 = T11 * T13 + T21 * T23;
51   B3 = T12 * T13 + T22 * T23;
52   C1 = T11 * T14 + T21 * T24;
53   C2 = T12 * T14 + T22 * T24;
54   C3 = T13 * T14 + T23 * T24;
55   D  = T14 * T14 + T24 * T24 - radius * radius;  
56 }
57
58 void gp_Cylinder::Mirror (const gp_Pnt& P)
59 { pos.Mirror (P); }
60
61 gp_Cylinder gp_Cylinder::Mirrored (const gp_Pnt& P) const
62 {
63   gp_Cylinder C = *this;
64   C.pos.Mirror (P);
65   return C;
66 }
67
68 void gp_Cylinder::Mirror (const gp_Ax1& A1)
69 { pos.Mirror (A1); }
70
71 gp_Cylinder gp_Cylinder::Mirrored (const gp_Ax1& A1) const
72 {
73   gp_Cylinder C = *this;
74   C.pos.Mirror (A1);
75   return C;
76 }
77
78 void gp_Cylinder::Mirror (const gp_Ax2& A2)
79 { pos.Mirror (A2); }
80
81 gp_Cylinder gp_Cylinder::Mirrored (const gp_Ax2& A2) const
82 {
83   gp_Cylinder C = *this;
84   C.pos.Mirror (A2);
85   return C;
86 }
87