0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / GProp / GProp_PrincipalProps.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
16 #include <gp_Pnt.hxx>
17 #include <gp_Vec.hxx>
18 #include <GProp_PrincipalProps.hxx>
19 #include <GProp_UndefinedAxis.hxx>
20
21 typedef gp_Vec Vec;
22 typedef gp_Pnt Pnt;
23
24
25
26
27
28    GProp_PrincipalProps::GProp_PrincipalProps () {
29
30       i1= i2 = i3 = RealLast();
31       r1 = r2 = r3 = RealLast();
32       v1 = Vec (1.0, 0.0, 0.0);
33       v2 = Vec (0.0, 1.0, 0.0);
34       v3 = Vec (0.0, 0.0, 1.0);
35       g = Pnt (RealLast(), RealLast(), RealLast());
36    }
37
38
39    GProp_PrincipalProps::GProp_PrincipalProps (
40    const Standard_Real Ixx, const Standard_Real Iyy, const Standard_Real Izz, 
41    const Standard_Real Rxx, const Standard_Real Ryy, const Standard_Real Rzz,
42    const gp_Vec& Vxx, const gp_Vec& Vyy, const gp_Vec& Vzz, const gp_Pnt& G) :
43    i1 (Ixx), i2 (Iyy), i3 (Izz), r1 (Rxx), r2 (Ryy), r3 (Rzz),
44    v1 (Vxx), v2 (Vyy), v3 (Vzz), g (G) { }
45
46
47    Standard_Boolean GProp_PrincipalProps::HasSymmetryAxis () const {
48
49 //     Standard_Real Eps1 = Abs(Epsilon (i1));
50 //     Standard_Real Eps2 = Abs(Epsilon (i2));
51      const Standard_Real aRelTol = 1.e-10;
52      Standard_Real Eps1 = Abs(i1)*aRelTol;
53      Standard_Real Eps2 = Abs(i2)*aRelTol;
54      return (Abs (i1 - i2) <= Eps1 || Abs (i1 - i3) <= Eps1 ||
55              Abs (i2 - i3) <= Eps2);
56    }
57
58    Standard_Boolean GProp_PrincipalProps::HasSymmetryAxis (const Standard_Real aTol) const {
59
60
61      Standard_Real Eps1 = Abs(i1*aTol) + Abs(Epsilon(i1));
62      Standard_Real Eps2 = Abs(i2*aTol) + Abs(Epsilon(i2));
63      return (Abs (i1 - i2) <= Eps1 || Abs (i1 - i3) <= Eps1 ||
64              Abs (i2 - i3) <= Eps2);
65    }
66
67
68    Standard_Boolean GProp_PrincipalProps::HasSymmetryPoint () const {
69
70 //     Standard_Real Eps1 = Abs(Epsilon (i1));
71      const Standard_Real aRelTol = 1.e-10;
72      Standard_Real Eps1 = Abs(i1)*aRelTol;
73      return (Abs (i1 - i2) <= Eps1 && Abs (i1 - i3) <= Eps1);
74    }
75
76    Standard_Boolean GProp_PrincipalProps::HasSymmetryPoint (const Standard_Real aTol) const {
77
78      Standard_Real Eps1 = Abs(i1*aTol) + Abs(Epsilon(i1));
79      return (Abs (i1 - i2) <= Eps1 && Abs (i1 - i3) <= Eps1);
80    }
81
82
83    void GProp_PrincipalProps::Moments (Standard_Real& Ixx, Standard_Real& Iyy, Standard_Real& Izz) const {
84
85       Ixx = i1;
86       Iyy = i2;
87       Izz = i3;
88    }
89
90
91    const Vec& GProp_PrincipalProps::FirstAxisOfInertia () const {return  v1;}
92
93
94    const Vec& GProp_PrincipalProps::SecondAxisOfInertia () const {return  v2;}
95
96
97    const Vec& GProp_PrincipalProps::ThirdAxisOfInertia () const {return v3;}
98
99
100    void GProp_PrincipalProps::RadiusOfGyration (
101    Standard_Real& Rxx, Standard_Real& Ryy, Standard_Real& Rzz) const {
102    
103      Rxx = r1;
104      Ryy = r2;
105      Rzz = r3;
106    }
107
108
109
110
111
112
113