0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / gp / gp_Sphere.cxx
CommitLineData
b311480e 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
7fd59977 19
7fd59977 20
21#include <gp_Sphere.ixx>
22#include <Standard_ConstructionError.hxx>
23
24void gp_Sphere::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 local de la sphere :
31 // X*X + Y*Y + Z*Z - radius * radius = 0
32 gp_Trsf T;
33 T.SetTransformation (pos);
34 Standard_Real T11 = T.Value (1, 1);
35 Standard_Real T12 = T.Value (1, 2);
36 Standard_Real T13 = T.Value (1, 3);
37 Standard_Real T14 = T.Value (1, 4);
38 Standard_Real T21 = T.Value (2, 1);
39 Standard_Real T22 = T.Value (2, 2);
40 Standard_Real T23 = T.Value (2, 3);
41 Standard_Real T24 = T.Value (2, 4);
42 Standard_Real T31 = T.Value (3, 1);
43 Standard_Real T32 = T.Value (3, 2);
44 Standard_Real T33 = T.Value (3, 3);
45 Standard_Real T34 = T.Value (3, 4);
46 A1 = T11 * T11 + T21 * T21 + T31 * T31;
47 A2 = T12 * T12 + T22 * T22 + T32 * T32;
48 A3 = T13 * T13 + T23 * T23 + T33 * T33;
49 B1 = T11 * T12 + T21 * T22 + T31 * T32;
50 B2 = T11 * T13 + T21 * T23 + T31 * T33;
51 B3 = T12 * T13 + T22 * T23 + T32 * T33;
52 C1 = T11 * T14 + T21 * T24 + T31 * T34;
53 C2 = T12 * T14 + T22 * T24 + T32 * T34;
54 C3 = T13 * T14 + T23 * T24 + T33 * T34;
55 D = T14 * T14 + T24 * T24 + T34 * T34 - radius * radius;
56}
57
58void gp_Sphere::Mirror (const gp_Pnt& P)
59{ pos.Mirror (P); }
60
61gp_Sphere gp_Sphere::Mirrored (const gp_Pnt& P) const
62{
63 gp_Sphere C = *this;
64 C.pos.Mirror (P);
65 return C;
66}
67
68void gp_Sphere::Mirror (const gp_Ax1& A1)
69{ pos.Mirror (A1); }
70
71gp_Sphere gp_Sphere::Mirrored (const gp_Ax1& A1) const
72{
73 gp_Sphere C = *this;
74 C.pos.Mirror (A1);
75 return C;
76}
77
78void gp_Sphere::Mirror (const gp_Ax2& A2)
79{ pos.Mirror (A2); }
80
81gp_Sphere gp_Sphere::Mirrored (const gp_Ax2& A2) const
82{
83 gp_Sphere C = *this;
84 C.pos.Mirror (A2);
85 return C;
86}
87