|
|
|||
File indexing completed on 2026-09-15 09:15:05
0001 // Copyright (c) 2015 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _BRepGProp_Gauss_HeaderFile 0015 #define _BRepGProp_Gauss_HeaderFile 0016 0017 #include <NCollection_Handle.hxx> 0018 #include <NCollection_Array1.hxx> 0019 0020 template <typename T> 0021 class math_VectorBase; 0022 using math_Vector = math_VectorBase<double>; 0023 0024 //! Class performs computing of the global inertia properties 0025 //! of geometric object in 3D space by adaptive and non-adaptive 0026 //! 2D Gauss integration algorithms. 0027 class BRepGProp_Gauss 0028 { 0029 //! Auxiliary structure for storing of inertial moments. 0030 struct Inertia 0031 { 0032 //! Mass of the current system (without density). 0033 //! May correspond to: length, area, volume. 0034 double Mass; 0035 0036 //! Static moments of inertia. 0037 double Ix; 0038 double Iy; 0039 double Iz; 0040 0041 //! Quadratic moments of inertia. 0042 double Ixx; 0043 double Iyy; 0044 double Izz; 0045 double Ixy; 0046 double Ixz; 0047 double Iyz; 0048 0049 //! Default constructor. 0050 Inertia(); 0051 0052 //! Zeroes all values. 0053 void Reset(); 0054 }; 0055 0056 typedef NCollection_Handle<NCollection_Array1<Inertia>> InertiaArray; 0057 typedef double (*BRepGProp_GaussFunc)(const double, const double); 0058 0059 public: //! @name public API 0060 //! Describes types of geometric objects. 0061 //! - Vinert is 3D closed region of space delimited with: 0062 //! -- Surface; 0063 //! -- Point and Surface; 0064 //! -- Plane and Surface. 0065 //! - Sinert is face in 3D space. 0066 typedef enum 0067 { 0068 Vinert = 0, 0069 Sinert 0070 } BRepGProp_GaussType; 0071 0072 //! Constructor 0073 Standard_EXPORT explicit BRepGProp_Gauss(const BRepGProp_GaussType theType); 0074 0075 //! Computes the global properties of a solid region of 3D space which can be 0076 //! delimited by the surface and point or surface and plane. Surface can be closed. 0077 //! The method is quick and its precision is enough for many cases of analytical surfaces. 0078 //! Non-adaptive 2D Gauss integration with predefined numbers of Gauss points 0079 //! is used. Numbers of points depend on types of surfaces and curves. 0080 //! Error of the computation is not calculated. 0081 //! @param theSurface - bounding surface of the region; 0082 //! @param theLocation - location of the point or the plane; 0083 //! @param theCoeff - plane coefficients; 0084 //! @param theIsByPoint - flag of restricition (point/plane); 0085 //! @param[out] theOutMass - mass (volume) of region; 0086 //! @param[out] theOutGravityCenter - garvity center of region; 0087 //! @param[out] theOutInertia - matrix of inertia; 0088 Standard_EXPORT void Compute(const BRepGProp_Face& theSurface, 0089 const gp_Pnt& theLocation, 0090 const double theCoeff[], 0091 const bool theIsByPoint, 0092 double& theOutMass, 0093 gp_Pnt& theOutGravityCenter, 0094 gp_Mat& theOutInertia); 0095 0096 //! Computes the global properties of a surface. Surface can be closed. 0097 //! The method is quick and its precision is enough for many cases of analytical surfaces. 0098 //! Non-adaptive 2D Gauss integration with predefined numbers of Gauss points 0099 //! is used. Numbers of points depend on types of surfaces and curves. 0100 //! Error of the computation is not calculated. 0101 //! @param theSurface - bounding surface of the region; 0102 //! @param theLocation - surface location; 0103 //! @param[out] theOutMass - mass (volume) of region; 0104 //! @param[out] theOutGravityCenter - garvity center of region; 0105 //! @param[out] theOutInertia - matrix of inertia; 0106 Standard_EXPORT void Compute(const BRepGProp_Face& theSurface, 0107 const gp_Pnt& theLocation, 0108 double& theOutMass, 0109 gp_Pnt& theOutGravityCenter, 0110 gp_Mat& theOutInertia); 0111 0112 //! Computes the global properties of a region of 3D space which can be 0113 //! delimited by the surface and point or surface and plane. Surface can be closed. 0114 //! The method is quick and its precision is enough for many cases of analytical surfaces. 0115 //! Non-adaptive 2D Gauss integration with predefined numbers of Gauss points is used. 0116 //! Numbers of points depend on types of surfaces and curves. 0117 //! Error of the computation is not calculated. 0118 //! @param theSurface - bounding surface of the region; 0119 //! @param theDomain - surface boundings; 0120 //! @param theLocation - location of the point or the plane; 0121 //! @param theCoeff - plane coefficients; 0122 //! @param theIsByPoint - flag of restricition (point/plane); 0123 //! @param[out] theOutMass - mass (volume) of region; 0124 //! @param[out] theOutGravityCenter - garvity center of region; 0125 //! @param[out] theOutInertia - matrix of inertia; 0126 Standard_EXPORT void Compute(BRepGProp_Face& theSurface, 0127 BRepGProp_Domain& theDomain, 0128 const gp_Pnt& theLocation, 0129 const double theCoeff[], 0130 const bool theIsByPoint, 0131 double& theOutMass, 0132 gp_Pnt& theOutGravityCenter, 0133 gp_Mat& theOutInertia); 0134 0135 //! Computes the global properties of a surface. Surface can be closed. 0136 //! The method is quick and its precision is enough for many cases of analytical surfaces. 0137 //! Non-adaptive 2D Gauss integration with predefined numbers of Gauss points 0138 //! is used. Numbers of points depend on types of surfaces and curves. 0139 //! Error of the computation is not calculated. 0140 //! @param theSurface - bounding surface of the region; 0141 //! @param theDomain - surface boundings; 0142 //! @param theLocation - surface location; 0143 //! @param[out] theOutMass - mass (volume) of region; 0144 //! @param[out] theOutGravityCenter - garvity center of region; 0145 //! @param[out] theOutInertia - matrix of inertia; 0146 Standard_EXPORT void Compute(BRepGProp_Face& theSurface, 0147 BRepGProp_Domain& theDomain, 0148 const gp_Pnt& theLocation, 0149 double& theOutMass, 0150 gp_Pnt& theOutGravityCenter, 0151 gp_Mat& theOutInertia); 0152 0153 //! Computes the global properties of the region of 3D space which can be 0154 //! delimited by the surface and point or surface and plane. 0155 //! Adaptive 2D Gauss integration is used. 0156 //! If Epsilon more than 0.001 then algorithm performs non-adaptive integration. 0157 //! @param theSurface - bounding surface of the region; 0158 //! @param theDomain - surface boundings; 0159 //! @param theLocation - location of the point or the plane; 0160 //! @param theEps - maximal relative error of computed mass (volume) for face; 0161 //! @param theCoeff - plane coefficients; 0162 //! @param theIsByPoint - flag of restricition (point/plane); 0163 //! @param[out] theOutMass - mass (volume) of region; 0164 //! @param[out] theOutGravityCenter - garvity center of region; 0165 //! @param[out] theOutInertia - matrix of inertia; 0166 //! @return value of error which is calculated as 0167 //! std::abs((M(i+1)-M(i))/M(i+1)), M(i+1) and M(i) are values 0168 //! for two successive steps of adaptive integration. 0169 Standard_EXPORT double Compute(BRepGProp_Face& theSurface, 0170 BRepGProp_Domain& theDomain, 0171 const gp_Pnt& theLocation, 0172 const double theEps, 0173 const double theCoeff[], 0174 const bool theByPoint, 0175 double& theOutMass, 0176 gp_Pnt& theOutGravityCenter, 0177 gp_Mat& theOutInertia); 0178 0179 //! Computes the global properties of the face. Adaptive 2D Gauss integration is used. 0180 //! If Epsilon more than 0.001 then algorithm performs non-adaptive integration. 0181 //! @param theSurface - bounding surface of the region; 0182 //! @param theDomain - surface boundings; 0183 //! @param theLocation - surface location; 0184 //! @param theEps - maximal relative error of computed mass (square) for face; 0185 //! @param[out] theOutMass - mass (volume) of region; 0186 //! @param[out] theOutGravityCenter - garvity center of region; 0187 //! @param[out] theOutInertia - matrix of inertia; 0188 //! @return value of error which is calculated as 0189 //! std::abs((M(i+1)-M(i))/M(i+1)), M(i+1) and M(i) are values 0190 //! for two successive steps of adaptive integration. 0191 Standard_EXPORT double Compute(BRepGProp_Face& theSurface, 0192 BRepGProp_Domain& theDomain, 0193 const gp_Pnt& theLocation, 0194 const double theEps, 0195 double& theOutMass, 0196 gp_Pnt& theOutGravityCenter, 0197 gp_Mat& theOutInertia); 0198 0199 private: //! @name private methods 0200 BRepGProp_Gauss(BRepGProp_Gauss const&) = delete; 0201 BRepGProp_Gauss& operator=(BRepGProp_Gauss const&) = delete; 0202 0203 void computeVInertiaOfElementaryPart(const gp_Pnt& thePoint, 0204 const gp_Vec& theNormal, 0205 const gp_Pnt& theLocation, 0206 const double theWeight, 0207 const double theCoeff[], 0208 const bool theIsByPoint, 0209 BRepGProp_Gauss::Inertia& theOutInertia); 0210 0211 void computeSInertiaOfElementaryPart(const gp_Pnt& thePoint, 0212 const gp_Vec& theNormal, 0213 const gp_Pnt& theLocation, 0214 const double theWeight, 0215 BRepGProp_Gauss::Inertia& theOutInertia); 0216 0217 void checkBounds(const double theU1, const double theU2, const double theV1, const double theV2); 0218 0219 void addAndRestoreInertia(const BRepGProp_Gauss::Inertia& theInInertia, 0220 BRepGProp_Gauss::Inertia& theOutInertia); 0221 0222 void multAndRestoreInertia(const double theValue, BRepGProp_Gauss::Inertia& theInertia); 0223 0224 void convert(const BRepGProp_Gauss::Inertia& theInertia, 0225 gp_Pnt& theOutGravityCenter, 0226 gp_Mat& theOutMatrixOfInertia, 0227 double& theOutMass); 0228 0229 void convert(const BRepGProp_Gauss::Inertia& theInertia, 0230 const double theCoeff[], 0231 const bool theIsByPoint, 0232 gp_Pnt& theOutGravityCenter, 0233 gp_Mat& theOutMatrixOfInertia, 0234 double& theOutMass); 0235 0236 static int MaxSubs(const int theN, const int theCoeff = 32); 0237 0238 static void Init(NCollection_Handle<math_Vector>& theOutVec, 0239 const double theValue, 0240 const int theFirst = 0, 0241 const int theLast = 0); 0242 0243 static void InitMass(const double theValue, 0244 const int theFirst, 0245 const int theLast, 0246 InertiaArray& theArray); 0247 0248 static int FillIntervalBounds(const double theA, 0249 const double theB, 0250 const NCollection_Array1<double>& theKnots, 0251 const int theNumSubs, 0252 InertiaArray& theInerts, 0253 NCollection_Handle<math_Vector>& theParam1, 0254 NCollection_Handle<math_Vector>& theParam2, 0255 NCollection_Handle<math_Vector>& theError, 0256 NCollection_Handle<math_Vector>& theCommonError); 0257 0258 private: //! @name private fields 0259 BRepGProp_GaussType myType; //!< Type of geometric object 0260 BRepGProp_GaussFunc add; //!< Pointer on the add function 0261 BRepGProp_GaussFunc mult; //!< Pointer on the mult function 0262 }; 0263 0264 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|