0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / GProp / GProp_PrincipalProps.hxx
CommitLineData
42cf5bc1 1// Created on: 1992-02-17
2// Created by: Jean Claude VAUTHIER
3// Copyright (c) 1992-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _GProp_PrincipalProps_HeaderFile
18#define _GProp_PrincipalProps_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <Standard_Real.hxx>
25#include <gp_Vec.hxx>
26#include <gp_Pnt.hxx>
27#include <GProp_GProps.hxx>
28#include <Standard_Boolean.hxx>
29class GProp_UndefinedAxis;
30class gp_Vec;
31class gp_Pnt;
32
33
34
35//! A framework to present the principal properties of
36//! inertia of a system of which global properties are
37//! computed by a GProp_GProps object.
38//! There is always a set of axes for which the
39//! products of inertia of a geometric system are equal
40//! to 0; i.e. the matrix of inertia of the system is
41//! diagonal. These axes are the principal axes of
42//! inertia. Their origin is coincident with the center of
43//! mass of the system. The associated moments are
44//! called the principal moments of inertia.
45//! This sort of presentation object is created, filled and
46//! returned by the function PrincipalProperties for
47//! any GProp_GProps object, and can be queried to access the result.
48//! Note: The system whose principal properties of
49//! inertia are returned by this framework is referred to
50//! as the current system. The current system,
51//! however, is retained neither by this presentation
52//! framework nor by the GProp_GProps object which activates it.
53class GProp_PrincipalProps
54{
55public:
56
57 DEFINE_STANDARD_ALLOC
58
59
60 //! creates an undefined PrincipalProps.
61 Standard_EXPORT GProp_PrincipalProps();
62
63
64 //! returns true if the geometric system has an axis of symmetry.
65 //! For comparing moments relative tolerance 1.e-10 is used.
66 //! Usually it is enough for objects, restricted by faces with
67 //! analitycal geometry.
68 Standard_EXPORT Standard_Boolean HasSymmetryAxis() const;
69
70
71 //! returns true if the geometric system has an axis of symmetry.
72 //! aTol is relative tolerance for cheking equality of moments
73 //! If aTol == 0, relative tolerance is ~ 1.e-16 (Epsilon(I))
74 Standard_EXPORT Standard_Boolean HasSymmetryAxis (const Standard_Real aTol) const;
75
76
77 //! returns true if the geometric system has a point of symmetry.
78 //! For comparing moments relative tolerance 1.e-10 is used.
79 //! Usually it is enough for objects, restricted by faces with
80 //! analitycal geometry.
81 Standard_EXPORT Standard_Boolean HasSymmetryPoint() const;
82
83
84 //! returns true if the geometric system has a point of symmetry.
85 //! aTol is relative tolerance for cheking equality of moments
86 //! If aTol == 0, relative tolerance is ~ 1.e-16 (Epsilon(I))
87 Standard_EXPORT Standard_Boolean HasSymmetryPoint (const Standard_Real aTol) const;
88
89 //! Ixx, Iyy and Izz return the principal moments of inertia
90 //! in the current system.
91 //! Notes :
92 //! - If the current system has an axis of symmetry, two
93 //! of the three values Ixx, Iyy and Izz are equal. They
94 //! indicate which eigen vectors define an infinity of
95 //! axes of principal inertia.
96 //! - If the current system has a center of symmetry, Ixx,
97 //! Iyy and Izz are equal.
98 Standard_EXPORT void Moments (Standard_Real& Ixx, Standard_Real& Iyy, Standard_Real& Izz) const;
99
100 //! returns the first axis of inertia.
101 //!
102 //! if the system has a point of symmetry there is an infinity of
103 //! solutions. It is not possible to defines the three axis of
104 //! inertia.
105 Standard_EXPORT const gp_Vec& FirstAxisOfInertia() const;
106
107 //! returns the second axis of inertia.
108 //!
109 //! if the system has a point of symmetry or an axis of symmetry the
110 //! second and the third axis of symmetry are undefined.
111 Standard_EXPORT const gp_Vec& SecondAxisOfInertia() const;
112
113 //! returns the third axis of inertia.
114 //! This and the above functions return the first, second or third eigen vector of the
115 //! matrix of inertia of the current system.
116 //! The first, second and third principal axis of inertia
117 //! pass through the center of mass of the current
118 //! system. They are respectively parallel to these three eigen vectors.
119 //! Note that:
120 //! - If the current system has an axis of symmetry, any
121 //! axis is an axis of principal inertia if it passes
122 //! through the center of mass of the system, and runs
123 //! parallel to a linear combination of the two eigen
124 //! vectors of the matrix of inertia, corresponding to the
125 //! two eigen values which are equal. If the current
126 //! system has a center of symmetry, any axis passing
127 //! through the center of mass of the system is an axis
128 //! of principal inertia. Use the functions
129 //! HasSymmetryAxis and HasSymmetryPoint to
130 //! check these particular cases, where the returned
131 //! eigen vectors define an infinity of principal axis of inertia.
132 //! - The Moments function can be used to know which
133 //! of the three eigen vectors corresponds to the two
134 //! eigen values which are equal.
135 //!
136 //! if the system has a point of symmetry or an axis of symmetry the
137 //! second and the third axis of symmetry are undefined.
138 Standard_EXPORT const gp_Vec& ThirdAxisOfInertia() const;
139
140 //! Returns the principal radii of gyration Rxx, Ryy
141 //! and Rzz are the radii of gyration of the current
142 //! system about its three principal axes of inertia.
143 //! Note that:
144 //! - If the current system has an axis of symmetry,
145 //! two of the three values Rxx, Ryy and Rzz are equal.
146 //! - If the current system has a center of symmetry,
147 //! Rxx, Ryy and Rzz are equal.
148 Standard_EXPORT void RadiusOfGyration (Standard_Real& Rxx, Standard_Real& Ryy, Standard_Real& Rzz) const;
149
150
151friend
152 //! Computes the principal properties of inertia of the current system.
153 //! There is always a set of axes for which the products
154 //! of inertia of a geometric system are equal to 0; i.e. the
155 //! matrix of inertia of the system is diagonal. These axes
156 //! are the principal axes of inertia. Their origin is
157 //! coincident with the center of mass of the system. The
158 //! associated moments are called the principal moments of inertia.
159 //! This function computes the eigen values and the
160 //! eigen vectors of the matrix of inertia of the system.
161 //! Results are stored by using a presentation framework
162 //! of principal properties of inertia
163 //! (GProp_PrincipalProps object) which may be
164 //! queried to access the value sought.
165 Standard_EXPORT GProp_PrincipalProps GProp_GProps::PrincipalProperties() const;
166
167
168protected:
169
170
171
172
173
174private:
175
176
177 Standard_EXPORT GProp_PrincipalProps(const Standard_Real Ixx, const Standard_Real Iyy, const Standard_Real Izz, const Standard_Real Rxx, const Standard_Real Ryy, const Standard_Real Rzz, const gp_Vec& Vxx, const gp_Vec& Vyy, const gp_Vec& Vzz, const gp_Pnt& G);
178
179
180 Standard_Real i1;
181 Standard_Real i2;
182 Standard_Real i3;
183 Standard_Real r1;
184 Standard_Real r2;
185 Standard_Real r3;
186 gp_Vec v1;
187 gp_Vec v2;
188 gp_Vec v3;
189 gp_Pnt g;
190
191
192};
193
194
195
196
197
198
199
200#endif // _GProp_PrincipalProps_HeaderFile