Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:57:12

0001 // Created on: 1992-12-04
0002 // Created by: Isabelle GRIGNON
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 _BRepGProp_HeaderFile
0018 #define _BRepGProp_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Boolean.hxx>
0025 #include <gp_XYZ.hxx>
0026 #include <NCollection_Array1.hxx>
0027 
0028 class TopoDS_Shape;
0029 class GProp_GProps;
0030 class gp_Pln;
0031 
0032 //! Provides global functions to compute a shape's global
0033 //! properties for lines, surfaces or volumes, and bring
0034 //! them together with the global properties already
0035 //! computed for a geometric system.
0036 //! The global properties computed for a system are :
0037 //! - its mass,
0038 //! - its center of mass,
0039 //! - its matrix of inertia,
0040 //! - its moment about an axis,
0041 //! - its radius of gyration about an axis,
0042 //! - and its principal properties of inertia such as
0043 //! principal axis, principal moments, principal radius of gyration.
0044 class BRepGProp
0045 {
0046 public:
0047   DEFINE_STANDARD_ALLOC
0048 
0049   //! Computes the linear global properties of the shape S,
0050   //! i.e. the global properties induced by each edge of the
0051   //! shape S, and brings them together with the global
0052   //! properties still retained by the framework LProps. If
0053   //! the current system of LProps was empty, its global
0054   //! properties become equal to the linear global
0055   //! properties of S.
0056   //! For this computation no linear density is attached to
0057   //! the edges. So, for example, the added mass
0058   //! corresponds to the sum of the lengths of the edges of
0059   //! S. The density of the composed systems, i.e. that of
0060   //! each component of the current system of LProps, and
0061   //! that of S which is considered to be equal to 1, must be coherent.
0062   //! Note that this coherence cannot be checked. You are
0063   //! advised to use a separate framework for each
0064   //! density, and then to bring these frameworks together
0065   //! into a global one.
0066   //! The point relative to which the inertia of the system is
0067   //! computed is the reference point of the framework LProps.
0068   //! Note: if your programming ensures that the framework
0069   //! LProps retains only linear global properties (brought
0070   //! together for example, by the function
0071   //! LinearProperties) for objects the density of which is
0072   //! equal to 1 (or is not defined), the function Mass will
0073   //! return the total length of edges of the system analysed by LProps.
0074   //! Warning
0075   //! No check is performed to verify that the shape S
0076   //! retains truly linear properties. If S is simply a vertex, it
0077   //! is not considered to present any additional global properties.
0078   //! SkipShared is a special flag, which allows taking in calculation
0079   //! shared topological entities or not.
0080   //! For ex., if SkipShared = True, edges, shared by two or more faces,
0081   //! are taken into calculation only once.
0082   //! If we have cube with sizes 1, 1, 1, its linear properties = 12
0083   //! for SkipEdges = true and 24 for SkipEdges = false.
0084   //! UseTriangulation is a special flag, which defines preferable
0085   //! source of geometry data. If UseTriangulation = false,
0086   //! exact geometry objects (curves) are used, otherwise polygons of
0087   //! triangulation are used first.
0088   Standard_EXPORT static void LinearProperties(const TopoDS_Shape& S,
0089                                                GProp_GProps&       LProps,
0090                                                const bool          SkipShared       = false,
0091                                                const bool          UseTriangulation = false);
0092 
0093   //! Computes the surface global properties of the
0094   //! shape S, i.e. the global properties induced by each
0095   //! face of the shape S, and brings them together with
0096   //! the global properties still retained by the framework
0097   //! SProps. If the current system of SProps was empty,
0098   //! its global properties become equal to the surface
0099   //! global properties of S.
0100   //! For this computation, no surface density is attached
0101   //! to the faces. Consequently, the added mass
0102   //! corresponds to the sum of the areas of the faces of
0103   //! S. The density of the component systems, i.e. that
0104   //! of each component of the current system of
0105   //! SProps, and that of S which is considered to be
0106   //! equal to 1, must be coherent.
0107   //! Note that this coherence cannot be checked. You
0108   //! are advised to use a framework for each different
0109   //! value of density, and then to bring these
0110   //! frameworks together into a global one.
0111   //! The point relative to which the inertia of the system
0112   //! is computed is the reference point of the framework SProps.
0113   //! Note : if your programming ensures that the
0114   //! framework SProps retains only surface global
0115   //! properties, brought together, for example, by the
0116   //! function SurfaceProperties, for objects the density
0117   //! of which is equal to 1 (or is not defined), the
0118   //! function Mass will return the total area of faces of
0119   //! the system analysed by SProps.
0120   //! Warning
0121   //! No check is performed to verify that the shape S
0122   //! retains truly surface properties. If S is simply a
0123   //! vertex, an edge or a wire, it is not considered to
0124   //! present any additional global properties.
0125   //! SkipShared is a special flag, which allows taking in calculation
0126   //! shared topological entities or not.
0127   //! For ex., if SkipShared = True, faces, shared by two or more shells,
0128   //! are taken into calculation only once.
0129   //! UseTriangulation is a special flag, which defines preferable
0130   //! source of geometry data. If UseTriangulation = false,
0131   //! exact geometry objects (surfaces) are used,
0132   //! otherwise face triangulations are used first.
0133   Standard_EXPORT static void SurfaceProperties(const TopoDS_Shape& S,
0134                                                 GProp_GProps&       SProps,
0135                                                 const bool          SkipShared       = false,
0136                                                 const bool          UseTriangulation = false);
0137 
0138   //! Updates <SProps> with the shape <S>, that contains its principal properties.
0139   //! The surface properties of all the faces in <S> are computed.
0140   //! Adaptive 2D Gauss integration is used.
0141   //! Parameter Eps sets maximal relative error of computed mass (area) for each face.
0142   //! Error is calculated as std::abs((M(i+1)-M(i))/M(i+1)), M(i+1) and M(i) are values
0143   //! for two successive steps of adaptive integration.
0144   //! Method returns estimation of relative error reached for whole shape.
0145   //! WARNING: if Eps > 0.001 algorithm performs non-adaptive integration.
0146   //! SkipShared is a special flag, which allows taking in calculation
0147   //! shared topological entities or not
0148   //! For ex., if SkipShared = True, faces, shared by two or more shells,
0149   //! are taken into calculation only once.
0150   Standard_EXPORT static double SurfaceProperties(const TopoDS_Shape& S,
0151                                                   GProp_GProps&       SProps,
0152                                                   const double        Eps,
0153                                                   const bool          SkipShared = false);
0154   //!
0155   //! Computes the global volume properties of the solid
0156   //! S, and brings them together with the global
0157   //! properties still retained by the framework VProps. If
0158   //! the current system of VProps was empty, its global
0159   //! properties become equal to the global properties of S for volume.
0160   //! For this computation, no volume density is attached
0161   //! to the solid. Consequently, the added mass
0162   //! corresponds to the volume of S. The density of the
0163   //! component systems, i.e. that of each component of
0164   //! the current system of VProps, and that of S which
0165   //! is considered to be equal to 1, must be coherent to each other.
0166   //! Note that this coherence cannot be checked. You
0167   //! are advised to use a separate framework for each
0168   //! density, and then to bring these frameworks
0169   //! together into a global one.
0170   //! The point relative to which the inertia of the system
0171   //! is computed is the reference point of the framework VProps.
0172   //! Note: if your programming ensures that the
0173   //! framework VProps retains only global properties of
0174   //! volume (brought together for example, by the
0175   //! function VolumeProperties) for objects the density
0176   //! of which is equal to 1 (or is not defined), the
0177   //! function Mass will return the total volume of the
0178   //! solids of the system analysed by VProps.
0179   //! Warning
0180   //! The shape S must represent an object whose
0181   //! global volume properties can be computed. It may
0182   //! be a finite solid, or a series of finite solids all
0183   //! oriented in a coherent way. Nonetheless, S must be
0184   //! exempt of any free boundary. Note that these
0185   //! conditions of coherence are not checked by this
0186   //! algorithm, and results will be false if they are not respected.
0187   //! SkipShared a is special flag, which allows taking in calculation
0188   //! shared topological entities or not.
0189   //! For ex., if SkipShared = True, the volumes formed by the equal
0190   //! (the same TShape, location and orientation) faces are taken
0191   //! into calculation only once.
0192   //! UseTriangulation is a special flag, which defines preferable
0193   //! source of geometry data. If UseTriangulation = false,
0194   //! exact geometry objects (surfaces) are used,
0195   //! otherwise face triangulations are used first.
0196   Standard_EXPORT static void VolumeProperties(const TopoDS_Shape& S,
0197                                                GProp_GProps&       VProps,
0198                                                const bool          OnlyClosed       = false,
0199                                                const bool          SkipShared       = false,
0200                                                const bool          UseTriangulation = false);
0201 
0202   //! Updates <VProps> with the shape <S>, that contains its principal properties.
0203   //! The volume properties of all the FORWARD and REVERSED faces in <S> are computed.
0204   //! If OnlyClosed is True then computed faces must belong to closed Shells.
0205   //! Adaptive 2D Gauss integration is used.
0206   //! Parameter Eps sets maximal relative error of computed mass (volume) for each face.
0207   //! Error is calculated as std::abs((M(i+1)-M(i))/M(i+1)), M(i+1) and M(i) are values
0208   //! for two successive steps of adaptive integration.
0209   //! Method returns estimation of relative error reached for whole shape.
0210   //! WARNING: if Eps > 0.001 algorithm performs non-adaptive integration.
0211   //! SkipShared is a special flag, which allows taking in calculation shared
0212   //! topological entities or not.
0213   //! For ex., if SkipShared = True, the volumes formed by the equal
0214   //! (the same TShape, location and orientation)
0215   //! faces are taken into calculation only once.
0216   Standard_EXPORT static double VolumeProperties(const TopoDS_Shape& S,
0217                                                  GProp_GProps&       VProps,
0218                                                  const double        Eps,
0219                                                  const bool          OnlyClosed = false,
0220                                                  const bool          SkipShared = false);
0221 
0222   //! Updates <VProps> with the shape <S>, that contains its principal properties.
0223   //! The volume properties of all the FORWARD and REVERSED faces in <S> are computed.
0224   //! If OnlyClosed is True then computed faces must belong to closed Shells.
0225   //! Adaptive 2D Gauss integration is used.
0226   //! Parameter IsUseSpan says if it is necessary to define spans on a face.
0227   //! This option has an effect only for BSpline faces.
0228   //! Parameter Eps sets maximal relative error of computed property for each face.
0229   //! Error is delivered by the adaptive Gauss-Kronrod method of integral computation
0230   //! that is used for properties computation.
0231   //! Method returns estimation of relative error reached for whole shape.
0232   //! Returns negative value if the computation is failed.
0233   //! SkipShared is a special flag, which allows taking in calculation
0234   //! shared topological entities or not.
0235   //! For ex., if SkipShared = True, the volumes formed by the equal
0236   //! (the same TShape, location and orientation) faces are taken into calculation only once.
0237   Standard_EXPORT static double VolumePropertiesGK(const TopoDS_Shape& S,
0238                                                    GProp_GProps&       VProps,
0239                                                    const double        Eps        = 0.001,
0240                                                    const bool          OnlyClosed = false,
0241                                                    const bool          IsUseSpan  = false,
0242                                                    const bool          CGFlag     = false,
0243                                                    const bool          IFlag      = false,
0244                                                    const bool          SkipShared = false);
0245 
0246   Standard_EXPORT static double VolumePropertiesGK(const TopoDS_Shape& S,
0247                                                    GProp_GProps&       VProps,
0248                                                    const gp_Pln&       thePln,
0249                                                    const double        Eps        = 0.001,
0250                                                    const bool          OnlyClosed = false,
0251                                                    const bool          IsUseSpan  = false,
0252                                                    const bool          CGFlag     = false,
0253                                                    const bool          IFlag      = false,
0254                                                    const bool          SkipShared = false);
0255 };
0256 
0257 #endif // _BRepGProp_HeaderFile