Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-08 09:16:20

0001 // Created on: 1992-08-24
0002 // Created by: Michel CHAUVAT
0003 // Copyright (c) 1992-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _GProp_GProps_HeaderFile
0018 #define _GProp_GProps_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <gp_Pnt.hxx>
0024 #include <gp_Mat.hxx>
0025 class gp_Ax1;
0026 class GProp_PrincipalProps;
0027 
0028 //! Implements a general mechanism to compute the global properties of
0029 //! a "compound geometric system" in 3d space    by composition of the
0030 //! global properties of "elementary geometric entities"       such as
0031 //! (curve, surface, solid, set of points).  It is possible to compose
0032 //! the properties of several "compound geometric systems" too.
0033 //!
0034 //! To computes the global properties of a compound geometric
0035 //! system you should :
0036 //! . declare the GProps using a constructor which initializes the
0037 //! GProps and defines the location point used to compute the inertia
0038 //! . compose the global properties of your geometric components with
0039 //! the properties of your system using the method Add.
0040 //!
0041 //! To compute the global properties of the geometric components of
0042 //! the system you should  use the services of the following classes :
0043 //! - class PGProps for a set of points,
0044 //! - class CGProps for a curve,
0045 //! - class SGProps for a surface,
0046 //! - class VGProps for a "solid".
0047 //! The classes CGProps, SGProps, VGProps are generic classes and
0048 //! must be instantiated for your application.
0049 //!
0050 //! The global properties computed are :
0051 //! - the dimension (length, area or volume)
0052 //! - the mass,
0053 //! - the centre of mass,
0054 //! - the moments of inertia (static moments and quadratic moments),
0055 //! - the moment about an axis,
0056 //! - the radius of gyration about an axis,
0057 //! - the principal properties of inertia  :
0058 //! (sea also class PrincipalProps)
0059 //! . the principal moments,
0060 //! . the principal axis of inertia,
0061 //! . the principal radius of gyration,
0062 //!
0063 //! Example of utilisation in a simplified C++ implementation :
0064 //!
0065 //! //declares the GProps, the point (0.0, 0.0, 0.0) of the
0066 //! //absolute cartesian coordinate system is used as
0067 //! //default reference point to compute the centre of mass
0068 //! GProp_GProps System ();
0069 //!
0070 //! //computes the inertia of a 3d curve
0071 //! Your_CGProps Component1 (curve, ....);
0072 //!
0073 //! //computes the inertia of surfaces
0074 //! Your_SGprops Component2 (surface1, ....);
0075 //! Your_SGprops Component3 (surface2,....);
0076 //!
0077 //! //composes the global properties of components 1, 2, 3
0078 //! //a density can be associated with the components, the
0079 //! //density can be defaulted to 1.
0080 //! Real Density1 = 2.0;
0081 //! Real Density2 = 3.0;
0082 //! System.Add (Component1, Density1);
0083 //! System.Add (Component2, Density2);
0084 //! System.Add (Component3);
0085 //!
0086 //! //returns the centre of mass of the system in the
0087 //! //absolute cartesian coordinate system
0088 //! gp_Pnt G = System.CentreOfMass ();
0089 //!
0090 //! //computes the principales inertia of the system
0091 //! GProp_PrincipalProps Pp  = System.PrincipalProperties();
0092 //!
0093 //! //returns the principal moments and radius of gyration
0094 //! Real Ixx, Iyy, Izz, Rxx, Ryy, Rzz;
0095 //! Pp.Moments (Ixx, Iyy, Izz);
0096 //! Pp.RadiusOfGyration (Ixx, Iyy, Izz);
0097 class GProp_GProps
0098 {
0099 public:
0100   DEFINE_STANDARD_ALLOC
0101 
0102   //! The origin (0, 0, 0) of the absolute cartesian coordinate system
0103   //! is used to compute the global properties.
0104   Standard_EXPORT GProp_GProps();
0105 
0106   //! The point SystemLocation is used to compute the global properties
0107   //! of the system. For more accuracy it is better to define this
0108   //! point closed to the location of the system. For example it could
0109   //! be a point around the centre of mass of the system.
0110   //! This point is referred to as the reference point for
0111   //! this framework. For greater accuracy it is better for
0112   //! the reference point to be close to the location of the
0113   //! system. It can, for example, be a point near the
0114   //! center of mass of the system.
0115   //! At initialization, the framework is empty; i.e. it
0116   //! retains no dimensional information such as mass, or
0117   //! inertia. However, it is now able to bring together
0118   //! global properties of various other systems, whose
0119   //! global properties have already been computed
0120   //! using another framework. To do this, use the
0121   //! function Add to define the components of the
0122   //! system. Use it once per component of the system,
0123   //! and then use the interrogation functions available to
0124   //! access the computed values.
0125   Standard_EXPORT GProp_GProps(const gp_Pnt& SystemLocation);
0126 
0127   //! Either
0128   //! - initializes the global properties retained by this
0129   //! framework from those retained by the framework Item, or
0130   //! - brings together the global properties still retained by
0131   //! this framework with those retained by the framework Item.
0132   //! The value Density, which is 1.0 by default, is used as
0133   //! the density of the system analysed by Item.
0134   //! Sometimes the density will have already been given at
0135   //! the time of construction of the framework Item. This
0136   //! may be the case for example, if Item is a
0137   //! GProp_PGProps framework built to compute the
0138   //! global properties of a set of points ; or another
0139   //! GProp_GProps object which already retains
0140   //! composite global properties. In these cases the real
0141   //! density was perhaps already taken into account at the
0142   //! time of construction of Item. Note that this is not
0143   //! checked: if the density of parts of the system is taken
0144   //! into account two or more times, results of the
0145   //! computation will be false.
0146   //! Notes :
0147   //! - The point relative to which the inertia of Item is
0148   //! computed (i.e. the reference point of Item) may be
0149   //! different from the reference point in this
0150   //! framework. Huygens' theorem is applied
0151   //! automatically to transfer inertia values to the
0152   //! reference point in this framework.
0153   //! - The function Add is used once per component of
0154   //! the system. After that, you use the interrogation
0155   //! functions available to access values computed for the system.
0156   //! - The system whose global properties are already
0157   //! brought together by this framework is referred to
0158   //! as the current system. However, the current system
0159   //! is not retained by this framework, which maintains
0160   //! only its global properties.
0161   //! Exceptions
0162   //! Standard_DomainError if Density is less than or
0163   //! equal to gp::Resolution().
0164   Standard_EXPORT void Add(const GProp_GProps& Item, const Standard_Real Density = 1.0);
0165 
0166   //! Returns the mass of the current system.
0167   //! If no density is attached to the components of the
0168   //! current system the returned value corresponds to :
0169   //! - the total length of the edges of the current
0170   //! system if this framework retains only linear
0171   //! properties, as is the case for example, when
0172   //! using only the LinearProperties function to
0173   //! combine properties of lines from shapes, or
0174   //! - the total area of the faces of the current system if
0175   //! this framework retains only surface properties,
0176   //! as is the case for example, when using only the
0177   //! SurfaceProperties function to combine
0178   //! properties of surfaces from shapes, or
0179   //! - the total volume of the solids of the current
0180   //! system if this framework retains only volume
0181   //! properties, as is the case for example, when
0182   //! using only the VolumeProperties function to
0183   //! combine properties of volumes from solids.
0184   //! Warning
0185   //! A length, an area, or a volume is computed in the
0186   //! current data unit system. The mass of a single
0187   //! object is obtained by multiplying its length, its area
0188   //! or its volume by the given density. You must be
0189   //! consistent with respect to the units used.
0190   Standard_EXPORT Standard_Real Mass() const;
0191 
0192   //! Returns the center of mass of the current system. If
0193   //! the gravitational field is uniform, it is the center of gravity.
0194   //! The coordinates returned for the center of mass are
0195   //! expressed in the absolute Cartesian coordinate system.
0196   Standard_EXPORT gp_Pnt CentreOfMass() const;
0197 
0198   //! returns the matrix of inertia. It is a symmetrical matrix.
0199   //! The coefficients of the matrix are the quadratic moments of
0200   //! inertia.
0201   //!
0202   //! | Ixx  Ixy  Ixz |
0203   //! matrix =    | Ixy  Iyy  Iyz |
0204   //! | Ixz  Iyz  Izz |
0205   //!
0206   //! The moments of inertia are denoted by Ixx, Iyy, Izz.
0207   //! The products of inertia are denoted by Ixy, Ixz, Iyz.
0208   //! The matrix of inertia is returned in the central coordinate
0209   //! system (G, Gx, Gy, Gz) where G is the centre of mass of the
0210   //! system and Gx, Gy, Gz the directions parallel to the X(1,0,0)
0211   //! Y(0,1,0) Z(0,0,1) directions of the absolute cartesian
0212   //! coordinate system. It is possible to compute the matrix of
0213   //! inertia at another location point using the Huyghens theorem
0214   //! (you can use the method of package GProp : HOperator).
0215   Standard_EXPORT gp_Mat MatrixOfInertia() const;
0216 
0217   //! Returns Ix, Iy, Iz, the static moments of inertia of the
0218   //! current system; i.e. the moments of inertia about the
0219   //! three axes of the Cartesian coordinate system.
0220   Standard_EXPORT void StaticMoments(Standard_Real& Ix, Standard_Real& Iy, Standard_Real& Iz) const;
0221 
0222   //! computes the moment of inertia of the material system about the
0223   //! axis A.
0224   Standard_EXPORT Standard_Real MomentOfInertia(const gp_Ax1& A) const;
0225 
0226   //! Computes the principal properties of inertia of the current system.
0227   //! There is always a set of axes for which the products
0228   //! of inertia of a geometric system are equal to 0; i.e. the
0229   //! matrix of inertia of the system is diagonal. These axes
0230   //! are the principal axes of inertia. Their origin is
0231   //! coincident with the center of mass of the system. The
0232   //! associated moments are called the principal moments of inertia.
0233   //! This function computes the eigen values and the
0234   //! eigen vectors of the matrix of inertia of the system.
0235   //! Results are stored by using a presentation framework
0236   //! of principal properties of inertia
0237   //! (GProp_PrincipalProps object) which may be
0238   //! queried to access the value sought.
0239   Standard_EXPORT GProp_PrincipalProps PrincipalProperties() const;
0240 
0241   //! Returns the radius of gyration of the current system about the axis A.
0242   Standard_EXPORT Standard_Real RadiusOfGyration(const gp_Ax1& A) const;
0243 
0244 protected:
0245   gp_Pnt        g;
0246   gp_Pnt        loc;
0247   Standard_Real dim;
0248   gp_Mat        inertia;
0249 
0250 private:
0251 };
0252 
0253 #endif // _GProp_GProps_HeaderFile