1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Coding - Apply .clang-format formatting #286

Update empty method guards to new style with regex (see PR).
Used clang-format 18.1.8.
New actions to validate code formatting is added.
Update .clang-format with disabling of include sorting.
  It is temporary changes, then include will be sorted.
Apply formatting for /src and /tools folder.
The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
This commit is contained in:
dpasukhi
2025-01-25 20:15:22 +00:00
parent dbba6f1289
commit a5a7b3185b
14005 changed files with 1273539 additions and 1195567 deletions

View File

@@ -17,23 +17,23 @@
#include <gp_Pnt.hxx>
#include <gp_XYZ.hxx>
void GProp::HOperator (
void GProp::HOperator(
const gp_Pnt& G,
const gp_Pnt& Q,
const Standard_Real Mass,
gp_Mat& Operator
const gp_Pnt& G,
const gp_Pnt& Q,
const Standard_Real Mass,
gp_Mat& Operator
) {
)
{
gp_XYZ QG = G.XYZ() - Q.XYZ();
gp_XYZ QG = G.XYZ() - Q.XYZ();
Standard_Real Ixx = QG.Y() * QG.Y() + QG.Z() * QG.Z();
Standard_Real Iyy = QG.X() * QG.X() + QG.Z() * QG.Z();
Standard_Real Izz = QG.Y() * QG.Y() + QG.X() * QG.X();
Standard_Real Ixy = - QG.X() * QG.Y();
Standard_Real Iyz = - QG.Y() * QG.Z();
Standard_Real Ixz = - QG.X() * QG.Z();
Operator.SetCols (gp_XYZ (Ixx, Ixy, Ixz), gp_XYZ (Ixy, Iyy, Iyz),
gp_XYZ (Ixz, Iyz, Izz));
Operator.Multiply (Mass);
Standard_Real Ixy = -QG.X() * QG.Y();
Standard_Real Iyz = -QG.Y() * QG.Z();
Standard_Real Ixz = -QG.X() * QG.Z();
Operator.SetCols(gp_XYZ(Ixx, Ixy, Ixz), gp_XYZ(Ixy, Iyy, Iyz), gp_XYZ(Ixz, Iyz, Izz));
Operator.Multiply(Mass);
}

View File

@@ -25,8 +25,6 @@
class gp_Pnt;
class gp_Mat;
//! This package defines algorithms to compute the global properties
//! of a set of points, a curve, a surface, a solid (non infinite
//! region of space delimited with geometric entities), a compound
@@ -42,13 +40,11 @@ class gp_Mat;
//!
//! It provides also a class to compile the average point or
//! line of a set of points.
class GProp
class GProp
{
public:
DEFINE_STANDARD_ALLOC
//! methods of package
//! Computes the matrix Operator, referred to as the
//! "Huyghens Operator" of a geometric system at the
@@ -62,8 +58,10 @@ public:
//! where Inertia/G is the matrix of inertia of the
//! system relative to its center of mass as returned by
//! the function MatrixOfInertia on any GProp_GProps object.
Standard_EXPORT static void HOperator (const gp_Pnt& G, const gp_Pnt& Q, const Standard_Real Mass, gp_Mat& Operator);
Standard_EXPORT static void HOperator(const gp_Pnt& G,
const gp_Pnt& Q,
const Standard_Real Mass,
gp_Mat& Operator);
};
#endif // _GProp_HeaderFile

View File

@@ -12,7 +12,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <ElCLib.hxx>
#include <gp_Circ.hxx>
#include <gp_Lin.hxx>
@@ -24,135 +23,130 @@
#include <math_Vector.hxx>
#include <Standard_NotImplemented.hxx>
GProp_CelGProps::GProp_CelGProps(){}
GProp_CelGProps::GProp_CelGProps() {}
void GProp_CelGProps::SetLocation(const gp_Pnt& CLocation)
{
loc = CLocation;
}
void GProp_CelGProps::Perform(const gp_Circ& C,
const Standard_Real U1,
const Standard_Real U2)
void GProp_CelGProps::Perform(const gp_Circ& C, const Standard_Real U1, const Standard_Real U2)
{
Standard_Real X0,Y0,Z0,Xa1,Ya1,Za1,Xa2,Ya2,Za2,Xa3,Ya3,Za3;
C.Location().Coord(X0,Y0,Z0);
C.XAxis().Direction().Coord(Xa1,Ya1,Za1);
C.YAxis().Direction().Coord(Xa2,Ya2,Za2);
C.Axis().Direction().Coord(Xa3,Ya3,Za3);
Standard_Real X0, Y0, Z0, Xa1, Ya1, Za1, Xa2, Ya2, Za2, Xa3, Ya3, Za3;
C.Location().Coord(X0, Y0, Z0);
C.XAxis().Direction().Coord(Xa1, Ya1, Za1);
C.YAxis().Direction().Coord(Xa2, Ya2, Za2);
C.Axis().Direction().Coord(Xa3, Ya3, Za3);
Standard_Real Ray = C.Radius();
dim = Ray*Abs(U2-U1);
Standard_Real xloc =Ray*(Sin(U2)-Sin(U1))/(U2-U1);
Standard_Real yloc =Ray*(Cos(U1)-Cos(U2))/(U2-U1);
dim = Ray * Abs(U2 - U1);
Standard_Real xloc = Ray * (Sin(U2) - Sin(U1)) / (U2 - U1);
Standard_Real yloc = Ray * (Cos(U1) - Cos(U2)) / (U2 - U1);
g.SetCoord(xloc*Xa1+yloc*Xa2+X0,xloc*Ya1+yloc*Ya2+Y0,Z0);
g.SetCoord(xloc * Xa1 + yloc * Xa2 + X0, xloc * Ya1 + yloc * Ya2 + Y0, Z0);
math_Matrix Dm(1,3,1,3);
Dm(1,1)= Ray*Ray*Ray*(U2/2-U1/2-Sin(2*U2)/4+Sin(2*U1)/4);
Dm(2,2)= Ray*Ray*Ray*(U2/2-U1/2+Sin(2*U2)/4-Sin(2*U1)/4);
Dm(3,3)= Ray*Ray*dim;
Dm(2,1)= Dm(1,2) = - Ray*Ray*Ray*(Cos(2*U1)/4-Cos(2*U2)/4);
Dm(3,1) = Dm(1,3) = 0.;
Dm(3,2) = Dm(2,3) = 0.;
math_Matrix Passage (1,3,1,3);
Passage(1,1) = Xa1; Passage(1,2) = Xa2 ;Passage(1,3) = Xa3;
Passage(2,1) = Ya1; Passage(2,2) = Ya2 ;Passage(2,3) = Ya3;
Passage(3,1) = Za1; Passage(3,2) = Za2 ;Passage(3,3) = Za3;
math_Matrix Dm(1, 3, 1, 3);
Dm(1, 1) = Ray * Ray * Ray * (U2 / 2 - U1 / 2 - Sin(2 * U2) / 4 + Sin(2 * U1) / 4);
Dm(2, 2) = Ray * Ray * Ray * (U2 / 2 - U1 / 2 + Sin(2 * U2) / 4 - Sin(2 * U1) / 4);
Dm(3, 3) = Ray * Ray * dim;
Dm(2, 1) = Dm(1, 2) = -Ray * Ray * Ray * (Cos(2 * U1) / 4 - Cos(2 * U2) / 4);
Dm(3, 1) = Dm(1, 3) = 0.;
Dm(3, 2) = Dm(2, 3) = 0.;
math_Matrix Passage(1, 3, 1, 3);
Passage(1, 1) = Xa1;
Passage(1, 2) = Xa2;
Passage(1, 3) = Xa3;
Passage(2, 1) = Ya1;
Passage(2, 2) = Ya2;
Passage(2, 3) = Ya3;
Passage(3, 1) = Za1;
Passage(3, 2) = Za2;
Passage(3, 3) = Za3;
math_Jacobi J(Dm);
math_Vector V1(1,3),V2(1,3),V3(1,3);
J.Vector(1,V1);
V1.Multiply(Passage,V1);
math_Vector V1(1, 3), V2(1, 3), V3(1, 3);
J.Vector(1, V1);
V1.Multiply(Passage, V1);
V1.Multiply(J.Value(1));
J.Vector(2,V2);
V2.Multiply(Passage,V2);
J.Vector(2, V2);
V2.Multiply(Passage, V2);
V2.Multiply(J.Value(2));
J.Vector(3,V3);
V3.Multiply(Passage,V3);
J.Vector(3, V3);
V3.Multiply(Passage, V3);
V3.Multiply(J.Value(3));
inertia = gp_Mat (gp_XYZ(V1(1),V2(1),V3(1)),
gp_XYZ(V1(2),V2(2),V3(2)),
gp_XYZ(V1(3),V2(3),V3(3)));
inertia =
gp_Mat(gp_XYZ(V1(1), V2(1), V3(1)), gp_XYZ(V1(2), V2(2), V3(2)), gp_XYZ(V1(3), V2(3), V3(3)));
gp_Mat Hop;
GProp::HOperator(g,loc,dim,Hop);
inertia = inertia+Hop;
GProp::HOperator(g, loc, dim, Hop);
inertia = inertia + Hop;
}
void GProp_CelGProps::Perform(const gp_Lin& C,
const Standard_Real U1,
const Standard_Real U2)
void GProp_CelGProps::Perform(const gp_Lin& C, const Standard_Real U1, const Standard_Real U2)
{
gp_Ax1 Pos = C.Position();
gp_Pnt P1 = ElCLib::LineValue(U1,Pos);
dim =Abs(U2-U1);
gp_Pnt P2 = ElCLib::LineValue(U2,Pos);
g.SetCoord((P1.X()+P2.X())/2.,(P1.Y()+P2.Y())/2.,(P1.Z()+P2.Z())/2.);
Standard_Real Vx,Vy,Vz,X0,Y0,Z0;
Pos.Direction().Coord(Vx,Vy,Vz);
Pos.Location().Coord(X0,Y0,Z0);
Standard_Real alfa1 = (Vz*Vz+Vy*Vy)/3.;
Standard_Real alfa2 = Vy*Y0+Vz*Z0;
Standard_Real alfa3 = Y0*Y0+Z0*Z0;
Standard_Real Ixx = (U2*(U2*(U2*alfa1+alfa2)+alfa3)) -
(U1*(U1*(U1*alfa1+alfa2)+alfa3));
alfa1 = (Vz*Vz+Vx*Vx)/3.;
alfa2 = Vx*X0+Vz*Z0;
alfa3 = X0*X0+Z0*Z0;
Standard_Real Iyy = (U2*(U2*(U2*alfa1+alfa2)+alfa3)) -
(U1*(U1*(U1*alfa1+alfa2)+alfa3));
alfa1 = (Vy*Vy+Vx*Vx)/3.;
alfa2 = Vy*Y0+Vz*Z0;
alfa3 = Y0*Y0+Z0*Z0;
Standard_Real Izz = (U2*(U2*(U2*alfa1+alfa2)+alfa3)) -
(U1*(U1*(U1*alfa1+alfa2)+alfa3));
alfa1 = (Vy*Vx)/3.;
alfa2 = (Vy*X0+Vx*Y0)/2.;
alfa3 = Y0*X0;
Standard_Real Ixy = (U2*(U2*(U2*alfa1+alfa2)+alfa3)) -
(U1*(U1*(U1*alfa1+alfa2)+alfa3));
alfa1 = (Vz*Vx)/3.;
alfa2 = (Vz*X0+Vx*Z0)/2;
alfa3 = Z0*X0;
Standard_Real Ixz = (U2*(U2*(U2*alfa1+alfa2)+alfa3)) -
(U1*(U1*(U1*alfa1+alfa2)+alfa3));
alfa1 = (Vy*Vz)/3.;
alfa2 = (Vy*Z0+Vz*Y0)/2.;
alfa3 = Y0*Z0;
Standard_Real Iyz = (U2*(U2*(U2*alfa1+alfa2)+alfa3)) -
(U1*(U1*(U1*alfa1+alfa2)+alfa3));
gp_Pnt P1 = ElCLib::LineValue(U1, Pos);
dim = Abs(U2 - U1);
gp_Pnt P2 = ElCLib::LineValue(U2, Pos);
g.SetCoord((P1.X() + P2.X()) / 2., (P1.Y() + P2.Y()) / 2., (P1.Z() + P2.Z()) / 2.);
Standard_Real Vx, Vy, Vz, X0, Y0, Z0;
Pos.Direction().Coord(Vx, Vy, Vz);
Pos.Location().Coord(X0, Y0, Z0);
Standard_Real alfa1 = (Vz * Vz + Vy * Vy) / 3.;
Standard_Real alfa2 = Vy * Y0 + Vz * Z0;
Standard_Real alfa3 = Y0 * Y0 + Z0 * Z0;
Standard_Real Ixx =
(U2 * (U2 * (U2 * alfa1 + alfa2) + alfa3)) - (U1 * (U1 * (U1 * alfa1 + alfa2) + alfa3));
alfa1 = (Vz * Vz + Vx * Vx) / 3.;
alfa2 = Vx * X0 + Vz * Z0;
alfa3 = X0 * X0 + Z0 * Z0;
Standard_Real Iyy =
(U2 * (U2 * (U2 * alfa1 + alfa2) + alfa3)) - (U1 * (U1 * (U1 * alfa1 + alfa2) + alfa3));
alfa1 = (Vy * Vy + Vx * Vx) / 3.;
alfa2 = Vy * Y0 + Vz * Z0;
alfa3 = Y0 * Y0 + Z0 * Z0;
Standard_Real Izz =
(U2 * (U2 * (U2 * alfa1 + alfa2) + alfa3)) - (U1 * (U1 * (U1 * alfa1 + alfa2) + alfa3));
alfa1 = (Vy * Vx) / 3.;
alfa2 = (Vy * X0 + Vx * Y0) / 2.;
alfa3 = Y0 * X0;
Standard_Real Ixy =
(U2 * (U2 * (U2 * alfa1 + alfa2) + alfa3)) - (U1 * (U1 * (U1 * alfa1 + alfa2) + alfa3));
alfa1 = (Vz * Vx) / 3.;
alfa2 = (Vz * X0 + Vx * Z0) / 2;
alfa3 = Z0 * X0;
Standard_Real Ixz =
(U2 * (U2 * (U2 * alfa1 + alfa2) + alfa3)) - (U1 * (U1 * (U1 * alfa1 + alfa2) + alfa3));
alfa1 = (Vy * Vz) / 3.;
alfa2 = (Vy * Z0 + Vz * Y0) / 2.;
alfa3 = Y0 * Z0;
Standard_Real Iyz =
(U2 * (U2 * (U2 * alfa1 + alfa2) + alfa3)) - (U1 * (U1 * (U1 * alfa1 + alfa2) + alfa3));
inertia = gp_Mat (gp_XYZ (Ixx, -Ixy,-Ixz),
gp_XYZ (-Ixy, Iyy,-Iyz),
gp_XYZ (-Ixz,-Iyz, Izz));
inertia = gp_Mat(gp_XYZ(Ixx, -Ixy, -Ixz), gp_XYZ(-Ixy, Iyy, -Iyz), gp_XYZ(-Ixz, -Iyz, Izz));
}
GProp_CelGProps::GProp_CelGProps (const gp_Circ& C, const gp_Pnt& CLocation)
GProp_CelGProps::GProp_CelGProps(const gp_Circ& C, const gp_Pnt& CLocation)
{
SetLocation(CLocation);
Perform(C,0.,2.*M_PI);
Perform(C, 0., 2. * M_PI);
}
GProp_CelGProps::GProp_CelGProps (const gp_Circ& C,
const Standard_Real U1,
const Standard_Real U2,
const gp_Pnt& CLocation)
GProp_CelGProps::GProp_CelGProps(const gp_Circ& C,
const Standard_Real U1,
const Standard_Real U2,
const gp_Pnt& CLocation)
{
SetLocation(CLocation);
Perform(C,U1,U2);
Perform(C, U1, U2);
}
GProp_CelGProps::GProp_CelGProps (const gp_Lin& C,
const Standard_Real U1,
const Standard_Real U2,
const gp_Pnt& CLocation)
GProp_CelGProps::GProp_CelGProps(const gp_Lin& C,
const Standard_Real U1,
const Standard_Real U2,
const gp_Pnt& CLocation)
{
SetLocation(CLocation);
Perform(C,U1,U2);
Perform(C, U1, U2);
}

View File

@@ -25,54 +25,37 @@ class gp_Circ;
class gp_Pnt;
class gp_Lin;
//! Computes the global properties of bounded curves
//! in 3D space.
//! It can be an elementary curve from package gp such as
//! Lin, Circ, Elips, Parab .
class GProp_CelGProps : public GProp_GProps
class GProp_CelGProps : public GProp_GProps
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT GProp_CelGProps();
Standard_EXPORT GProp_CelGProps(const gp_Circ& C, const gp_Pnt& CLocation);
Standard_EXPORT GProp_CelGProps(const gp_Circ& C, const Standard_Real U1, const Standard_Real U2, const gp_Pnt& CLocation);
Standard_EXPORT GProp_CelGProps(const gp_Lin& C, const Standard_Real U1, const Standard_Real U2, const gp_Pnt& CLocation);
Standard_EXPORT void SetLocation (const gp_Pnt& CLocation);
Standard_EXPORT void Perform (const gp_Circ& C, const Standard_Real U1, const Standard_Real U2);
Standard_EXPORT void Perform (const gp_Lin& C, const Standard_Real U1, const Standard_Real U2);
Standard_EXPORT GProp_CelGProps(const gp_Circ& C,
const Standard_Real U1,
const Standard_Real U2,
const gp_Pnt& CLocation);
Standard_EXPORT GProp_CelGProps(const gp_Lin& C,
const Standard_Real U1,
const Standard_Real U2,
const gp_Pnt& CLocation);
Standard_EXPORT void SetLocation(const gp_Pnt& CLocation);
Standard_EXPORT void Perform(const gp_Circ& C, const Standard_Real U1, const Standard_Real U2);
Standard_EXPORT void Perform(const gp_Lin& C, const Standard_Real U1, const Standard_Real U2);
protected:
private:
};
#endif // _GProp_CelGProps_HeaderFile

View File

@@ -17,14 +17,13 @@
#ifndef _GProp_EquaType_HeaderFile
#define _GProp_EquaType_HeaderFile
enum GProp_EquaType
{
GProp_Plane,
GProp_Line,
GProp_Point,
GProp_Space,
GProp_None
GProp_Plane,
GProp_Line,
GProp_Point,
GProp_Space,
GProp_None
};
#endif // _GProp_EquaType_HeaderFile

View File

@@ -12,7 +12,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <gp_Ax1.hxx>
#include <gp_Mat.hxx>
#include <gp_Pnt.hxx>
@@ -24,172 +23,173 @@
#include <math_Jacobi.hxx>
#include <Standard_DomainError.hxx>
GProp_GProps::GProp_GProps () : g (gp::Origin()) , loc (gp::Origin()), dim (0.0)
{
inertia = gp_Mat(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
GProp_GProps::GProp_GProps()
: g(gp::Origin()),
loc(gp::Origin()),
dim(0.0)
{
inertia = gp_Mat(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
}
GProp_GProps::GProp_GProps (const gp_Pnt& SystemLocation) :
g (gp::Origin()), loc (SystemLocation), dim (0.0)
{
inertia = gp_Mat(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
GProp_GProps::GProp_GProps(const gp_Pnt& SystemLocation)
: g(gp::Origin()),
loc(SystemLocation),
dim(0.0)
{
inertia = gp_Mat(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
}
void GProp_GProps::Add (const GProp_GProps& Item, const Standard_Real Density) {
if (Density <= gp::Resolution()) throw Standard_DomainError();
if (loc.Distance (Item.loc) <= gp::Resolution ()) {
gp_XYZ GXYZ = (Item.g.XYZ()).Multiplied (Item.dim * Density);
g.SetXYZ (g.XYZ().Multiplied (dim));
GXYZ.Add (g.XYZ());
void GProp_GProps::Add(const GProp_GProps& Item, const Standard_Real Density)
{
if (Density <= gp::Resolution())
throw Standard_DomainError();
if (loc.Distance(Item.loc) <= gp::Resolution())
{
gp_XYZ GXYZ = (Item.g.XYZ()).Multiplied(Item.dim * Density);
g.SetXYZ(g.XYZ().Multiplied(dim));
GXYZ.Add(g.XYZ());
dim = dim + Item.dim * Density;
if (Abs(dim) >= 1.e-20 ) {
GXYZ.Divide (dim);
g.SetXYZ (GXYZ);
if (Abs(dim) >= 1.e-20)
{
GXYZ.Divide(dim);
g.SetXYZ(GXYZ);
}
else {
else
{
g.SetCoord(0., 0., 0.);
}
inertia = inertia + Item.inertia * Density;
}else{
}
else
{
gp_XYZ Itemloc = loc.XYZ() - Item.loc.XYZ();
gp_XYZ Itemg = Item.loc.XYZ() + Item.g.XYZ();
gp_XYZ GXYZ = Item.g.XYZ() - Itemloc;
GXYZ = GXYZ.Multiplied (Item.dim * Density);
g.SetXYZ (g.XYZ().Multiplied (dim));
GXYZ.Add (g.XYZ());
GXYZ = GXYZ.Multiplied(Item.dim * Density);
g.SetXYZ(g.XYZ().Multiplied(dim));
GXYZ.Add(g.XYZ());
dim = dim + Item.dim * Density;
if (Abs(dim) >= 1.e-20 ) {
GXYZ.Divide (dim);
g.SetXYZ (GXYZ);
if (Abs(dim) >= 1.e-20)
{
GXYZ.Divide(dim);
g.SetXYZ(GXYZ);
}
else {
else
{
g.SetCoord(0., 0., 0.);
}
//We have to compute the inertia of the Item at the location point
//of the system using the Huyghens theorem
// We have to compute the inertia of the Item at the location point
// of the system using the Huyghens theorem
gp_Mat HMat;
gp_Mat ItemInertia = Item.inertia;
if (Item.g.XYZ().Modulus() > gp::Resolution()) {
//Computes the inertia of Item at its dim centre
GProp::HOperator (Itemg, Item.loc, Item.dim, HMat);
if (Item.g.XYZ().Modulus() > gp::Resolution())
{
// Computes the inertia of Item at its dim centre
GProp::HOperator(Itemg, Item.loc, Item.dim, HMat);
ItemInertia = ItemInertia - HMat;
}
//Computes the inertia of Item at the location point of the system
GProp::HOperator (Itemg, loc, Item.dim, HMat);
// Computes the inertia of Item at the location point of the system
GProp::HOperator(Itemg, loc, Item.dim, HMat);
ItemInertia = ItemInertia + HMat;
inertia = inertia + ItemInertia * Density;
inertia = inertia + ItemInertia * Density;
}
}
Standard_Real GProp_GProps::Mass () const { return dim; }
gp_Pnt GProp_GProps::CentreOfMass () const
{
return gp_Pnt(loc.XYZ() + g.XYZ());
Standard_Real GProp_GProps::Mass() const
{
return dim;
}
gp_Mat GProp_GProps::MatrixOfInertia () const {
gp_Pnt GProp_GProps::CentreOfMass() const
{
return gp_Pnt(loc.XYZ() + g.XYZ());
}
gp_Mat GProp_GProps::MatrixOfInertia() const
{
gp_Mat HMat;
GProp::HOperator (g,gp::Origin(),dim, HMat);
GProp::HOperator(g, gp::Origin(), dim, HMat);
return inertia - HMat;
}
void GProp_GProps::StaticMoments (Standard_Real& Ix,
Standard_Real& Iy,
Standard_Real& Iz) const {
void GProp_GProps::StaticMoments(Standard_Real& Ix, Standard_Real& Iy, Standard_Real& Iz) const
{
gp_XYZ G = loc.XYZ() + g.XYZ();
Ix = G.X() * dim;
Iy = G.Y() * dim;
Iz = G.Z() * dim;
Ix = G.X() * dim;
Iy = G.Y() * dim;
Iz = G.Z() * dim;
}
Standard_Real GProp_GProps::MomentOfInertia (const gp_Ax1& A) const {
Standard_Real GProp_GProps::MomentOfInertia(const gp_Ax1& A) const
{
// Moment of inertia / axis A
// 1] computes the math_Matrix of inertia / A.location()
// 2] applies this math_Matrix to A.Direction()
// 3] then computes the scalar product between this vector and
// 3] then computes the scalar product between this vector and
// A.Direction()
if (loc.Distance (A.Location()) <= gp::Resolution()) {
return (A.Direction().XYZ()).Dot (
(A.Direction().XYZ()).Multiplied (inertia));
if (loc.Distance(A.Location()) <= gp::Resolution())
{
return (A.Direction().XYZ()).Dot((A.Direction().XYZ()).Multiplied(inertia));
}
else {
else
{
gp_Mat HMat;
gp_Mat AxisInertia = MatrixOfInertia();
GProp::HOperator (gp_Pnt (loc.XYZ() + g.XYZ()), A.Location(), dim, HMat);
GProp::HOperator(gp_Pnt(loc.XYZ() + g.XYZ()), A.Location(), dim, HMat);
AxisInertia = AxisInertia + HMat;
return (A.Direction().XYZ()).Dot (
(A.Direction().XYZ()).Multiplied (AxisInertia));
return (A.Direction().XYZ()).Dot((A.Direction().XYZ()).Multiplied(AxisInertia));
}
}
Standard_Real GProp_GProps::RadiusOfGyration(const gp_Ax1& A) const
{
Standard_Real GProp_GProps::RadiusOfGyration (const gp_Ax1& A) const {
return Sqrt (MomentOfInertia (A) / dim);
return Sqrt(MomentOfInertia(A) / dim);
}
GProp_PrincipalProps GProp_GProps::PrincipalProperties() const
{
GProp_PrincipalProps GProp_GProps::PrincipalProperties () const {
math_Matrix DiagMat (1, 3, 1, 3);
math_Matrix DiagMat(1, 3, 1, 3);
Standard_Integer i, j;
gp_Mat AxisInertia = MatrixOfInertia();
for (j = 1; j <= 3; j++) {
for (i = 1; i <= 3; i++) {
DiagMat (i, j) = AxisInertia.Value (i, j);
gp_Mat AxisInertia = MatrixOfInertia();
for (j = 1; j <= 3; j++)
{
for (i = 1; i <= 3; i++)
{
DiagMat(i, j) = AxisInertia.Value(i, j);
}
}
math_Jacobi J (DiagMat);
Standard_Real Ixx = J.Value (1);
Standard_Real Iyy = J.Value (2);
Standard_Real Izz = J.Value (3);
DiagMat = J.Vectors ();
gp_Vec Vxx (DiagMat (1,1), DiagMat (2, 1), DiagMat (3, 1));
gp_Vec Vyy (DiagMat (1,2), DiagMat (2, 2), DiagMat (3, 2));
gp_Vec Vzz (DiagMat (1,3), DiagMat (2, 3), DiagMat (3, 3));
math_Jacobi J(DiagMat);
Standard_Real Ixx = J.Value(1);
Standard_Real Iyy = J.Value(2);
Standard_Real Izz = J.Value(3);
DiagMat = J.Vectors();
gp_Vec Vxx(DiagMat(1, 1), DiagMat(2, 1), DiagMat(3, 1));
gp_Vec Vyy(DiagMat(1, 2), DiagMat(2, 2), DiagMat(3, 2));
gp_Vec Vzz(DiagMat(1, 3), DiagMat(2, 3), DiagMat(3, 3));
//
// protection contre dim == 0.0e0 au cas ou on aurait rentre qu'un point
//
Standard_Real Rxx = 0.0e0 ;
Standard_Real Ryy = 0.0e0 ;
Standard_Real Rzz = 0.0e0 ;
if (0.0e0 != dim) {
Rxx = Sqrt (Abs(Ixx / dim));
Ryy = Sqrt (Abs(Iyy / dim));
Rzz = Sqrt (Abs(Izz / dim));
Standard_Real Rxx = 0.0e0;
Standard_Real Ryy = 0.0e0;
Standard_Real Rzz = 0.0e0;
if (0.0e0 != dim)
{
Rxx = Sqrt(Abs(Ixx / dim));
Ryy = Sqrt(Abs(Iyy / dim));
Rzz = Sqrt(Abs(Izz / dim));
}
return GProp_PrincipalProps (Ixx, Iyy, Izz, Rxx, Ryy, Rzz, Vxx, Vyy, Vzz,
gp_Pnt(g.XYZ() + loc.XYZ()));
return GProp_PrincipalProps(Ixx,
Iyy,
Izz,
Rxx,
Ryy,
Rzz,
Vxx,
Vyy,
Vzz,
gp_Pnt(g.XYZ() + loc.XYZ()));
}

View File

@@ -25,8 +25,6 @@
class gp_Ax1;
class GProp_PrincipalProps;
//! Implements a general mechanism to compute the global properties of
//! a "compound geometric system" in 3d space by composition of the
//! global properties of "elementary geometric entities" such as
@@ -96,18 +94,14 @@ class GProp_PrincipalProps;
//! Real Ixx, Iyy, Izz, Rxx, Ryy, Rzz;
//! Pp.Moments (Ixx, Iyy, Izz);
//! Pp.RadiusOfGyration (Ixx, Iyy, Izz);
class GProp_GProps
class GProp_GProps
{
public:
DEFINE_STANDARD_ALLOC
//! The origin (0, 0, 0) of the absolute cartesian coordinate system
//! is used to compute the global properties.
Standard_EXPORT GProp_GProps();
//! The point SystemLocation is used to compute the global properties
//! of the system. For more accuracy it is better to define this
@@ -129,7 +123,7 @@ public:
//! and then use the interrogation functions available to
//! access the computed values.
Standard_EXPORT GProp_GProps(const gp_Pnt& SystemLocation);
//! Either
//! - initializes the global properties retained by this
//! framework from those retained by the framework Item, or
@@ -167,8 +161,8 @@ public:
//! Exceptions
//! Standard_DomainError if Density is less than or
//! equal to gp::Resolution().
Standard_EXPORT void Add (const GProp_GProps& Item, const Standard_Real Density = 1.0);
Standard_EXPORT void Add(const GProp_GProps& Item, const Standard_Real Density = 1.0);
//! Returns the mass of the current system.
//! If no density is attached to the components of the
//! current system the returned value corresponds to :
@@ -194,14 +188,12 @@ public:
//! or its volume by the given density. You must be
//! consistent with respect to the units used.
Standard_EXPORT Standard_Real Mass() const;
//! Returns the center of mass of the current system. If
//! the gravitational field is uniform, it is the center of gravity.
//! The coordinates returned for the center of mass are
//! expressed in the absolute Cartesian coordinate system.
Standard_EXPORT gp_Pnt CentreOfMass() const;
//! returns the matrix of inertia. It is a symmetrical matrix.
//! The coefficients of the matrix are the quadratic moments of
@@ -221,17 +213,16 @@ public:
//! inertia at another location point using the Huyghens theorem
//! (you can use the method of package GProp : HOperator).
Standard_EXPORT gp_Mat MatrixOfInertia() const;
//! Returns Ix, Iy, Iz, the static moments of inertia of the
//! current system; i.e. the moments of inertia about the
//! three axes of the Cartesian coordinate system.
Standard_EXPORT void StaticMoments (Standard_Real& Ix, Standard_Real& Iy, Standard_Real& Iz) const;
Standard_EXPORT void StaticMoments(Standard_Real& Ix, Standard_Real& Iy, Standard_Real& Iz) const;
//! computes the moment of inertia of the material system about the
//! axis A.
Standard_EXPORT Standard_Real MomentOfInertia (const gp_Ax1& A) const;
Standard_EXPORT Standard_Real MomentOfInertia(const gp_Ax1& A) const;
//! Computes the principal properties of inertia of the current system.
//! There is always a set of axes for which the products
//! of inertia of a geometric system are equal to 0; i.e. the
@@ -246,35 +237,17 @@ public:
//! (GProp_PrincipalProps object) which may be
//! queried to access the value sought.
Standard_EXPORT GProp_PrincipalProps PrincipalProperties() const;
//! Returns the radius of gyration of the current system about the axis A.
Standard_EXPORT Standard_Real RadiusOfGyration (const gp_Ax1& A) const;
Standard_EXPORT Standard_Real RadiusOfGyration(const gp_Ax1& A) const;
protected:
gp_Pnt g;
gp_Pnt loc;
gp_Pnt g;
gp_Pnt loc;
Standard_Real dim;
gp_Mat inertia;
gp_Mat inertia;
private:
};
#endif // _GProp_GProps_HeaderFile

View File

@@ -12,7 +12,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
@@ -21,25 +20,24 @@
#include <GProp_PrincipalProps.hxx>
#include <Standard_NoSuchObject.hxx>
GProp_PEquation::GProp_PEquation(const TColgp_Array1OfPnt& Pnts,
const Standard_Real Tol)
: type(GProp_None)
GProp_PEquation::GProp_PEquation(const TColgp_Array1OfPnt& Pnts, const Standard_Real Tol)
: type(GProp_None)
{
GProp_PGProps Pmat(Pnts);
g = Pmat.CentreOfMass();
Standard_Real Xg,Yg,Zg;
g.Coord(Xg,Yg,Zg);
g = Pmat.CentreOfMass();
Standard_Real Xg, Yg, Zg;
g.Coord(Xg, Yg, Zg);
GProp_PrincipalProps Pp = Pmat.PrincipalProperties();
gp_Vec V1 = Pp.FirstAxisOfInertia();
Standard_Real Xv1,Yv1,Zv1;
V1.Coord(Xv1,Yv1,Zv1);
gp_Vec V2 = Pp.SecondAxisOfInertia();
Standard_Real Xv2,Yv2,Zv2;
V2.Coord(Xv2,Yv2,Zv2);
gp_Vec V3 = Pp.ThirdAxisOfInertia();
Standard_Real Xv3,Yv3,Zv3;
V3.Coord(Xv3,Yv3,Zv3);
Standard_Real D,X,Y,Z;
gp_Vec V1 = Pp.FirstAxisOfInertia();
Standard_Real Xv1, Yv1, Zv1;
V1.Coord(Xv1, Yv1, Zv1);
gp_Vec V2 = Pp.SecondAxisOfInertia();
Standard_Real Xv2, Yv2, Zv2;
V2.Coord(Xv2, Yv2, Zv2);
gp_Vec V3 = Pp.ThirdAxisOfInertia();
Standard_Real Xv3, Yv3, Zv3;
V3.Coord(Xv3, Yv3, Zv3);
Standard_Real D, X, Y, Z;
Standard_Real Dmx1 = RealFirst();
Standard_Real Dmn1 = RealLast();
Standard_Real Dmx2 = RealFirst();
@@ -47,106 +45,140 @@ GProp_PEquation::GProp_PEquation(const TColgp_Array1OfPnt& Pnts,
Standard_Real Dmx3 = RealFirst();
Standard_Real Dmn3 = RealLast();
for (Standard_Integer i = Pnts.Lower(); i <= Pnts.Upper();i++){
Pnts(i).Coord(X,Y,Z);
D = (X-Xg)*Xv1 +(Y-Yg)*Yv1 + (Z-Zg)*Zv1;
if (D > Dmx1) Dmx1 = D;
if (D < Dmn1) Dmn1 = D;
D = (X-Xg)*Xv2 +(Y-Yg)*Yv2 + (Z-Zg)*Zv2;
if (D > Dmx2) Dmx2 = D;
if (D < Dmn2) Dmn2 = D;
D = (X-Xg)*Xv3 +(Y-Yg)*Yv3 + (Z-Zg)*Zv3;
if (D > Dmx3) Dmx3 = D;
if (D < Dmn3) Dmn3 = D;
for (Standard_Integer i = Pnts.Lower(); i <= Pnts.Upper(); i++)
{
Pnts(i).Coord(X, Y, Z);
D = (X - Xg) * Xv1 + (Y - Yg) * Yv1 + (Z - Zg) * Zv1;
if (D > Dmx1)
Dmx1 = D;
if (D < Dmn1)
Dmn1 = D;
D = (X - Xg) * Xv2 + (Y - Yg) * Yv2 + (Z - Zg) * Zv2;
if (D > Dmx2)
Dmx2 = D;
if (D < Dmn2)
Dmn2 = D;
D = (X - Xg) * Xv3 + (Y - Yg) * Yv3 + (Z - Zg) * Zv3;
if (D > Dmx3)
Dmx3 = D;
if (D < Dmn3)
Dmn3 = D;
}
Standard_Integer dimension= 3 ;
Standard_Integer It = 0;
if (Abs(Dmx1-Dmn1) <= Tol) {
dimension =dimension-1;
It =1;
Standard_Integer dimension = 3;
Standard_Integer It = 0;
if (Abs(Dmx1 - Dmn1) <= Tol)
{
dimension = dimension - 1;
It = 1;
}
if (Abs(Dmx2-Dmn2) <= Tol) {
dimension =dimension-1;
It =2*(It+1);
if (Abs(Dmx2 - Dmn2) <= Tol)
{
dimension = dimension - 1;
It = 2 * (It + 1);
}
if (Abs(Dmx3-Dmn3) <= Tol) {
dimension =dimension-1;
It = 3*(It+1);
if (Abs(Dmx3 - Dmn3) <= Tol)
{
dimension = dimension - 1;
It = 3 * (It + 1);
}
switch (dimension) {
case 0:
{
switch (dimension)
{
case 0: {
type = GProp_Point;
break;
}
case 1:
{
case 1: {
type = GProp_Line;
if (It == 4) v1 = V3;
else if (It == 6) v1 = V2;
else v1 = V1;
if (It == 4)
v1 = V3;
else if (It == 6)
v1 = V2;
else
v1 = V1;
break;
}
case 2:
{
case 2: {
type = GProp_Plane;
if (It == 1) v1 = V1;
else if (It == 2) v1 =V2;
else v1 = V3;
if (It == 1)
v1 = V1;
else if (It == 2)
v1 = V2;
else
v1 = V3;
break;
}
case 3:
{
case 3: {
type = GProp_Space;
g.SetXYZ(g.XYZ() + Dmn1*V1.XYZ() + Dmn2*V2.XYZ() + Dmn3*V3.XYZ());
v1 = (Dmx1-Dmn1)*V1;
v2 = (Dmx2-Dmn2)*V2;
v3 = (Dmx3-Dmn3)*V3;
g.SetXYZ(g.XYZ() + Dmn1 * V1.XYZ() + Dmn2 * V2.XYZ() + Dmn3 * V3.XYZ());
v1 = (Dmx1 - Dmn1) * V1;
v2 = (Dmx2 - Dmn2) * V2;
v3 = (Dmx3 - Dmn3) * V3;
break;
}
}
}
Standard_Boolean GProp_PEquation::IsPlanar() const {
if (type == GProp_Plane) return Standard_True;
else return Standard_False;
Standard_Boolean GProp_PEquation::IsPlanar() const
{
if (type == GProp_Plane)
return Standard_True;
else
return Standard_False;
}
Standard_Boolean GProp_PEquation::IsLinear() const {
Standard_Boolean GProp_PEquation::IsLinear() const
{
if (type == GProp_Line) return Standard_True;
else return Standard_False;
if (type == GProp_Line)
return Standard_True;
else
return Standard_False;
}
Standard_Boolean GProp_PEquation::IsPoint() const {
Standard_Boolean GProp_PEquation::IsPoint() const
{
if (type == GProp_Point) return Standard_True;
else return Standard_False;
if (type == GProp_Point)
return Standard_True;
else
return Standard_False;
}
Standard_Boolean GProp_PEquation::IsSpace() const {
if (type == GProp_Space) return Standard_True;
else return Standard_False;
Standard_Boolean GProp_PEquation::IsSpace() const
{
if (type == GProp_Space)
return Standard_True;
else
return Standard_False;
}
gp_Pln GProp_PEquation::Plane() const {
if (!IsPlanar()) throw Standard_NoSuchObject();
return gp_Pln(g,v1);
}
gp_Lin GProp_PEquation::Line() const {
if (!IsLinear()) throw Standard_NoSuchObject();
return gp_Lin(g,gp_Dir(v1));
gp_Pln GProp_PEquation::Plane() const
{
if (!IsPlanar())
throw Standard_NoSuchObject();
return gp_Pln(g, v1);
}
gp_Pnt GProp_PEquation::Point() const {
if (!IsPoint()) throw Standard_NoSuchObject();
gp_Lin GProp_PEquation::Line() const
{
if (!IsLinear())
throw Standard_NoSuchObject();
return gp_Lin(g, gp_Dir(v1));
}
gp_Pnt GProp_PEquation::Point() const
{
if (!IsPoint())
throw Standard_NoSuchObject();
return g;
}
void GProp_PEquation::Box(gp_Pnt& P , gp_Vec& V1,
gp_Vec& V2 , gp_Vec& V3) const {
if (!IsSpace()) throw Standard_NoSuchObject();
P = g;
void GProp_PEquation::Box(gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const
{
if (!IsSpace())
throw Standard_NoSuchObject();
P = g;
V1 = v1;
V2 = v2;
V3 = v3;

View File

@@ -27,20 +27,17 @@
class gp_Pln;
class gp_Lin;
//! A framework to analyze a collection - or cloud
//! - of points and to verify if they are coincident,
//! collinear or coplanar within a given precision. If
//! so, it also computes the mean point, the mean
//! line or the mean plane of the points. If not, it
//! computes the minimal box which includes all the points.
class GProp_PEquation
class GProp_PEquation
{
public:
DEFINE_STANDARD_ALLOC
//! Constructs a framework to analyze the
//! collection of points Pnts and computes:
//! - the mean point if the points in question are
@@ -55,29 +52,29 @@ public:
//! - the function Point, Line, Plane or Box to
//! access the computed result.
Standard_EXPORT GProp_PEquation(const TColgp_Array1OfPnt& Pnts, const Standard_Real Tol);
//! Returns true if, according to the given
//! tolerance, the points analyzed by this framework are coplanar.
//! Use the function Plane to access the computed result.
Standard_EXPORT Standard_Boolean IsPlanar() const;
//! Returns true if, according to the given
//! tolerance, the points analyzed by this framework are colinear.
//! Use the function Line to access the computed result.
Standard_EXPORT Standard_Boolean IsLinear() const;
//! Returns true if, according to the given
//! tolerance, the points analyzed by this framework are coincident.
//! Use the function Point to access the computed result.
Standard_EXPORT Standard_Boolean IsPoint() const;
//! Returns true if, according to the given
//! tolerance value, the points analyzed by this
//! framework are neither coincident, nor collinear, nor coplanar.
//! Use the function Box to query the smallest box
//! that includes the collection of points.
Standard_EXPORT Standard_Boolean IsSpace() const;
//! Returns the mean plane passing near all the
//! points analyzed by this framework if, according
//! to the given precision, the points are considered to be coplanar.
@@ -89,7 +86,7 @@ public:
//! - collinear, or
//! - not coplanar.
Standard_EXPORT gp_Pln Plane() const;
//! Returns the mean line passing near all the
//! points analyzed by this framework if, according
//! to the given precision value, the points are considered to be collinear.
@@ -100,7 +97,7 @@ public:
//! - coincident, or
//! - not collinear.
Standard_EXPORT gp_Lin Line() const;
//! Returns the mean point of all the points
//! analyzed by this framework if, according to the
//! given precision, the points are considered to be coincident.
@@ -109,7 +106,7 @@ public:
//! given precision, the points analyzed by this
//! framework are not considered to be coincident.
Standard_EXPORT gp_Pnt Point() const;
//! Returns the definition of the smallest box which
//! contains all the points analyzed by this
//! framework if, according to the given precision
@@ -125,34 +122,15 @@ public:
//! Exceptions
//! Standard_NoSuchObject if, according to the given precision,
//! the points analyzed by this framework are considered to be coincident, collinear or coplanar.
Standard_EXPORT void Box (gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const;
Standard_EXPORT void Box(gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const;
protected:
private:
GProp_EquaType type;
gp_Pnt g;
gp_Vec v1;
gp_Vec v2;
gp_Vec v3;
gp_Pnt g;
gp_Vec v1;
gp_Vec v2;
gp_Vec v3;
};
#endif // _GProp_PEquation_HeaderFile

View File

@@ -12,214 +12,226 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <GProp_PGProps.hxx>
#include <Standard_DimensionError.hxx>
#include <Standard_DomainError.hxx>
//#include <gp.hxx>
typedef gp_Pnt Pnt;
typedef gp_Mat Mat;
typedef gp_XYZ XYZ;
typedef TColgp_Array1OfPnt Array1OfPnt;
typedef TColgp_Array2OfPnt Array2OfPnt;
// #include <gp.hxx>
typedef gp_Pnt Pnt;
typedef gp_Mat Mat;
typedef gp_XYZ XYZ;
typedef TColgp_Array1OfPnt Array1OfPnt;
typedef TColgp_Array2OfPnt Array2OfPnt;
typedef TColStd_Array1OfReal Array1OfReal;
typedef TColStd_Array2OfReal Array2OfReal;
GProp_PGProps::GProp_PGProps ()
GProp_PGProps::GProp_PGProps()
{
g = gp::Origin();
g = gp::Origin();
loc = gp::Origin();
dim = 0.0;
}
void GProp_PGProps::AddPoint (const Pnt& P)
void GProp_PGProps::AddPoint(const Pnt& P)
{
Standard_Real Xp, Yp, Zp;
P.Coord (Xp, Yp, Zp);
Standard_Real Ixy = - Xp * Yp;
Standard_Real Ixz = - Xp * Zp;
Standard_Real Iyz = - Yp * Zp;
P.Coord(Xp, Yp, Zp);
Standard_Real Ixy = -Xp * Yp;
Standard_Real Ixz = -Xp * Zp;
Standard_Real Iyz = -Yp * Zp;
Standard_Real Ixx = Yp * Yp + Zp * Zp;
Standard_Real Iyy = Xp * Xp + Zp * Zp;
Standard_Real Izz = Xp * Xp + Yp * Yp;
Mat Mp (XYZ (Ixx, Ixy, Ixz), XYZ (Ixy, Iyy, Iyz), XYZ (Ixz, Iyz, Izz));
if (dim == 0) {
dim = 1;
g = P;
Mat Mp(XYZ(Ixx, Ixy, Ixz), XYZ(Ixy, Iyy, Iyz), XYZ(Ixz, Iyz, Izz));
if (dim == 0)
{
dim = 1;
g = P;
inertia = Mp;
}
else {
else
{
Standard_Real X, Y, Z;
g.Coord (X, Y, Z);
X = X * dim + Xp;
Y = Y * dim + Yp;
Z = Z * dim + Zp;
g.Coord(X, Y, Z);
X = X * dim + Xp;
Y = Y * dim + Yp;
Z = Z * dim + Zp;
dim = dim + 1;
X /= dim;
Y /= dim;
Z /= dim;
g.SetCoord (X, Y, Z);
g.SetCoord(X, Y, Z);
inertia = inertia + Mp;
}
}
}
void GProp_PGProps::AddPoint (const gp_Pnt& P, const Standard_Real Density)
void GProp_PGProps::AddPoint(const gp_Pnt& P, const Standard_Real Density)
{
if (Density <= gp::Resolution()) throw Standard_DomainError();
if (Density <= gp::Resolution())
throw Standard_DomainError();
Standard_Real Xp, Yp, Zp;
P.Coord (Xp, Yp, Zp);
Standard_Real Ixy = - Xp * Yp;
Standard_Real Ixz = - Xp * Zp;
Standard_Real Iyz = - Yp * Zp;
P.Coord(Xp, Yp, Zp);
Standard_Real Ixy = -Xp * Yp;
Standard_Real Ixz = -Xp * Zp;
Standard_Real Iyz = -Yp * Zp;
Standard_Real Ixx = Yp * Yp + Zp * Zp;
Standard_Real Iyy = Xp * Xp + Zp * Zp;
Standard_Real Izz = Xp * Xp + Yp * Yp;
Mat Mp (XYZ (Ixx, Ixy, Ixz), XYZ (Ixy, Iyy, Iyz), XYZ (Ixz, Iyz, Izz));
if (dim == 0) {
dim = Density;
g = P;
Mat Mp(XYZ(Ixx, Ixy, Ixz), XYZ(Ixy, Iyy, Iyz), XYZ(Ixz, Iyz, Izz));
if (dim == 0)
{
dim = Density;
g = P;
inertia = Mp * Density;
}
else {
else
{
Standard_Real X, Y, Z;
g.Coord (X, Y, Z);
X = X * dim + Xp * Density;
Y = Y * dim + Yp * Density;
Z = Z * dim + Zp * Density;
g.Coord(X, Y, Z);
X = X * dim + Xp * Density;
Y = Y * dim + Yp * Density;
Z = Z * dim + Zp * Density;
dim = dim + Density;
X /= dim;
Y /= dim;
Z /= dim;
g.SetCoord (X, Y, Z);
g.SetCoord(X, Y, Z);
inertia = inertia + Mp * Density;
}
}
GProp_PGProps::GProp_PGProps (const Array1OfPnt& Pnts)
{
for (Standard_Integer i = Pnts.Lower(); i <= Pnts.Upper(); i++) AddPoint(Pnts(i));
}
GProp_PGProps::GProp_PGProps (const Array2OfPnt& Pnts)
{
for (Standard_Integer j = Pnts.LowerCol(); j <= Pnts.UpperCol(); j++)
{
for (Standard_Integer i = Pnts.LowerRow(); i <= Pnts.UpperRow(); i++) AddPoint(Pnts (i, j));
}
}
GProp_PGProps::GProp_PGProps (const Array1OfPnt& Pnts,const Array1OfReal& Density)
{
if (Pnts.Length() != Density.Length()) throw Standard_DomainError();
Standard_Integer ip = Pnts.Lower();
Standard_Integer id = Density.Lower();
while (id <= Pnts.Upper()) {
Standard_Real D = Density (id);
if (D <= gp::Resolution()) throw Standard_DomainError();
AddPoint(Pnts (ip),D);
ip++; id++;
}
}
GProp_PGProps::GProp_PGProps (const Array2OfPnt& Pnts,const Array2OfReal& Density)
{
if (Pnts.ColLength() != Density.ColLength() || Pnts.RowLength() != Density.RowLength()) throw Standard_DomainError();
Standard_Integer ip = Pnts.LowerRow();
Standard_Integer id = Density.LowerRow();
Standard_Integer jp = Pnts.LowerCol();
Standard_Integer jd = Density.LowerCol();
while (jp <= Pnts.UpperCol()) {
while (ip <= Pnts.UpperRow()) {
Standard_Real D = Density (id, jd);
if (D <= gp::Resolution()) throw Standard_DomainError();
AddPoint(Pnts (ip, jp),D);
ip++; id++;
}
jp++; jd++;
}
}
void GProp_PGProps::Barycentre(const Array1OfPnt& Pnts,
const Array1OfReal& Density,
Standard_Real& Mass,
Pnt& G)
GProp_PGProps::GProp_PGProps(const Array1OfPnt& Pnts)
{
if (Pnts.Length() != Density.Length()) throw Standard_DimensionError();
for (Standard_Integer i = Pnts.Lower(); i <= Pnts.Upper(); i++)
AddPoint(Pnts(i));
}
GProp_PGProps::GProp_PGProps(const Array2OfPnt& Pnts)
{
for (Standard_Integer j = Pnts.LowerCol(); j <= Pnts.UpperCol(); j++)
{
for (Standard_Integer i = Pnts.LowerRow(); i <= Pnts.UpperRow(); i++)
AddPoint(Pnts(i, j));
}
}
GProp_PGProps::GProp_PGProps(const Array1OfPnt& Pnts, const Array1OfReal& Density)
{
if (Pnts.Length() != Density.Length())
throw Standard_DomainError();
Standard_Integer ip = Pnts.Lower();
Standard_Integer id = Density.Lower();
Mass = Density (id);
XYZ Gxyz = Pnts (ip).XYZ();
Gxyz.Multiply (Mass);
while (ip <= Pnts.Upper()) {
Mass = Mass + Density (id);
Gxyz.Add ( (Pnts(ip).XYZ()).Multiplied (Density (id)) );
while (id <= Pnts.Upper())
{
Standard_Real D = Density(id);
if (D <= gp::Resolution())
throw Standard_DomainError();
AddPoint(Pnts(ip), D);
ip++;
id++;
}
Gxyz.Divide (Mass);
G.SetXYZ (Gxyz);
}
void GProp_PGProps::Barycentre(const Array2OfPnt& Pnts,
const Array2OfReal& Density,
Standard_Real& Mass,
Pnt& G)
GProp_PGProps::GProp_PGProps(const Array2OfPnt& Pnts, const Array2OfReal& Density)
{
if (Pnts.RowLength() != Density.RowLength() || Pnts.ColLength() != Density.ColLength()) throw Standard_DimensionError();
if (Pnts.ColLength() != Density.ColLength() || Pnts.RowLength() != Density.RowLength())
throw Standard_DomainError();
Standard_Integer ip = Pnts.LowerRow();
Standard_Integer id = Density.LowerRow();
Standard_Integer jp = Pnts.LowerCol();
Standard_Integer jd = Density.LowerCol();
Mass = 0.0;
XYZ Gxyz (0.0, 0.0, 0.0);
while (jp <= Pnts.UpperCol()) {
while (ip <= Pnts.UpperRow()) {
Mass = Mass + Density (id, jd);
Gxyz.Add ((Pnts(ip, jp).XYZ()).Multiplied (Density (id, jd)));
ip++; id++;
while (jp <= Pnts.UpperCol())
{
while (ip <= Pnts.UpperRow())
{
Standard_Real D = Density(id, jd);
if (D <= gp::Resolution())
throw Standard_DomainError();
AddPoint(Pnts(ip, jp), D);
ip++;
id++;
}
jp++; jd++;
jp++;
jd++;
}
Gxyz.Divide (Mass);
G.SetXYZ (Gxyz);
}
Pnt GProp_PGProps::Barycentre (const Array1OfPnt& Pnts) {
XYZ Gxyz = Pnts (Pnts.Lower()).XYZ();
for (Standard_Integer i = Pnts.Lower() + 1; i <= Pnts.Upper(); i++) {
Gxyz.Add (Pnts(i).XYZ());
void GProp_PGProps::Barycentre(const Array1OfPnt& Pnts,
const Array1OfReal& Density,
Standard_Real& Mass,
Pnt& G)
{
if (Pnts.Length() != Density.Length())
throw Standard_DimensionError();
Standard_Integer ip = Pnts.Lower();
Standard_Integer id = Density.Lower();
Mass = Density(id);
XYZ Gxyz = Pnts(ip).XYZ();
Gxyz.Multiply(Mass);
while (ip <= Pnts.Upper())
{
Mass = Mass + Density(id);
Gxyz.Add((Pnts(ip).XYZ()).Multiplied(Density(id)));
ip++;
id++;
}
Gxyz.Divide (Pnts.Length());
return Pnt (Gxyz);
Gxyz.Divide(Mass);
G.SetXYZ(Gxyz);
}
void GProp_PGProps::Barycentre(const Array2OfPnt& Pnts,
const Array2OfReal& Density,
Standard_Real& Mass,
Pnt& G)
{
if (Pnts.RowLength() != Density.RowLength() || Pnts.ColLength() != Density.ColLength())
throw Standard_DimensionError();
Standard_Integer ip = Pnts.LowerRow();
Standard_Integer id = Density.LowerRow();
Standard_Integer jp = Pnts.LowerCol();
Standard_Integer jd = Density.LowerCol();
Mass = 0.0;
XYZ Gxyz(0.0, 0.0, 0.0);
while (jp <= Pnts.UpperCol())
{
while (ip <= Pnts.UpperRow())
{
Mass = Mass + Density(id, jd);
Gxyz.Add((Pnts(ip, jp).XYZ()).Multiplied(Density(id, jd)));
ip++;
id++;
}
jp++;
jd++;
}
Gxyz.Divide(Mass);
G.SetXYZ(Gxyz);
}
Pnt GProp_PGProps::Barycentre(const Array1OfPnt& Pnts)
{
XYZ Gxyz = Pnts(Pnts.Lower()).XYZ();
for (Standard_Integer i = Pnts.Lower() + 1; i <= Pnts.Upper(); i++)
{
Gxyz.Add(Pnts(i).XYZ());
}
Gxyz.Divide(Pnts.Length());
return Pnt(Gxyz);
}
Pnt GProp_PGProps::Barycentre (const Array2OfPnt& Pnts) {
Pnt GProp_PGProps::Barycentre(const Array2OfPnt& Pnts)
{
XYZ Gxyz (0.0, 0.0, 0.0);
for (Standard_Integer j = Pnts.LowerCol(); j <= Pnts.UpperCol(); j++) {
for (Standard_Integer i = Pnts.LowerRow(); i <= Pnts.UpperRow(); i++) {
Gxyz.Add (Pnts(i, j).XYZ());
XYZ Gxyz(0.0, 0.0, 0.0);
for (Standard_Integer j = Pnts.LowerCol(); j <= Pnts.UpperCol(); j++)
{
for (Standard_Integer i = Pnts.LowerRow(); i <= Pnts.UpperRow(); i++)
{
Gxyz.Add(Pnts(i, j).XYZ());
}
}
Gxyz.Divide (Pnts.RowLength() * Pnts.ColLength());
return Pnt (Gxyz);
Gxyz.Divide(Pnts.RowLength() * Pnts.ColLength());
return Pnt(Gxyz);
}

View File

@@ -28,7 +28,6 @@
#include <TColStd_Array2OfReal.hxx>
class gp_Pnt;
//! A framework for computing the global properties of a
//! set of points.
//! A point mass is attached to each point. The global
@@ -48,13 +47,11 @@ class gp_Pnt;
//! GProp_PGProps object to a set of points and to
//! create a GProp_GProps object in order to bring
//! together global properties of different systems.
class GProp_PGProps : public GProp_GProps
class GProp_PGProps : public GProp_GProps
{
public:
DEFINE_STANDARD_ALLOC
//! Initializes a framework to compute global properties
//! on a set of points.
//! The point relative to which the inertia of the system is
@@ -72,31 +69,27 @@ public:
//! system's global properties. Note that the current
//! system may be more complex than a set of points.
Standard_EXPORT GProp_PGProps();
//! Brings together the global properties already
//! retained by this framework with those induced by
//! the point Pnt. Pnt may be the first point of the current system.
//! A point mass is attached to the point Pnt, it is either
//! equal to 1. or to Density.
Standard_EXPORT void AddPoint (const gp_Pnt& P);
Standard_EXPORT void AddPoint(const gp_Pnt& P);
//! Adds a new point P with its density in the system of points
//! Exceptions
//! Standard_DomainError if the mass value Density
//! is less than gp::Resolution().
Standard_EXPORT void AddPoint (const gp_Pnt& P, const Standard_Real Density);
Standard_EXPORT void AddPoint(const gp_Pnt& P, const Standard_Real Density);
//! computes the global properties of the system of points Pnts.
//! The density of the points are defaulted to all being 1
Standard_EXPORT GProp_PGProps(const TColgp_Array1OfPnt& Pnts);
//! computes the global properties of the system of points Pnts.
//! The density of the points are defaulted to all being 1
Standard_EXPORT GProp_PGProps(const TColgp_Array2OfPnt& Pnts);
//! computes the global properties of the system of points Pnts.
//! A density is associated with each point.
@@ -106,8 +99,8 @@ public:
//!
//! raises if the length of Pnts and the length of Density
//! is not the same.
Standard_EXPORT GProp_PGProps(const TColgp_Array1OfPnt& Pnts, const TColStd_Array1OfReal& Density);
Standard_EXPORT GProp_PGProps(const TColgp_Array1OfPnt& Pnts,
const TColStd_Array1OfReal& Density);
//! computes the global properties of the system of points Pnts.
//! A density is associated with each point.
@@ -117,18 +110,16 @@ public:
//!
//! Raised if the length of Pnts and the length of Density
//! is not the same.
Standard_EXPORT GProp_PGProps(const TColgp_Array2OfPnt& Pnts, const TColStd_Array2OfReal& Density);
Standard_EXPORT GProp_PGProps(const TColgp_Array2OfPnt& Pnts,
const TColStd_Array2OfReal& Density);
//! Computes the barycentre of a set of points. The density of the
//! points is defaulted to 1.
Standard_EXPORT static gp_Pnt Barycentre (const TColgp_Array1OfPnt& Pnts);
Standard_EXPORT static gp_Pnt Barycentre(const TColgp_Array1OfPnt& Pnts);
//! Computes the barycentre of a set of points. The density of the
//! points is defaulted to 1.
Standard_EXPORT static gp_Pnt Barycentre (const TColgp_Array2OfPnt& Pnts);
Standard_EXPORT static gp_Pnt Barycentre(const TColgp_Array2OfPnt& Pnts);
//! Computes the barycentre of a set of points. A density is associated
//! with each point.
@@ -138,8 +129,10 @@ public:
//!
//! Raised if the length of Pnts and the length of Density
//! is not the same.
Standard_EXPORT static void Barycentre (const TColgp_Array1OfPnt& Pnts, const TColStd_Array1OfReal& Density, Standard_Real& Mass, gp_Pnt& G);
Standard_EXPORT static void Barycentre(const TColgp_Array1OfPnt& Pnts,
const TColStd_Array1OfReal& Density,
Standard_Real& Mass,
gp_Pnt& G);
//! Computes the barycentre of a set of points. A density is associated
//! with each point.
@@ -149,29 +142,13 @@ public:
//!
//! Raised if the length of Pnts and the length of Density
//! is not the same.
Standard_EXPORT static void Barycentre (const TColgp_Array2OfPnt& Pnts, const TColStd_Array2OfReal& Density, Standard_Real& Mass, gp_Pnt& G);
Standard_EXPORT static void Barycentre(const TColgp_Array2OfPnt& Pnts,
const TColStd_Array2OfReal& Density,
Standard_Real& Mass,
gp_Pnt& G);
protected:
private:
};
#endif // _GProp_PGProps_HeaderFile

View File

@@ -12,99 +12,109 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <GProp_PrincipalProps.hxx>
typedef gp_Vec Vec;
typedef gp_Pnt Pnt;
GProp_PrincipalProps::GProp_PrincipalProps()
{
i1 = i2 = i3 = RealLast();
r1 = r2 = r3 = RealLast();
v1 = Vec(1.0, 0.0, 0.0);
v2 = Vec(0.0, 1.0, 0.0);
v3 = Vec(0.0, 0.0, 1.0);
g = Pnt(RealLast(), RealLast(), RealLast());
}
GProp_PrincipalProps::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)
: i1(Ixx),
i2(Iyy),
i3(Izz),
r1(Rxx),
r2(Ryy),
r3(Rzz),
v1(Vxx),
v2(Vyy),
v3(Vzz),
g(G)
{
}
Standard_Boolean GProp_PrincipalProps::HasSymmetryAxis() const
{
GProp_PrincipalProps::GProp_PrincipalProps () {
// Standard_Real Eps1 = Abs(Epsilon (i1));
// Standard_Real Eps2 = Abs(Epsilon (i2));
const Standard_Real aRelTol = 1.e-10;
Standard_Real Eps1 = Abs(i1) * aRelTol;
Standard_Real Eps2 = Abs(i2) * aRelTol;
return (Abs(i1 - i2) <= Eps1 || Abs(i1 - i3) <= Eps1 || Abs(i2 - i3) <= Eps2);
}
i1= i2 = i3 = RealLast();
r1 = r2 = r3 = RealLast();
v1 = Vec (1.0, 0.0, 0.0);
v2 = Vec (0.0, 1.0, 0.0);
v3 = Vec (0.0, 0.0, 1.0);
g = Pnt (RealLast(), RealLast(), RealLast());
}
Standard_Boolean GProp_PrincipalProps::HasSymmetryAxis(const Standard_Real aTol) const
{
Standard_Real Eps1 = Abs(i1 * aTol) + Abs(Epsilon(i1));
Standard_Real Eps2 = Abs(i2 * aTol) + Abs(Epsilon(i2));
return (Abs(i1 - i2) <= Eps1 || Abs(i1 - i3) <= Eps1 || Abs(i2 - i3) <= Eps2);
}
GProp_PrincipalProps::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) :
i1 (Ixx), i2 (Iyy), i3 (Izz), r1 (Rxx), r2 (Ryy), r3 (Rzz),
v1 (Vxx), v2 (Vyy), v3 (Vzz), g (G) { }
Standard_Boolean GProp_PrincipalProps::HasSymmetryPoint() const
{
// Standard_Real Eps1 = Abs(Epsilon (i1));
const Standard_Real aRelTol = 1.e-10;
Standard_Real Eps1 = Abs(i1) * aRelTol;
return (Abs(i1 - i2) <= Eps1 && Abs(i1 - i3) <= Eps1);
}
Standard_Boolean GProp_PrincipalProps::HasSymmetryAxis () const {
Standard_Boolean GProp_PrincipalProps::HasSymmetryPoint(const Standard_Real aTol) const
{
// Standard_Real Eps1 = Abs(Epsilon (i1));
// Standard_Real Eps2 = Abs(Epsilon (i2));
const Standard_Real aRelTol = 1.e-10;
Standard_Real Eps1 = Abs(i1)*aRelTol;
Standard_Real Eps2 = Abs(i2)*aRelTol;
return (Abs (i1 - i2) <= Eps1 || Abs (i1 - i3) <= Eps1 ||
Abs (i2 - i3) <= Eps2);
}
Standard_Boolean GProp_PrincipalProps::HasSymmetryAxis (const Standard_Real aTol) const {
Standard_Real Eps1 = Abs(i1*aTol) + Abs(Epsilon(i1));
Standard_Real Eps2 = Abs(i2*aTol) + Abs(Epsilon(i2));
return (Abs (i1 - i2) <= Eps1 || Abs (i1 - i3) <= Eps1 ||
Abs (i2 - i3) <= Eps2);
}
Standard_Boolean GProp_PrincipalProps::HasSymmetryPoint () const {
// Standard_Real Eps1 = Abs(Epsilon (i1));
const Standard_Real aRelTol = 1.e-10;
Standard_Real Eps1 = Abs(i1)*aRelTol;
return (Abs (i1 - i2) <= Eps1 && Abs (i1 - i3) <= Eps1);
}
Standard_Boolean GProp_PrincipalProps::HasSymmetryPoint (const Standard_Real aTol) const {
Standard_Real Eps1 = Abs(i1*aTol) + Abs(Epsilon(i1));
return (Abs (i1 - i2) <= Eps1 && Abs (i1 - i3) <= Eps1);
}
void GProp_PrincipalProps::Moments (Standard_Real& Ixx, Standard_Real& Iyy, Standard_Real& Izz) const {
Ixx = i1;
Iyy = i2;
Izz = i3;
}
const Vec& GProp_PrincipalProps::FirstAxisOfInertia () const {return v1;}
const Vec& GProp_PrincipalProps::SecondAxisOfInertia () const {return v2;}
const Vec& GProp_PrincipalProps::ThirdAxisOfInertia () const {return v3;}
void GProp_PrincipalProps::RadiusOfGyration (
Standard_Real& Rxx, Standard_Real& Ryy, Standard_Real& Rzz) const {
Rxx = r1;
Ryy = r2;
Rzz = r3;
}
Standard_Real Eps1 = Abs(i1 * aTol) + Abs(Epsilon(i1));
return (Abs(i1 - i2) <= Eps1 && Abs(i1 - i3) <= Eps1);
}
void GProp_PrincipalProps::Moments(Standard_Real& Ixx, Standard_Real& Iyy, Standard_Real& Izz) const
{
Ixx = i1;
Iyy = i2;
Izz = i3;
}
const Vec& GProp_PrincipalProps::FirstAxisOfInertia() const
{
return v1;
}
const Vec& GProp_PrincipalProps::SecondAxisOfInertia() const
{
return v2;
}
const Vec& GProp_PrincipalProps::ThirdAxisOfInertia() const
{
return v3;
}
void GProp_PrincipalProps::RadiusOfGyration(Standard_Real& Rxx,
Standard_Real& Ryy,
Standard_Real& Rzz) const
{
Rxx = r1;
Ryy = r2;
Rzz = r3;
}

View File

@@ -26,8 +26,6 @@
#include <GProp_GProps.hxx>
#include <Standard_Boolean.hxx>
//! A framework to present the principal properties of
//! inertia of a system of which global properties are
//! computed by a GProp_GProps object.
@@ -46,42 +44,36 @@
//! as the current system. The current system,
//! however, is retained neither by this presentation
//! framework nor by the GProp_GProps object which activates it.
class GProp_PrincipalProps
class GProp_PrincipalProps
{
public:
DEFINE_STANDARD_ALLOC
//! creates an undefined PrincipalProps.
Standard_EXPORT GProp_PrincipalProps();
//! returns true if the geometric system has an axis of symmetry.
//! For comparing moments relative tolerance 1.e-10 is used.
//! Usually it is enough for objects, restricted by faces with
//! analytical geometry.
Standard_EXPORT Standard_Boolean HasSymmetryAxis() const;
//! returns true if the geometric system has an axis of symmetry.
//! aTol is relative tolerance for checking equality of moments
//! If aTol == 0, relative tolerance is ~ 1.e-16 (Epsilon(I))
Standard_EXPORT Standard_Boolean HasSymmetryAxis (const Standard_Real aTol) const;
Standard_EXPORT Standard_Boolean HasSymmetryAxis(const Standard_Real aTol) const;
//! returns true if the geometric system has a point of symmetry.
//! For comparing moments relative tolerance 1.e-10 is used.
//! Usually it is enough for objects, restricted by faces with
//! analytical geometry.
Standard_EXPORT Standard_Boolean HasSymmetryPoint() const;
//! returns true if the geometric system has a point of symmetry.
//! aTol is relative tolerance for checking equality of moments
//! If aTol == 0, relative tolerance is ~ 1.e-16 (Epsilon(I))
Standard_EXPORT Standard_Boolean HasSymmetryPoint (const Standard_Real aTol) const;
Standard_EXPORT Standard_Boolean HasSymmetryPoint(const Standard_Real aTol) const;
//! Ixx, Iyy and Izz return the principal moments of inertia
//! in the current system.
//! Notes :
@@ -91,21 +83,21 @@ public:
//! axes of principal inertia.
//! - If the current system has a center of symmetry, Ixx,
//! Iyy and Izz are equal.
Standard_EXPORT void Moments (Standard_Real& Ixx, Standard_Real& Iyy, Standard_Real& Izz) const;
Standard_EXPORT void Moments(Standard_Real& Ixx, Standard_Real& Iyy, Standard_Real& Izz) const;
//! returns the first axis of inertia.
//!
//! if the system has a point of symmetry there is an infinity of
//! solutions. It is not possible to defines the three axis of
//! inertia.
Standard_EXPORT const gp_Vec& FirstAxisOfInertia() const;
//! returns the second axis of inertia.
//!
//! if the system has a point of symmetry or an axis of symmetry the
//! second and the third axis of symmetry are undefined.
Standard_EXPORT const gp_Vec& SecondAxisOfInertia() const;
//! returns the third axis of inertia.
//! This and the above functions return the first, second or third eigen vector of the
//! matrix of inertia of the current system.
@@ -132,7 +124,7 @@ public:
//! if the system has a point of symmetry or an axis of symmetry the
//! second and the third axis of symmetry are undefined.
Standard_EXPORT const gp_Vec& ThirdAxisOfInertia() const;
//! Returns the principal radii of gyration Rxx, Ryy
//! and Rzz are the radii of gyration of the current
//! system about its three principal axes of inertia.
@@ -141,37 +133,39 @@ public:
//! two of the three values Rxx, Ryy and Rzz are equal.
//! - If the current system has a center of symmetry,
//! Rxx, Ryy and Rzz are equal.
Standard_EXPORT void RadiusOfGyration (Standard_Real& Rxx, Standard_Real& Ryy, Standard_Real& Rzz) const;
friend
//! Computes the principal properties of inertia of the current system.
//! There is always a set of axes for which the products
//! of inertia of a geometric system are equal to 0; i.e. the
//! matrix of inertia of the system is diagonal. These axes
//! are the principal axes of inertia. Their origin is
//! coincident with the center of mass of the system. The
//! associated moments are called the principal moments of inertia.
//! This function computes the eigen values and the
//! eigen vectors of the matrix of inertia of the system.
//! Results are stored by using a presentation framework
//! of principal properties of inertia
//! (GProp_PrincipalProps object) which may be
//! queried to access the value sought.
Standard_EXPORT GProp_PrincipalProps GProp_GProps::PrincipalProperties() const;
Standard_EXPORT void RadiusOfGyration(Standard_Real& Rxx,
Standard_Real& Ryy,
Standard_Real& Rzz) const;
friend
//! Computes the principal properties of inertia of the current system.
//! There is always a set of axes for which the products
//! of inertia of a geometric system are equal to 0; i.e. the
//! matrix of inertia of the system is diagonal. These axes
//! are the principal axes of inertia. Their origin is
//! coincident with the center of mass of the system. The
//! associated moments are called the principal moments of inertia.
//! This function computes the eigen values and the
//! eigen vectors of the matrix of inertia of the system.
//! Results are stored by using a presentation framework
//! of principal properties of inertia
//! (GProp_PrincipalProps object) which may be
//! queried to access the value sought.
Standard_EXPORT GProp_PrincipalProps
GProp_GProps::PrincipalProperties() const;
protected:
private:
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);
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);
Standard_Real i1;
Standard_Real i2;
@@ -179,18 +173,10 @@ private:
Standard_Real r1;
Standard_Real r2;
Standard_Real r3;
gp_Vec v1;
gp_Vec v2;
gp_Vec v3;
gp_Pnt g;
gp_Vec v1;
gp_Vec v2;
gp_Vec v3;
gp_Pnt g;
};
#endif // _GProp_PrincipalProps_HeaderFile

View File

@@ -12,7 +12,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <gp_Cone.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Pnt.hxx>
@@ -24,171 +23,179 @@
#include <math_Matrix.hxx>
#include <math_Vector.hxx>
GProp_SelGProps::GProp_SelGProps(){}
GProp_SelGProps::GProp_SelGProps() {}
void GProp_SelGProps::SetLocation(const gp_Pnt& SLocation )
void GProp_SelGProps::SetLocation(const gp_Pnt& SLocation)
{
loc = SLocation;
}
void GProp_SelGProps::Perform(const gp_Cylinder& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2)
{
Standard_Real X0,Y0,Z0,Xa1,Ya1,Za1,Xa2,Ya2,Za2,Xa3,Ya3,Za3;
S.Location().Coord(X0,Y0,Z0);
void GProp_SelGProps::Perform(const gp_Cylinder& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2)
{
Standard_Real X0, Y0, Z0, Xa1, Ya1, Za1, Xa2, Ya2, Za2, Xa3, Ya3, Za3;
S.Location().Coord(X0, Y0, Z0);
Standard_Real R = S.Radius();
S.Position().XDirection().Coord(Xa1,Ya1,Za1);
S.Position().YDirection().Coord(Xa2,Ya2,Za2);
S.Position().Direction().Coord(Xa3,Ya3,Za3);
dim = R*(Z2-Z1)*(Alpha2-Alpha1);
S.Position().XDirection().Coord(Xa1, Ya1, Za1);
S.Position().YDirection().Coord(Xa2, Ya2, Za2);
S.Position().Direction().Coord(Xa3, Ya3, Za3);
dim = R * (Z2 - Z1) * (Alpha2 - Alpha1);
Standard_Real SA2 = Sin(Alpha2);
Standard_Real SA1 = Sin(Alpha1);
Standard_Real CA2 = Cos(Alpha2);
Standard_Real CA1 = Cos(Alpha1);
Standard_Real Ix = R*(SA2-SA1)/(Alpha2-Alpha1);
Standard_Real Iy = R*(CA1-CA2)/(Alpha2-Alpha1);
g.SetCoord( X0 + Ix*Xa1+Iy*Xa2 + Xa3*(Z2+Z1)/2.,
Y0 + Ix*Ya1+Iy*Ya2 + Ya3*(Z2+Z1)/2.,
Z0 + Ix*Za1+Iy*Za2 + Za3*(Z2+Z1)/2.);
Standard_Real ICn2 =R*R*( Alpha2-Alpha1 + SA2*CA2 - SA1*CA1 )/2.;
Standard_Real ISn2 =R*R*( Alpha2-Alpha1 - SA2*CA2 + SA1*CA1 )/2.;
Standard_Real IZ2 = (Alpha2-Alpha1)*(Z2*Z2+Z2*Z1+Z1*Z1)/3.;
Standard_Real ICnSn= R*R*( SA2*SA2-SA1*SA1)/2.;
Standard_Real ICnz = (Z2+Z1)*(SA2-SA1)/2.;
Standard_Real ISnz = (Z2+Z1)*(CA1-CA2)/2.;
Standard_Real Ix = R * (SA2 - SA1) / (Alpha2 - Alpha1);
Standard_Real Iy = R * (CA1 - CA2) / (Alpha2 - Alpha1);
g.SetCoord(X0 + Ix * Xa1 + Iy * Xa2 + Xa3 * (Z2 + Z1) / 2.,
Y0 + Ix * Ya1 + Iy * Ya2 + Ya3 * (Z2 + Z1) / 2.,
Z0 + Ix * Za1 + Iy * Za2 + Za3 * (Z2 + Z1) / 2.);
Standard_Real ICn2 = R * R * (Alpha2 - Alpha1 + SA2 * CA2 - SA1 * CA1) / 2.;
Standard_Real ISn2 = R * R * (Alpha2 - Alpha1 - SA2 * CA2 + SA1 * CA1) / 2.;
Standard_Real IZ2 = (Alpha2 - Alpha1) * (Z2 * Z2 + Z2 * Z1 + Z1 * Z1) / 3.;
Standard_Real ICnSn = R * R * (SA2 * SA2 - SA1 * SA1) / 2.;
Standard_Real ICnz = (Z2 + Z1) * (SA2 - SA1) / 2.;
Standard_Real ISnz = (Z2 + Z1) * (CA1 - CA2) / 2.;
math_Matrix Dm(1,3,1,3);
math_Matrix Dm(1, 3, 1, 3);
Dm(1,1) = ISn2 + IZ2;
Dm(2,2) = ICn2 + IZ2;
Dm(3,3) = Alpha2-Alpha1;
Dm(1,2) = Dm(2,1) = -ICnSn;
Dm(1,3) = Dm(3,1) = -ICnz;
Dm(3,2) = Dm(2,3) = -ISnz;
Dm(1, 1) = ISn2 + IZ2;
Dm(2, 2) = ICn2 + IZ2;
Dm(3, 3) = Alpha2 - Alpha1;
Dm(1, 2) = Dm(2, 1) = -ICnSn;
Dm(1, 3) = Dm(3, 1) = -ICnz;
Dm(3, 2) = Dm(2, 3) = -ISnz;
math_Matrix Passage (1,3,1,3);
Passage(1,1) = Xa1; Passage(1,2) = Xa2 ;Passage(1,3) = Xa3;
Passage(2,1) = Ya1; Passage(2,2) = Ya2 ;Passage(2,3) = Ya3;
Passage(3,1) = Za1; Passage(3,2) = Za2 ;Passage(3,3) = Za3;
math_Matrix Passage(1, 3, 1, 3);
Passage(1, 1) = Xa1;
Passage(1, 2) = Xa2;
Passage(1, 3) = Xa3;
Passage(2, 1) = Ya1;
Passage(2, 2) = Ya2;
Passage(2, 3) = Ya3;
Passage(3, 1) = Za1;
Passage(3, 2) = Za2;
Passage(3, 3) = Za3;
math_Jacobi J(Dm);
R = R*(Z2-Z1);
math_Vector V1(1,3), V2(1,3), V3(1,3);
J.Vector(1,V1);
V1.Multiply(Passage,V1);
V1.Multiply(R*J.Value(1));
J.Vector(2,V2);
V2.Multiply(Passage,V2);
V2.Multiply(R*J.Value(2));
J.Vector(3,V3);
V3.Multiply(Passage,V3);
V3.Multiply(R*J.Value(3));
R = R * (Z2 - Z1);
math_Vector V1(1, 3), V2(1, 3), V3(1, 3);
J.Vector(1, V1);
V1.Multiply(Passage, V1);
V1.Multiply(R * J.Value(1));
J.Vector(2, V2);
V2.Multiply(Passage, V2);
V2.Multiply(R * J.Value(2));
J.Vector(3, V3);
V3.Multiply(Passage, V3);
V3.Multiply(R * J.Value(3));
inertia = gp_Mat (gp_XYZ(V1(1),V2(1),V3(1)),
gp_XYZ(V1(2),V2(2),V3(2)),
gp_XYZ(V1(3),V2(3),V3(3)));
inertia =
gp_Mat(gp_XYZ(V1(1), V2(1), V3(1)), gp_XYZ(V1(2), V2(2), V3(2)), gp_XYZ(V1(3), V2(3), V3(3)));
gp_Mat Hop;
GProp::HOperator(g,loc,dim,Hop);
inertia = inertia+Hop;
GProp::HOperator(g, loc, dim, Hop);
inertia = inertia + Hop;
}
void GProp_SelGProps::Perform (const gp_Cone& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2)
void GProp_SelGProps::Perform(const gp_Cone& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2)
{
Standard_Real X0,Y0,Z0,Xa1,Ya1,Za1,Xa2,Ya2,Za2,Xa3,Ya3,Za3;
S.Location().Coord(X0,Y0,Z0);
S.Position().XDirection().Coord(Xa1,Ya1,Za1);
S.Position().YDirection().Coord(Xa2,Ya2,Za2);
S.Position().Direction().Coord(Xa3,Ya3,Za3);
Standard_Real t =S.SemiAngle();
Standard_Real X0, Y0, Z0, Xa1, Ya1, Za1, Xa2, Ya2, Za2, Xa3, Ya3, Za3;
S.Location().Coord(X0, Y0, Z0);
S.Position().XDirection().Coord(Xa1, Ya1, Za1);
S.Position().YDirection().Coord(Xa2, Ya2, Za2);
S.Position().Direction().Coord(Xa3, Ya3, Za3);
Standard_Real t = S.SemiAngle();
Standard_Real Cnt = Cos(t);
Standard_Real Snt = Sin(t);
Standard_Real R = S.RefRadius();
Standard_Real Snt = Sin(t);
Standard_Real R = S.RefRadius();
Standard_Real Sn2 = Sin(Alpha2);
Standard_Real Sn1 = Sin(Alpha1);
Standard_Real Cn2 = Cos(Alpha2);
Standard_Real Cn1 = Cos(Alpha1);
Standard_Real Auxi1 = R + (Z2+Z1)*Snt/2.;
Standard_Real Auxi2 = (Z2*Z2+Z1*Z2+Z1*Z1)/3.;
dim = (Alpha2-Alpha1)*Cnt*(Z2-Z1)*Auxi1;
Standard_Real Auxi1 = R + (Z2 + Z1) * Snt / 2.;
Standard_Real Auxi2 = (Z2 * Z2 + Z1 * Z2 + Z1 * Z1) / 3.;
dim = (Alpha2 - Alpha1) * Cnt * (Z2 - Z1) * Auxi1;
Standard_Real Ix =
(R*R+R*(Z2+Z1)*Snt + Snt*Auxi2)/Auxi1;
Standard_Real Iy = Ix*(Cn1-Cn2)/(Alpha2-Alpha1);
Ix = Ix*(Sn2-Sn1)/(Alpha2-Alpha1);
Standard_Real Iz = Cnt*(R*(Z2+Z1)/2.+Snt*Auxi2)/Auxi1;
Standard_Real Ix = (R * R + R * (Z2 + Z1) * Snt + Snt * Auxi2) / Auxi1;
Standard_Real Iy = Ix * (Cn1 - Cn2) / (Alpha2 - Alpha1);
Ix = Ix * (Sn2 - Sn1) / (Alpha2 - Alpha1);
Standard_Real Iz = Cnt * (R * (Z2 + Z1) / 2. + Snt * Auxi2) / Auxi1;
g.SetCoord(X0 + Xa1*Ix+ Xa2*Iy+ Xa3*Iz,
Y0 + Ya1*Ix+ Ya2*Iy+ Ya3*Iz,
Z0 + Za1*Ix+ Za2*Iy+ Za3*Iz);
Standard_Real R1 = R+Z1*Snt;
Standard_Real R2 = R+Z2*Snt;
Standard_Real ZZ = (Z2-Z1)*Cnt;
Standard_Real IR2 = ZZ*Snt*(R1*R1*R1+R1*R1*R2+R1*R2*R2+R2*R2*R2)/4.;
Standard_Real ICn2 = IR2*(Alpha2-Alpha1+Cn2*Sn2-Cn1*Sn1)/2.;
Standard_Real ISn2 = IR2*(Alpha2-Alpha1+Cn2*Sn2-Cn1*Sn1)/2.;
Standard_Real IZ2 = ZZ*Cnt*Cnt*(Z2-Z1)*(Alpha2-Alpha1)*
(R*Auxi2 +Snt*(Z2*Z2*Z2+Z2*Z2*Z1+Z2*Z1*Z1+Z1*Z1*Z1))/4.;
Standard_Real ICnSn = IR2*(Cn2*Cn2-Cn1*Cn1);
Standard_Real ICnz = Cnt*Snt*ZZ*(R*(Z1+Z2)/2.+Auxi2)*(Sn2-Sn1);
Standard_Real ISnz = Cnt*Snt*ZZ*(R*(Z1+Z2)/2.+Auxi2)*(Cn1-Cn2);
g.SetCoord(X0 + Xa1 * Ix + Xa2 * Iy + Xa3 * Iz,
Y0 + Ya1 * Ix + Ya2 * Iy + Ya3 * Iz,
Z0 + Za1 * Ix + Za2 * Iy + Za3 * Iz);
math_Matrix Dm(1,3,1,3);
Dm(1,1) = ISn2 + IZ2;
Dm(2,2) = ICn2 + IZ2;
Dm(3,3) = IR2*(Alpha2-Alpha1);
Dm(1,2) = Dm(2,1) = -ICnSn;
Dm(1,3) = Dm(3,1) = -ICnz;
Dm(3,2) = Dm(2,3) = -ISnz;
Standard_Real R1 = R + Z1 * Snt;
Standard_Real R2 = R + Z2 * Snt;
Standard_Real ZZ = (Z2 - Z1) * Cnt;
Standard_Real IR2 = ZZ * Snt * (R1 * R1 * R1 + R1 * R1 * R2 + R1 * R2 * R2 + R2 * R2 * R2) / 4.;
Standard_Real ICn2 = IR2 * (Alpha2 - Alpha1 + Cn2 * Sn2 - Cn1 * Sn1) / 2.;
Standard_Real ISn2 = IR2 * (Alpha2 - Alpha1 + Cn2 * Sn2 - Cn1 * Sn1) / 2.;
Standard_Real IZ2 =
ZZ * Cnt * Cnt * (Z2 - Z1) * (Alpha2 - Alpha1)
* (R * Auxi2 + Snt * (Z2 * Z2 * Z2 + Z2 * Z2 * Z1 + Z2 * Z1 * Z1 + Z1 * Z1 * Z1)) / 4.;
Standard_Real ICnSn = IR2 * (Cn2 * Cn2 - Cn1 * Cn1);
Standard_Real ICnz = Cnt * Snt * ZZ * (R * (Z1 + Z2) / 2. + Auxi2) * (Sn2 - Sn1);
Standard_Real ISnz = Cnt * Snt * ZZ * (R * (Z1 + Z2) / 2. + Auxi2) * (Cn1 - Cn2);
math_Matrix Passage (1,3,1,3);
Passage(1,1) = Xa1; Passage(1,2) = Xa2 ;Passage(1,3) = Xa3;
Passage(2,1) = Ya1; Passage(2,2) = Ya2 ;Passage(2,3) = Ya3;
Passage(3,1) = Za1; Passage(3,2) = Za2 ;Passage(3,3) = Za3;
math_Matrix Dm(1, 3, 1, 3);
Dm(1, 1) = ISn2 + IZ2;
Dm(2, 2) = ICn2 + IZ2;
Dm(3, 3) = IR2 * (Alpha2 - Alpha1);
Dm(1, 2) = Dm(2, 1) = -ICnSn;
Dm(1, 3) = Dm(3, 1) = -ICnz;
Dm(3, 2) = Dm(2, 3) = -ISnz;
math_Matrix Passage(1, 3, 1, 3);
Passage(1, 1) = Xa1;
Passage(1, 2) = Xa2;
Passage(1, 3) = Xa3;
Passage(2, 1) = Ya1;
Passage(2, 2) = Ya2;
Passage(2, 3) = Ya3;
Passage(3, 1) = Za1;
Passage(3, 2) = Za2;
Passage(3, 3) = Za3;
math_Jacobi J(Dm);
math_Vector V1(1,3),V2(1,3),V3(1,3);
J.Vector(1,V1);
V1.Multiply(Passage,V1);
math_Vector V1(1, 3), V2(1, 3), V3(1, 3);
J.Vector(1, V1);
V1.Multiply(Passage, V1);
V1.Multiply(J.Value(1));
J.Vector(2,V2);
V2.Multiply(Passage,V2);
J.Vector(2, V2);
V2.Multiply(Passage, V2);
V2.Multiply(J.Value(2));
J.Vector(3,V3);
V3.Multiply(Passage,V3);
J.Vector(3, V3);
V3.Multiply(Passage, V3);
V3.Multiply(J.Value(3));
inertia = gp_Mat (gp_XYZ(V1(1),V2(1),V3(1)),
gp_XYZ(V1(2),V2(2),V3(2)),
gp_XYZ(V1(3),V2(3),V3(3)));
inertia =
gp_Mat(gp_XYZ(V1(1), V2(1), V3(1)), gp_XYZ(V1(2), V2(2), V3(2)), gp_XYZ(V1(3), V2(3), V3(3)));
gp_Mat Hop;
GProp::HOperator(g,loc,dim,Hop);
inertia = inertia+Hop;
GProp::HOperator(g, loc, dim, Hop);
inertia = inertia + Hop;
}
void GProp_SelGProps::Perform(const gp_Sphere& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2)
void GProp_SelGProps::Perform(const gp_Sphere& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2)
{
Standard_Real X0,Y0,Z0,Xa1,Ya1,Za1,Xa2,Ya2,Za2,Xa3,Ya3,Za3;
S.Location().Coord(X0,Y0,Z0);
S.Position().XDirection().Coord(Xa1,Ya1,Za1);
S.Position().YDirection().Coord(Xa2,Ya2,Za2);
S.Position().Direction().Coord(Xa3,Ya3,Za3);
Standard_Real R = S.Radius();
Standard_Real X0, Y0, Z0, Xa1, Ya1, Za1, Xa2, Ya2, Za2, Xa3, Ya3, Za3;
S.Location().Coord(X0, Y0, Z0);
S.Position().XDirection().Coord(Xa1, Ya1, Za1);
S.Position().YDirection().Coord(Xa2, Ya2, Za2);
S.Position().Direction().Coord(Xa3, Ya3, Za3);
Standard_Real R = S.Radius();
Standard_Real Cnt1 = Cos(Teta1);
Standard_Real Snt1 = Sin(Teta1);
Standard_Real Cnt2 = Cos(Teta2);
@@ -197,76 +204,75 @@ void GProp_SelGProps::Perform(const gp_Sphere& S,
Standard_Real Snf1 = Sin(Alpha1);
Standard_Real Cnf2 = Cos(Alpha2);
Standard_Real Snf2 = Sin(Alpha2);
dim = R*R*(Teta2-Teta1)*(Snf2-Snf1);
Standard_Real Ix =
R*(Snt2-Snt1)/(Teta2-Teta1)*
(Alpha2-Alpha1+Snf2*Cnf2-Snf1*Cnf1)/(Snf2-Snf1)/2.;
Standard_Real Iy =
R*(Cnt1-Cnt2)/(Teta2-Teta1)*
(Alpha2-Alpha1+Snf2*Cnf2-Snf1*Cnf1)/(Snf2-Snf1)/2.;
Standard_Real Iz = R*(Snf2+Snf1)/2.;
g.SetCoord(
X0 + Ix*Xa1 + Iy*Xa2 + Iz*Xa3,
Y0 + Ix*Ya1 + Iy*Ya2 + Iz*Ya3,
Z0 + Ix*Za1 + Iy*Za2 + Iz*Za3);
dim = R * R * (Teta2 - Teta1) * (Snf2 - Snf1);
Standard_Real Ix = R * (Snt2 - Snt1) / (Teta2 - Teta1)
* (Alpha2 - Alpha1 + Snf2 * Cnf2 - Snf1 * Cnf1) / (Snf2 - Snf1) / 2.;
Standard_Real Iy = R * (Cnt1 - Cnt2) / (Teta2 - Teta1)
* (Alpha2 - Alpha1 + Snf2 * Cnf2 - Snf1 * Cnf1) / (Snf2 - Snf1) / 2.;
Standard_Real Iz = R * (Snf2 + Snf1) / 2.;
g.SetCoord(X0 + Ix * Xa1 + Iy * Xa2 + Iz * Xa3,
Y0 + Ix * Ya1 + Iy * Ya2 + Iz * Ya3,
Z0 + Ix * Za1 + Iy * Za2 + Iz * Za3);
Standard_Real IR2 = ( Cnf2*Snf2*(Cnf2+1.)- Cnf1*Snf1*(Cnf1+1.) +
Alpha2-Alpha1 )/3.;
Standard_Real ICn2 = (Teta2-Teta1+ Cnt2*Snt2-Cnt1*Snt1)*IR2/2.;
Standard_Real ISn2 = (Teta2-Teta1-Cnt2*Snt2+Cnt1*Snt1)*IR2/2.;
Standard_Real ICnSn = ( Snt2*Snt2-Snt1*Snt1)*IR2/2.;
Standard_Real IZ2 = (Teta2-Teta1)*(Snf2*Snf2*Snf2-Snf1*Snf1*Snf1)/3.;
Standard_Real ICnz =(Snt2-Snt1)*(Cnf1*Cnf1*Cnf1-Cnf2*Cnf2*Cnf2)/3.;
Standard_Real ISnz =(Cnt1-Cnt2)*(Cnf1*Cnf1*Cnf1-Cnf2*Cnf2*Cnf2)/3.;
Standard_Real IR2 =
(Cnf2 * Snf2 * (Cnf2 + 1.) - Cnf1 * Snf1 * (Cnf1 + 1.) + Alpha2 - Alpha1) / 3.;
Standard_Real ICn2 = (Teta2 - Teta1 + Cnt2 * Snt2 - Cnt1 * Snt1) * IR2 / 2.;
Standard_Real ISn2 = (Teta2 - Teta1 - Cnt2 * Snt2 + Cnt1 * Snt1) * IR2 / 2.;
Standard_Real ICnSn = (Snt2 * Snt2 - Snt1 * Snt1) * IR2 / 2.;
Standard_Real IZ2 = (Teta2 - Teta1) * (Snf2 * Snf2 * Snf2 - Snf1 * Snf1 * Snf1) / 3.;
Standard_Real ICnz = (Snt2 - Snt1) * (Cnf1 * Cnf1 * Cnf1 - Cnf2 * Cnf2 * Cnf2) / 3.;
Standard_Real ISnz = (Cnt1 - Cnt2) * (Cnf1 * Cnf1 * Cnf1 - Cnf2 * Cnf2 * Cnf2) / 3.;
math_Matrix Dm(1,3,1,3);
Dm(1,1) = ISn2 +IZ2;
Dm(2,2) = ICn2 +IZ2;
Dm(3,3) = IR2*(Teta2-Teta1);
Dm(1,2) = Dm(2,1) = -ICnSn;
Dm(1,3) = Dm(3,1) = -ICnz;
Dm(3,2) = Dm(2,3) = -ISnz;
math_Matrix Dm(1, 3, 1, 3);
Dm(1, 1) = ISn2 + IZ2;
Dm(2, 2) = ICn2 + IZ2;
Dm(3, 3) = IR2 * (Teta2 - Teta1);
Dm(1, 2) = Dm(2, 1) = -ICnSn;
Dm(1, 3) = Dm(3, 1) = -ICnz;
Dm(3, 2) = Dm(2, 3) = -ISnz;
math_Matrix Passage (1,3,1,3);
Passage(1,1) = Xa1; Passage(1,2) = Xa2 ;Passage(1,3) = Xa3;
Passage(2,1) = Ya1; Passage(2,2) = Ya2 ;Passage(2,3) = Ya3;
Passage(3,1) = Za1; Passage(3,2) = Za2 ;Passage(3,3) = Za3;
math_Matrix Passage(1, 3, 1, 3);
Passage(1, 1) = Xa1;
Passage(1, 2) = Xa2;
Passage(1, 3) = Xa3;
Passage(2, 1) = Ya1;
Passage(2, 2) = Ya2;
Passage(2, 3) = Ya3;
Passage(3, 1) = Za1;
Passage(3, 2) = Za2;
Passage(3, 3) = Za3;
math_Jacobi J(Dm);
R = R*R*R*R;
math_Vector V1(1,3), V2(1,3), V3(1,3);
J.Vector(1,V1);
V1.Multiply(Passage,V1);
V1.Multiply(R*J.Value(1));
J.Vector(2,V2);
V2.Multiply(Passage,V2);
V2.Multiply(R*J.Value(2));
J.Vector(3,V3);
V3.Multiply(Passage,V3);
V3.Multiply(R*J.Value(3));
R = R * R * R * R;
math_Vector V1(1, 3), V2(1, 3), V3(1, 3);
J.Vector(1, V1);
V1.Multiply(Passage, V1);
V1.Multiply(R * J.Value(1));
J.Vector(2, V2);
V2.Multiply(Passage, V2);
V2.Multiply(R * J.Value(2));
J.Vector(3, V3);
V3.Multiply(Passage, V3);
V3.Multiply(R * J.Value(3));
inertia = gp_Mat (gp_XYZ(V1(1),V2(1),V3(1)),
gp_XYZ(V1(2),V2(2),V3(2)),
gp_XYZ(V1(3),V2(3),V3(3)));
inertia =
gp_Mat(gp_XYZ(V1(1), V2(1), V3(1)), gp_XYZ(V1(2), V2(2), V3(2)), gp_XYZ(V1(3), V2(3), V3(3)));
gp_Mat Hop;
GProp::HOperator(g,loc,dim,Hop);
inertia = inertia+Hop;
GProp::HOperator(g, loc, dim, Hop);
inertia = inertia + Hop;
}
void GProp_SelGProps::Perform (const gp_Torus& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2)
void GProp_SelGProps::Perform(const gp_Torus& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2)
{
Standard_Real X0,Y0,Z0,Xa1,Ya1,Za1,Xa2,Ya2,Za2,Xa3,Ya3,Za3;
S.Location().Coord(X0,Y0,Z0);
S.XAxis().Direction().Coord(Xa1,Ya1,Za1);
S.YAxis().Direction().Coord(Xa2,Ya2,Za2);
S.Axis().Direction().Coord(Xa3,Ya3,Za3);
Standard_Real X0, Y0, Z0, Xa1, Ya1, Za1, Xa2, Ya2, Za2, Xa3, Ya3, Za3;
S.Location().Coord(X0, Y0, Z0);
S.XAxis().Direction().Coord(Xa1, Ya1, Za1);
S.YAxis().Direction().Coord(Xa2, Ya2, Za2);
S.Axis().Direction().Coord(Xa3, Ya3, Za3);
Standard_Real RMax = S.MajorRadius();
Standard_Real Rmin = S.MinorRadius();
Standard_Real Cnt1 = Cos(Teta1);
@@ -278,113 +284,106 @@ void GProp_SelGProps::Perform (const gp_Torus& S,
Standard_Real Cnf2 = Cos(Alpha2);
Standard_Real Snf2 = Sin(Alpha2);
dim = RMax * Rmin * (Teta2 - Teta1) * (Alpha2 - Alpha1);
Standard_Real Ix =
(Snt2 - Snt1) / (Teta2 - Teta1) * (Rmin * (Snf2 - Snf1) / (Alpha2 - Alpha1) + RMax);
Standard_Real Iy =
(Cnt1 - Cnt2) / (Teta2 - Teta1) * (Rmin * (Snf2 - Snf1) / (Alpha2 - Alpha1) + RMax);
Standard_Real Iz = Rmin * (Cnf1 - Cnf2) / (Alpha2 - Alpha1);
dim = RMax*Rmin*(Teta2-Teta1)*(Alpha2-Alpha1);
Standard_Real Ix =
(Snt2-Snt1)/(Teta2-Teta1)*(Rmin*(Snf2-Snf1)/(Alpha2-Alpha1) + RMax);
Standard_Real Iy =
(Cnt1-Cnt2)/(Teta2-Teta1)*(Rmin*(Snf2-Snf1)/(Alpha2-Alpha1) + RMax);
Standard_Real Iz = Rmin*(Cnf1-Cnf2)/(Alpha2-Alpha1);
g.SetCoord(
X0+Ix*Xa1+Iy*Xa2+Iz*Xa3,
Y0+Ix*Ya1+Iy*Ya2+Iz*Ya3,
Z0+Ix*Za1+Iy*Za2+Iz*Za3);
g.SetCoord(X0 + Ix * Xa1 + Iy * Xa2 + Iz * Xa3,
Y0 + Ix * Ya1 + Iy * Ya2 + Iz * Ya3,
Z0 + Ix * Za1 + Iy * Za2 + Iz * Za3);
Standard_Real IR2 = RMax*RMax + 2.*RMax*Rmin*(Snf2-Snf1) +
Rmin*Rmin/2.*(Snf2*Cnf2-Snf1*Cnf1);
Standard_Real ICn2 = IR2*(Teta2-Teta1 +Snt2*Cnt2-Snt1*Cnt1)/2.;
Standard_Real ISn2 = IR2*(Teta2-Teta1 -Snt2*Cnt2+Snt1*Cnt1)/2.;
Standard_Real ICnSn = IR2*(Snt2*Snt2-Snt1*Snt1)/2.;
Standard_Real IZ2 =
(Teta2-Teta1)*Rmin*Rmin*(Alpha2-Alpha1-Snf2*Cnf2+Snf1*Cnf1)/2.;
Standard_Real ICnz = Rmin*(Snt2-Snt1)*(Cnf1-Cnf2)*(RMax+Rmin*(Cnf1+Cnf2)/2.);
Standard_Real ISnz = Rmin*(Cnt2-Cnt1)*(Cnf1-Cnf2)*(RMax+Rmin*(Cnf1+Cnf2)/2.);
Standard_Real IR2 =
RMax * RMax + 2. * RMax * Rmin * (Snf2 - Snf1) + Rmin * Rmin / 2. * (Snf2 * Cnf2 - Snf1 * Cnf1);
Standard_Real ICn2 = IR2 * (Teta2 - Teta1 + Snt2 * Cnt2 - Snt1 * Cnt1) / 2.;
Standard_Real ISn2 = IR2 * (Teta2 - Teta1 - Snt2 * Cnt2 + Snt1 * Cnt1) / 2.;
Standard_Real ICnSn = IR2 * (Snt2 * Snt2 - Snt1 * Snt1) / 2.;
Standard_Real IZ2 =
(Teta2 - Teta1) * Rmin * Rmin * (Alpha2 - Alpha1 - Snf2 * Cnf2 + Snf1 * Cnf1) / 2.;
Standard_Real ICnz = Rmin * (Snt2 - Snt1) * (Cnf1 - Cnf2) * (RMax + Rmin * (Cnf1 + Cnf2) / 2.);
Standard_Real ISnz = Rmin * (Cnt2 - Cnt1) * (Cnf1 - Cnf2) * (RMax + Rmin * (Cnf1 + Cnf2) / 2.);
math_Matrix Dm(1,3,1,3);
Dm(1,1) = ISn2 + IZ2;
Dm(2,2) = ICn2 + IZ2;
Dm(3,3) = IR2*(Teta2-Teta1);
Dm(1,2) = Dm(2,1) = -ICnSn;
Dm(1,3) = Dm(3,1) = -ICnz;
Dm(3,2) = Dm(2,3) = -ISnz;
math_Matrix Dm(1, 3, 1, 3);
Dm(1, 1) = ISn2 + IZ2;
Dm(2, 2) = ICn2 + IZ2;
Dm(3, 3) = IR2 * (Teta2 - Teta1);
Dm(1, 2) = Dm(2, 1) = -ICnSn;
Dm(1, 3) = Dm(3, 1) = -ICnz;
Dm(3, 2) = Dm(2, 3) = -ISnz;
math_Matrix Passage (1,3,1,3);
Passage(1,1) = Xa1; Passage(1,2) = Xa2 ;Passage(1,3) = Xa3;
Passage(2,1) = Ya1; Passage(2,2) = Ya2 ;Passage(2,3) = Ya3;
Passage(3,1) = Za1; Passage(3,2) = Za2 ;Passage(3,3) = Za3;
math_Matrix Passage(1, 3, 1, 3);
Passage(1, 1) = Xa1;
Passage(1, 2) = Xa2;
Passage(1, 3) = Xa3;
Passage(2, 1) = Ya1;
Passage(2, 2) = Ya2;
Passage(2, 3) = Ya3;
Passage(3, 1) = Za1;
Passage(3, 2) = Za2;
Passage(3, 3) = Za3;
math_Jacobi J(Dm);
RMax = RMax*Rmin;
math_Vector V1(1,3), V2(1,3), V3(1,3);
J.Vector(1,V1);
V1.Multiply(Passage,V1);
V1.Multiply(RMax*J.Value(1));
J.Vector(2,V2);
V2.Multiply(Passage,V2);
V2.Multiply(RMax*J.Value(2));
J.Vector(3,V3);
V3.Multiply(Passage,V3);
V3.Multiply(RMax*J.Value(3));
RMax = RMax * Rmin;
math_Vector V1(1, 3), V2(1, 3), V3(1, 3);
J.Vector(1, V1);
V1.Multiply(Passage, V1);
V1.Multiply(RMax * J.Value(1));
J.Vector(2, V2);
V2.Multiply(Passage, V2);
V2.Multiply(RMax * J.Value(2));
J.Vector(3, V3);
V3.Multiply(Passage, V3);
V3.Multiply(RMax * J.Value(3));
inertia = gp_Mat (gp_XYZ(V1(1),V2(1),V3(1)),
gp_XYZ(V1(2),V2(2),V3(2)),
gp_XYZ(V1(3),V2(3),V3(3)));
inertia =
gp_Mat(gp_XYZ(V1(1), V2(1), V3(1)), gp_XYZ(V1(2), V2(2), V3(2)), gp_XYZ(V1(3), V2(3), V3(3)));
gp_Mat Hop;
GProp::HOperator(g,loc,dim,Hop);
inertia = inertia+Hop;
GProp::HOperator(g, loc, dim, Hop);
inertia = inertia + Hop;
}
GProp_SelGProps::GProp_SelGProps (const gp_Cone& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2,
const gp_Pnt& SLocation )
GProp_SelGProps::GProp_SelGProps(const gp_Cone& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2,
const gp_Pnt& SLocation)
{
SetLocation(SLocation);
Perform(S,Alpha1,Alpha2,Z1,Z2);
Perform(S, Alpha1, Alpha2, Z1, Z2);
}
GProp_SelGProps::GProp_SelGProps (const gp_Cylinder& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2,
const gp_Pnt& SLocation)
{
GProp_SelGProps::GProp_SelGProps(const gp_Cylinder& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2,
const gp_Pnt& SLocation)
{
SetLocation(SLocation);
Perform(S,Alpha1,Alpha2,Z1,Z2);
Perform(S, Alpha1, Alpha2, Z1, Z2);
}
GProp_SelGProps::GProp_SelGProps (const gp_Sphere& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const gp_Pnt& SLocation)
{
GProp_SelGProps::GProp_SelGProps(const gp_Sphere& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const gp_Pnt& SLocation)
{
SetLocation(SLocation);
Perform(S,Teta1,Teta2,Alpha1,Alpha2);
Perform(S, Teta1, Teta2, Alpha1, Alpha2);
}
GProp_SelGProps::GProp_SelGProps (const gp_Torus& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const gp_Pnt& SLocation)
{
GProp_SelGProps::GProp_SelGProps(const gp_Torus& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const gp_Pnt& SLocation)
{
SetLocation(SLocation);
Perform(S,Teta1,Teta2,Alpha1,Alpha2);
Perform(S, Teta1, Teta2, Alpha1, Alpha2);
}

View File

@@ -27,58 +27,71 @@ class gp_Cone;
class gp_Sphere;
class gp_Torus;
//! Computes the global properties of a bounded
//! elementary surface in 3d (surface of the gp package)
class GProp_SelGProps : public GProp_GProps
class GProp_SelGProps : public GProp_GProps
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT GProp_SelGProps();
Standard_EXPORT GProp_SelGProps(const gp_Cylinder& S, const Standard_Real Alpha1, const Standard_Real Alpha2, const Standard_Real Z1, const Standard_Real Z2, const gp_Pnt& SLocation);
Standard_EXPORT GProp_SelGProps(const gp_Cone& S, const Standard_Real Alpha1, const Standard_Real Alpha2, const Standard_Real Z1, const Standard_Real Z2, const gp_Pnt& SLocation);
Standard_EXPORT GProp_SelGProps(const gp_Sphere& S, const Standard_Real Teta1, const Standard_Real Teta2, const Standard_Real Alpha1, const Standard_Real Alpha2, const gp_Pnt& SLocation);
Standard_EXPORT GProp_SelGProps(const gp_Torus& S, const Standard_Real Teta1, const Standard_Real Teta2, const Standard_Real Alpha1, const Standard_Real Alpha2, const gp_Pnt& SLocation);
Standard_EXPORT void SetLocation (const gp_Pnt& SLocation);
Standard_EXPORT void Perform (const gp_Cylinder& S, const Standard_Real Alpha1, const Standard_Real Alpha2, const Standard_Real Z1, const Standard_Real Z2);
Standard_EXPORT void Perform (const gp_Cone& S, const Standard_Real Alpha1, const Standard_Real Alpha2, const Standard_Real Z1, const Standard_Real Z2);
Standard_EXPORT void Perform (const gp_Sphere& S, const Standard_Real Teta1, const Standard_Real Teta2, const Standard_Real Alpha1, const Standard_Real Alpha2);
Standard_EXPORT void Perform (const gp_Torus& S, const Standard_Real Teta1, const Standard_Real Teta2, const Standard_Real Alpha1, const Standard_Real Alpha2);
Standard_EXPORT GProp_SelGProps(const gp_Cylinder& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2,
const gp_Pnt& SLocation);
Standard_EXPORT GProp_SelGProps(const gp_Cone& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2,
const gp_Pnt& SLocation);
Standard_EXPORT GProp_SelGProps(const gp_Sphere& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const gp_Pnt& SLocation);
Standard_EXPORT GProp_SelGProps(const gp_Torus& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const gp_Pnt& SLocation);
Standard_EXPORT void SetLocation(const gp_Pnt& SLocation);
Standard_EXPORT void Perform(const gp_Cylinder& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2);
Standard_EXPORT void Perform(const gp_Cone& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2);
Standard_EXPORT void Perform(const gp_Sphere& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2);
Standard_EXPORT void Perform(const gp_Torus& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2);
protected:
private:
};
#endif // _GProp_SelGProps_HeaderFile

View File

@@ -28,8 +28,9 @@ class GProp_UndefinedAxis;
DEFINE_STANDARD_HANDLE(GProp_UndefinedAxis, Standard_DomainError)
#if !defined No_Exception && !defined No_GProp_UndefinedAxis
#define GProp_UndefinedAxis_Raise_if(CONDITION, MESSAGE) \
if (CONDITION) throw GProp_UndefinedAxis(MESSAGE);
#define GProp_UndefinedAxis_Raise_if(CONDITION, MESSAGE) \
if (CONDITION) \
throw GProp_UndefinedAxis(MESSAGE);
#else
#define GProp_UndefinedAxis_Raise_if(CONDITION, MESSAGE)
#endif

View File

@@ -20,17 +20,17 @@
//! Algorithms:
enum GProp_ValueType
{
GProp_Mass,
GProp_CenterMassX,
GProp_CenterMassY,
GProp_CenterMassZ,
GProp_InertiaXX,
GProp_InertiaYY,
GProp_InertiaZZ,
GProp_InertiaXY,
GProp_InertiaXZ,
GProp_InertiaYZ,
GProp_Unknown
GProp_Mass,
GProp_CenterMassX,
GProp_CenterMassY,
GProp_CenterMassZ,
GProp_InertiaXX,
GProp_InertiaYY,
GProp_InertiaZZ,
GProp_InertiaXY,
GProp_InertiaXZ,
GProp_InertiaYZ,
GProp_Unknown
};
#endif // _GProp_ValueType_HeaderFile

View File

@@ -12,7 +12,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <gp_Cone.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Pnt.hxx>
@@ -24,218 +23,224 @@
#include <math_Matrix.hxx>
#include <math_Vector.hxx>
GProp_VelGProps::GProp_VelGProps(){}
GProp_VelGProps::GProp_VelGProps() {}
void GProp_VelGProps::SetLocation(const gp_Pnt& VLocation)
{
loc =VLocation;
loc = VLocation;
}
GProp_VelGProps::GProp_VelGProps(const gp_Cylinder& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2,
const gp_Pnt& VLocation)
GProp_VelGProps::GProp_VelGProps(const gp_Cylinder& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2,
const gp_Pnt& VLocation)
{
SetLocation(VLocation);
Perform(S,Alpha1,Alpha2,Z1,Z2);
Perform(S, Alpha1, Alpha2, Z1, Z2);
}
GProp_VelGProps::GProp_VelGProps(const gp_Cone& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2,
const gp_Pnt& VLocation)
GProp_VelGProps::GProp_VelGProps(const gp_Cone& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2,
const gp_Pnt& VLocation)
{
SetLocation(VLocation);
Perform(S,Alpha1,Alpha2,Z1,Z2);
Perform(S, Alpha1, Alpha2, Z1, Z2);
}
GProp_VelGProps::GProp_VelGProps(const gp_Sphere& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const gp_Pnt& VLocation)
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const gp_Pnt& VLocation)
{
SetLocation(VLocation);
Perform(S,Teta1,Teta2,Alpha1,Alpha2);
Perform(S, Teta1, Teta2, Alpha1, Alpha2);
}
GProp_VelGProps::GProp_VelGProps(const gp_Torus& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const gp_Pnt& VLocation)
GProp_VelGProps::GProp_VelGProps(const gp_Torus& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const gp_Pnt& VLocation)
{
SetLocation(VLocation);
Perform(S,Teta1,Teta2,Alpha1,Alpha2);
Perform(S, Teta1, Teta2, Alpha1, Alpha2);
}
void GProp_VelGProps::Perform(const gp_Cylinder& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2)
void GProp_VelGProps::Perform(const gp_Cylinder& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2)
{
Standard_Real X0,Y0,Z0,Xa1,Ya1,Za1,Xa2,Ya2,Za2,Xa3,Ya3,Za3;
S.Location().Coord(X0,Y0,Z0);
Standard_Real X0, Y0, Z0, Xa1, Ya1, Za1, Xa2, Ya2, Za2, Xa3, Ya3, Za3;
S.Location().Coord(X0, Y0, Z0);
Standard_Real Rayon = S.Radius();
S.Position().XDirection().Coord(Xa1,Ya1,Za1);
S.Position().YDirection().Coord(Xa2,Ya2,Za2);
S.Position().Direction().Coord(Xa3,Ya3,Za3);
dim = Rayon*Rayon*(Z2-Z1)/2.;
Standard_Real SA2 = Sin(Alpha2);
Standard_Real SA1 = Sin(Alpha1);
Standard_Real CA2 = Cos(Alpha2);
Standard_Real CA1 = Cos(Alpha1);
Standard_Real Dsin = SA2-SA1;
Standard_Real Dcos = CA1-CA2;
Standard_Real Coef = Rayon/(Alpha2-Alpha1);
S.Position().XDirection().Coord(Xa1, Ya1, Za1);
S.Position().YDirection().Coord(Xa2, Ya2, Za2);
S.Position().Direction().Coord(Xa3, Ya3, Za3);
dim = Rayon * Rayon * (Z2 - Z1) / 2.;
Standard_Real SA2 = Sin(Alpha2);
Standard_Real SA1 = Sin(Alpha1);
Standard_Real CA2 = Cos(Alpha2);
Standard_Real CA1 = Cos(Alpha1);
Standard_Real Dsin = SA2 - SA1;
Standard_Real Dcos = CA1 - CA2;
Standard_Real Coef = Rayon / (Alpha2 - Alpha1);
g.SetCoord(X0+(Coef*(Xa1*Dsin+Xa2*Dcos) ) + (Xa3*(Z2+Z1)/2.),
Y0+(Coef*(Ya1*Dsin+Ya2*Dcos) ) + (Ya3*(Z2+Z1)/2.),
Z0+(Coef*(Za1*Dsin+Za2*Dcos) ) + (Za3*(Z2+Z1)/2.) );
Standard_Real ICn2 = dim/2. *( Alpha2-Alpha1 + SA2*CA2 - SA1*CA1 );
Standard_Real ISn2 = dim/2. *( Alpha2-Alpha1 - SA2*CA2 + SA1*CA1 );
Standard_Real IZ2 = dim * (Alpha2-Alpha1)*(Z2*Z2+Z1*Z2+Z1*Z1);
Standard_Real ICnSn = dim *(CA2*CA2-CA1*CA1)/2.;
Standard_Real ICnz = dim *(Z2+Z1)/2.*Dsin;
Standard_Real ISnz = dim *(Z2+Z1)/2.*Dcos;
dim =(Alpha2-Alpha1)*dim;
g.SetCoord(X0 + (Coef * (Xa1 * Dsin + Xa2 * Dcos)) + (Xa3 * (Z2 + Z1) / 2.),
Y0 + (Coef * (Ya1 * Dsin + Ya2 * Dcos)) + (Ya3 * (Z2 + Z1) / 2.),
Z0 + (Coef * (Za1 * Dsin + Za2 * Dcos)) + (Za3 * (Z2 + Z1) / 2.));
math_Matrix Dm(1,3,1,3);
Standard_Real ICn2 = dim / 2. * (Alpha2 - Alpha1 + SA2 * CA2 - SA1 * CA1);
Standard_Real ISn2 = dim / 2. * (Alpha2 - Alpha1 - SA2 * CA2 + SA1 * CA1);
Standard_Real IZ2 = dim * (Alpha2 - Alpha1) * (Z2 * Z2 + Z1 * Z2 + Z1 * Z1);
Standard_Real ICnSn = dim * (CA2 * CA2 - CA1 * CA1) / 2.;
Standard_Real ICnz = dim * (Z2 + Z1) / 2. * Dsin;
Standard_Real ISnz = dim * (Z2 + Z1) / 2. * Dcos;
dim = (Alpha2 - Alpha1) * dim;
Dm(1,1) = Rayon*Rayon*ISn2 + IZ2;
Dm(2,2) = Rayon*Rayon*ICn2 + IZ2;
Dm(3,3) = Rayon*Rayon*dim;
Dm(1,2) = Dm(2,1) = -Rayon*Rayon*ICnSn;
Dm(1,3) = Dm(3,1) = -Rayon*ICnz;
Dm(3,2) = Dm(2,3) = -Rayon*ISnz;
math_Matrix Dm(1, 3, 1, 3);
math_Matrix Passage (1,3,1,3);
Passage(1,1) = Xa1; Passage(1,2) = Xa2 ;Passage(1,3) = Xa3;
Passage(2,1) = Ya1; Passage(2,2) = Ya2 ;Passage(2,3) = Ya3;
Passage(3,1) = Za1; Passage(3,2) = Za2 ;Passage(3,3) = Za3;
Dm(1, 1) = Rayon * Rayon * ISn2 + IZ2;
Dm(2, 2) = Rayon * Rayon * ICn2 + IZ2;
Dm(3, 3) = Rayon * Rayon * dim;
Dm(1, 2) = Dm(2, 1) = -Rayon * Rayon * ICnSn;
Dm(1, 3) = Dm(3, 1) = -Rayon * ICnz;
Dm(3, 2) = Dm(2, 3) = -Rayon * ISnz;
math_Matrix Passage(1, 3, 1, 3);
Passage(1, 1) = Xa1;
Passage(1, 2) = Xa2;
Passage(1, 3) = Xa3;
Passage(2, 1) = Ya1;
Passage(2, 2) = Ya2;
Passage(2, 3) = Ya3;
Passage(3, 1) = Za1;
Passage(3, 2) = Za2;
Passage(3, 3) = Za3;
math_Jacobi J(Dm);
math_Vector V1(1,3),V2(1,3),V3(1,3);
J.Vector(1,V1);
V1.Multiply(Passage,V1);
math_Vector V1(1, 3), V2(1, 3), V3(1, 3);
J.Vector(1, V1);
V1.Multiply(Passage, V1);
V1.Multiply(J.Value(1));
J.Vector(2,V2);
V2.Multiply(Passage,V2);
J.Vector(2, V2);
V2.Multiply(Passage, V2);
V2.Multiply(J.Value(2));
J.Vector(3,V3);
V3.Multiply(Passage,V3);
J.Vector(3, V3);
V3.Multiply(Passage, V3);
V3.Multiply(J.Value(3));
inertia = gp_Mat (gp_XYZ(V1(1),V2(1),V3(1)),
gp_XYZ(V1(2),V2(2),V3(2)),
gp_XYZ(V1(3),V2(3),V3(3)));
inertia =
gp_Mat(gp_XYZ(V1(1), V2(1), V3(1)), gp_XYZ(V1(2), V2(2), V3(2)), gp_XYZ(V1(3), V2(3), V3(3)));
gp_Mat Hop;
GProp::HOperator(g,loc,dim,Hop);
inertia = inertia+Hop;
GProp::HOperator(g, loc, dim, Hop);
inertia = inertia + Hop;
}
void GProp_VelGProps::Perform(const gp_Cone& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2)
void GProp_VelGProps::Perform(const gp_Cone& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2)
{
Standard_Real X0,Y0,Z0,Xa1,Ya1,Za1,Xa2,Ya2,Za2,Xa3,Ya3,Za3;
S.Location().Coord(X0,Y0,Z0);
S.Position().XDirection().Coord(Xa1,Ya1,Za1);
S.Position().YDirection().Coord(Xa2,Ya2,Za2);
S.Position().Direction().Coord(Xa3,Ya3,Za3);
Standard_Real t =S.SemiAngle();
Standard_Real Cnt = Cos(t);
Standard_Real Snt = Sin(t);
Standard_Real R = S.RefRadius();
Standard_Real Sn2 = Sin(Alpha2);
Standard_Real Sn1 = Sin(Alpha1);
Standard_Real Cn2 = Cos(Alpha2);
Standard_Real Cn1 = Cos(Alpha1);
Standard_Real ZZ = (Z2-Z1)*(Z2-Z1)*Cnt*Snt;
Standard_Real Auxi1= 2*R +(Z2+Z1)*Snt;
Standard_Real X0, Y0, Z0, Xa1, Ya1, Za1, Xa2, Ya2, Za2, Xa3, Ya3, Za3;
S.Location().Coord(X0, Y0, Z0);
S.Position().XDirection().Coord(Xa1, Ya1, Za1);
S.Position().YDirection().Coord(Xa2, Ya2, Za2);
S.Position().Direction().Coord(Xa3, Ya3, Za3);
Standard_Real t = S.SemiAngle();
Standard_Real Cnt = Cos(t);
Standard_Real Snt = Sin(t);
Standard_Real R = S.RefRadius();
Standard_Real Sn2 = Sin(Alpha2);
Standard_Real Sn1 = Sin(Alpha1);
Standard_Real Cn2 = Cos(Alpha2);
Standard_Real Cn1 = Cos(Alpha1);
Standard_Real ZZ = (Z2 - Z1) * (Z2 - Z1) * Cnt * Snt;
Standard_Real Auxi1 = 2 * R + (Z2 + Z1) * Snt;
dim = ZZ*(Alpha2-Alpha1)*Auxi1/2.;
dim = ZZ * (Alpha2 - Alpha1) * Auxi1 / 2.;
Standard_Real R1 = R + Z1*Snt;
Standard_Real R2 = R + Z2*Snt;
Standard_Real Coef0 = (R1*R1+R1*R2+R2*R2);
Standard_Real Iz = Cnt*(R*(Z2+Z1) + 2*Snt*(Z1*Z1+Z1*Z2+Z2*Z2)/3.)/Auxi1;
Standard_Real Ix = Coef0*(Sn2-Sn1)/(Alpha2-Alpha1)/Auxi1;
Standard_Real Iy = Coef0*(Cn1-Cn2)/(Alpha2-Alpha1)/Auxi1;
Standard_Real R1 = R + Z1 * Snt;
Standard_Real R2 = R + Z2 * Snt;
Standard_Real Coef0 = (R1 * R1 + R1 * R2 + R2 * R2);
Standard_Real Iz = Cnt * (R * (Z2 + Z1) + 2 * Snt * (Z1 * Z1 + Z1 * Z2 + Z2 * Z2) / 3.) / Auxi1;
Standard_Real Ix = Coef0 * (Sn2 - Sn1) / (Alpha2 - Alpha1) / Auxi1;
Standard_Real Iy = Coef0 * (Cn1 - Cn2) / (Alpha2 - Alpha1) / Auxi1;
g.SetCoord(X0 + Xa1*Ix + Xa2*Iy + Xa3*Iz,
Y0 + Ya1*Ix + Ya2*Iy + Ya3*Iz,
Z0 + Za1*Ix + Za2*Iy + Za3*Iz);
g.SetCoord(X0 + Xa1 * Ix + Xa2 * Iy + Xa3 * Iz,
Y0 + Ya1 * Ix + Ya2 * Iy + Ya3 * Iz,
Z0 + Za1 * Ix + Za2 * Iy + Za3 * Iz);
Standard_Real IR2 = ZZ*(R2*R2*R2+R2*R2*R1+R1*R1*R2+R1*R1*R1)/4.;
Standard_Real ICn2 = IR2*(Alpha2-Alpha1+Cn2*Sn2-Cn1*Sn1)/2.;
Standard_Real ISn2 = IR2*(Alpha2-Alpha1+Cn2*Sn2-Cn1*Sn1)/2.;
Standard_Real IZ2 = ZZ*Cnt*Cnt*(Alpha2-Alpha1)*
(Z1*Z1*(R/3 + Z1*Snt/4) +
Z2*Z2*(R/3 + Z2*Snt/4) +
Z1*Z2*(R/3 +Z1*Snt/4 +Z2*Snt/4));
Standard_Real ICnSn = IR2*(Cn2*Cn2-Cn1*Cn1);
Standard_Real ICnz = (Z1+Z2)*ZZ*Coef0*(Sn2-Sn1)/3;
Standard_Real ISnz = (Z1+Z2)*ZZ*Coef0*(Cn1-Cn2)/3;
Standard_Real IR2 = ZZ * (R2 * R2 * R2 + R2 * R2 * R1 + R1 * R1 * R2 + R1 * R1 * R1) / 4.;
Standard_Real ICn2 = IR2 * (Alpha2 - Alpha1 + Cn2 * Sn2 - Cn1 * Sn1) / 2.;
Standard_Real ISn2 = IR2 * (Alpha2 - Alpha1 + Cn2 * Sn2 - Cn1 * Sn1) / 2.;
Standard_Real IZ2 = ZZ * Cnt * Cnt * (Alpha2 - Alpha1)
* (Z1 * Z1 * (R / 3 + Z1 * Snt / 4) + Z2 * Z2 * (R / 3 + Z2 * Snt / 4)
+ Z1 * Z2 * (R / 3 + Z1 * Snt / 4 + Z2 * Snt / 4));
Standard_Real ICnSn = IR2 * (Cn2 * Cn2 - Cn1 * Cn1);
Standard_Real ICnz = (Z1 + Z2) * ZZ * Coef0 * (Sn2 - Sn1) / 3;
Standard_Real ISnz = (Z1 + Z2) * ZZ * Coef0 * (Cn1 - Cn2) / 3;
math_Matrix Dm(1,3,1,3);
Dm(1,1) = ISn2 + IZ2;
Dm(2,2) = ICn2 + IZ2;
Dm(3,3) = IR2*(Alpha2-Alpha1);
Dm(1,2) = Dm(2,1) = -ICnSn;
Dm(1,3) = Dm(3,1) = -ICnz;
Dm(3,2) = Dm(2,3) = -ISnz;
math_Matrix Dm(1, 3, 1, 3);
Dm(1, 1) = ISn2 + IZ2;
Dm(2, 2) = ICn2 + IZ2;
Dm(3, 3) = IR2 * (Alpha2 - Alpha1);
Dm(1, 2) = Dm(2, 1) = -ICnSn;
Dm(1, 3) = Dm(3, 1) = -ICnz;
Dm(3, 2) = Dm(2, 3) = -ISnz;
math_Matrix Passage (1,3,1,3);
Passage(1,1) = Xa1; Passage(1,2) = Xa2 ;Passage(1,3) = Xa3;
Passage(2,1) = Ya1; Passage(2,2) = Ya2 ;Passage(2,3) = Ya3;
Passage(3,1) = Za1; Passage(3,2) = Za2 ;Passage(3,3) = Za3;
math_Matrix Passage(1, 3, 1, 3);
Passage(1, 1) = Xa1;
Passage(1, 2) = Xa2;
Passage(1, 3) = Xa3;
Passage(2, 1) = Ya1;
Passage(2, 2) = Ya2;
Passage(2, 3) = Ya3;
Passage(3, 1) = Za1;
Passage(3, 2) = Za2;
Passage(3, 3) = Za3;
math_Jacobi J(Dm);
math_Vector V1(1,3),V2(1,3),V3(1,3);
J.Vector(1,V1);
V1.Multiply(Passage,V1);
math_Vector V1(1, 3), V2(1, 3), V3(1, 3);
J.Vector(1, V1);
V1.Multiply(Passage, V1);
V1.Multiply(J.Value(1));
J.Vector(2,V2);
V2.Multiply(Passage,V2);
J.Vector(2, V2);
V2.Multiply(Passage, V2);
V2.Multiply(J.Value(2));
J.Vector(3,V3);
V3.Multiply(Passage,V3);
J.Vector(3, V3);
V3.Multiply(Passage, V3);
V3.Multiply(J.Value(3));
inertia = gp_Mat (gp_XYZ(V1(1),V2(1),V3(1)),
gp_XYZ(V1(2),V2(2),V3(2)),
gp_XYZ(V1(3),V2(3),V3(3)));
inertia =
gp_Mat(gp_XYZ(V1(1), V2(1), V3(1)), gp_XYZ(V1(2), V2(2), V3(2)), gp_XYZ(V1(3), V2(3), V3(3)));
gp_Mat Hop;
GProp::HOperator(g,loc,dim,Hop);
inertia = inertia+Hop;
GProp::HOperator(g, loc, dim, Hop);
inertia = inertia + Hop;
}
void GProp_VelGProps::Perform(const gp_Sphere& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2)
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2)
{
Standard_Real X0,Y0,Z0,Xa1,Ya1,Za1,Xa2,Ya2,Za2,Xa3,Ya3,Za3;
S.Location().Coord(X0,Y0,Z0);
S.Position().XDirection().Coord(Xa1,Ya1,Za1);
S.Position().YDirection().Coord(Xa2,Ya2,Za2);
S.Position().Direction().Coord(Xa3,Ya3,Za3);
Standard_Real R = S.Radius();
Standard_Real X0, Y0, Z0, Xa1, Ya1, Za1, Xa2, Ya2, Za2, Xa3, Ya3, Za3;
S.Location().Coord(X0, Y0, Z0);
S.Position().XDirection().Coord(Xa1, Ya1, Za1);
S.Position().YDirection().Coord(Xa2, Ya2, Za2);
S.Position().Direction().Coord(Xa3, Ya3, Za3);
Standard_Real R = S.Radius();
Standard_Real Cnt1 = Cos(Teta1);
Standard_Real Snt1 = Sin(Teta1);
Standard_Real Cnt2 = Cos(Teta2);
@@ -244,77 +249,77 @@ void GProp_VelGProps::Perform(const gp_Sphere& S,
Standard_Real Snf1 = Sin(Alpha1);
Standard_Real Cnf2 = Cos(Alpha2);
Standard_Real Snf2 = Sin(Alpha2);
dim = (Teta2-Teta1)*R*R*R*(Snf2-Snf1)/3.;
Standard_Real Ix =
R*(Snt2-Snt1)/(Teta2-Teta1)*
(Alpha2-Alpha1+Snf2*Cnf2-Snf1*Cnf1)/(Snf2-Snf1)/2.;
Standard_Real Iy =
R*(Cnt1-Cnt2)/(Teta2-Teta1)*
(Alpha2-Alpha1+Snf2*Cnf2-Snf1*Cnf1)/(Snf2-Snf1)/2.;
Standard_Real Iz = R*(Snf2+Snf1)/2.;
g.SetCoord(
X0 + Ix*Xa1 + Iy*Xa2 + Iz*Xa3,
Y0 + Ix*Ya1 + Iy*Ya2 + Iz*Ya3,
Z0 + Ix*Za1 + Iy*Za2 + Iz*Za3);
dim = (Teta2 - Teta1) * R * R * R * (Snf2 - Snf1) / 3.;
Standard_Real IR2 = ( Cnf2*Snf2*(Cnf2+1.)- Cnf1*Snf1*(Cnf1+1.) +
Alpha2-Alpha1 )/9.;
Standard_Real ICn2 = (Teta2-Teta1+ Cnt2*Snt2-Cnt1*Snt1)*IR2/2.;
Standard_Real ISn2 = (Teta2-Teta1-Cnt2*Snt2+Cnt1*Snt1)*IR2/2.;
Standard_Real ICnSn = ( Snt2*Snt2-Snt1*Snt1)*IR2/2.;
Standard_Real IZ2 = (Teta2-Teta1)*(Snf2*Snf2*Snf2-Snf1*Snf1*Snf1)/9.;
Standard_Real ICnz =(Snt2-Snt1)*(Cnf1*Cnf1*Cnf1-Cnf2*Cnf2*Cnf2)/9.;
Standard_Real ISnz =(Cnt1-Cnt2)*(Cnf1*Cnf1*Cnf1-Cnf2*Cnf2*Cnf2)/9.;
Standard_Real Ix = R * (Snt2 - Snt1) / (Teta2 - Teta1)
* (Alpha2 - Alpha1 + Snf2 * Cnf2 - Snf1 * Cnf1) / (Snf2 - Snf1) / 2.;
Standard_Real Iy = R * (Cnt1 - Cnt2) / (Teta2 - Teta1)
* (Alpha2 - Alpha1 + Snf2 * Cnf2 - Snf1 * Cnf1) / (Snf2 - Snf1) / 2.;
Standard_Real Iz = R * (Snf2 + Snf1) / 2.;
g.SetCoord(X0 + Ix * Xa1 + Iy * Xa2 + Iz * Xa3,
Y0 + Ix * Ya1 + Iy * Ya2 + Iz * Ya3,
Z0 + Ix * Za1 + Iy * Za2 + Iz * Za3);
math_Matrix Dm(1,3,1,3);
Dm(1,1) = ISn2 +IZ2;
Dm(2,2) = ICn2 +IZ2;
Dm(3,3) = IR2*(Teta2-Teta1);
Dm(1,2) = Dm(2,1) = -ICnSn;
Dm(1,3) = Dm(3,1) = -ICnz;
Dm(3,2) = Dm(2,3) = -ISnz;
Standard_Real IR2 =
(Cnf2 * Snf2 * (Cnf2 + 1.) - Cnf1 * Snf1 * (Cnf1 + 1.) + Alpha2 - Alpha1) / 9.;
Standard_Real ICn2 = (Teta2 - Teta1 + Cnt2 * Snt2 - Cnt1 * Snt1) * IR2 / 2.;
Standard_Real ISn2 = (Teta2 - Teta1 - Cnt2 * Snt2 + Cnt1 * Snt1) * IR2 / 2.;
Standard_Real ICnSn = (Snt2 * Snt2 - Snt1 * Snt1) * IR2 / 2.;
Standard_Real IZ2 = (Teta2 - Teta1) * (Snf2 * Snf2 * Snf2 - Snf1 * Snf1 * Snf1) / 9.;
Standard_Real ICnz = (Snt2 - Snt1) * (Cnf1 * Cnf1 * Cnf1 - Cnf2 * Cnf2 * Cnf2) / 9.;
Standard_Real ISnz = (Cnt1 - Cnt2) * (Cnf1 * Cnf1 * Cnf1 - Cnf2 * Cnf2 * Cnf2) / 9.;
math_Matrix Passage (1,3,1,3);
Passage(1,1) = Xa1; Passage(1,2) = Xa2 ;Passage(1,3) = Xa3;
Passage(2,1) = Ya1; Passage(2,2) = Ya2 ;Passage(2,3) = Ya3;
Passage(3,1) = Za1; Passage(3,2) = Za2 ;Passage(3,3) = Za3;
math_Matrix Dm(1, 3, 1, 3);
Dm(1, 1) = ISn2 + IZ2;
Dm(2, 2) = ICn2 + IZ2;
Dm(3, 3) = IR2 * (Teta2 - Teta1);
Dm(1, 2) = Dm(2, 1) = -ICnSn;
Dm(1, 3) = Dm(3, 1) = -ICnz;
Dm(3, 2) = Dm(2, 3) = -ISnz;
math_Matrix Passage(1, 3, 1, 3);
Passage(1, 1) = Xa1;
Passage(1, 2) = Xa2;
Passage(1, 3) = Xa3;
Passage(2, 1) = Ya1;
Passage(2, 2) = Ya2;
Passage(2, 3) = Ya3;
Passage(3, 1) = Za1;
Passage(3, 2) = Za2;
Passage(3, 3) = Za3;
math_Jacobi J(Dm);
R = R*R*R*R*R;
math_Vector V1(1,3), V2(1,3), V3(1,3);
J.Vector(1,V1);
V1.Multiply(Passage,V1);
V1.Multiply(R*J.Value(1));
J.Vector(2,V2);
V2.Multiply(Passage,V2);
V2.Multiply(R*J.Value(2));
J.Vector(3,V3);
V3.Multiply(Passage,V3);
V3.Multiply(R*J.Value(3));
R = R * R * R * R * R;
math_Vector V1(1, 3), V2(1, 3), V3(1, 3);
J.Vector(1, V1);
V1.Multiply(Passage, V1);
V1.Multiply(R * J.Value(1));
J.Vector(2, V2);
V2.Multiply(Passage, V2);
V2.Multiply(R * J.Value(2));
J.Vector(3, V3);
V3.Multiply(Passage, V3);
V3.Multiply(R * J.Value(3));
inertia = gp_Mat (gp_XYZ(V1(1),V2(1),V3(1)),
gp_XYZ(V1(2),V2(2),V3(2)),
gp_XYZ(V1(3),V2(3),V3(3)));
inertia =
gp_Mat(gp_XYZ(V1(1), V2(1), V3(1)), gp_XYZ(V1(2), V2(2), V3(2)), gp_XYZ(V1(3), V2(3), V3(3)));
gp_Mat Hop;
GProp::HOperator(g,loc,dim,Hop);
inertia = inertia+Hop;
GProp::HOperator(g, loc, dim, Hop);
inertia = inertia + Hop;
}
void GProp_VelGProps::Perform(const gp_Torus& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2)
void GProp_VelGProps::Perform(const gp_Torus& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2)
{
Standard_Real X0,Y0,Z0,Xa1,Ya1,Za1,Xa2,Ya2,Za2,Xa3,Ya3,Za3;
S.Location().Coord(X0,Y0,Z0);
S.Position().XDirection().Coord(Xa1,Ya1,Za1);
S.Position().YDirection().Coord(Xa2,Ya2,Za2);
S.Position().Direction().Coord(Xa3,Ya3,Za3);
Standard_Real X0, Y0, Z0, Xa1, Ya1, Za1, Xa2, Ya2, Za2, Xa3, Ya3, Za3;
S.Location().Coord(X0, Y0, Z0);
S.Position().XDirection().Coord(Xa1, Ya1, Za1);
S.Position().YDirection().Coord(Xa2, Ya2, Za2);
S.Position().Direction().Coord(Xa3, Ya3, Za3);
Standard_Real RMax = S.MajorRadius();
Standard_Real Rmin = S.MinorRadius();
Standard_Real Cnt1 = Cos(Teta1);
@@ -326,61 +331,62 @@ void GProp_VelGProps::Perform(const gp_Torus& S,
Standard_Real Cnf2 = Cos(Alpha2);
Standard_Real Snf2 = Sin(Alpha2);
dim = RMax*Rmin*Rmin*(Teta2-Teta1)*(Alpha2-Alpha1)/2.;
Standard_Real Ix =
(Snt2-Snt1)/(Teta2-Teta1)*(Rmin*(Snf2-Snf1)/(Alpha2-Alpha1) + RMax);
Standard_Real Iy =
(Cnt1-Cnt2)/(Teta2-Teta1)*(Rmin*(Snf2-Snf1)/(Alpha2-Alpha1) + RMax);
Standard_Real Iz = Rmin*(Cnf1-Cnf2)/(Alpha2-Alpha1);
g.SetCoord(
X0+Ix*Xa1+Iy*Xa2+Iz*Xa3,
Y0+Ix*Ya1+Iy*Ya2+Iz*Ya3,
Z0+Ix*Za1+Iy*Za2+Iz*Za3);
dim = RMax * Rmin * Rmin * (Teta2 - Teta1) * (Alpha2 - Alpha1) / 2.;
Standard_Real Ix =
(Snt2 - Snt1) / (Teta2 - Teta1) * (Rmin * (Snf2 - Snf1) / (Alpha2 - Alpha1) + RMax);
Standard_Real Iy =
(Cnt1 - Cnt2) / (Teta2 - Teta1) * (Rmin * (Snf2 - Snf1) / (Alpha2 - Alpha1) + RMax);
Standard_Real Iz = Rmin * (Cnf1 - Cnf2) / (Alpha2 - Alpha1);
Standard_Real IR2 = RMax*RMax+Rmin*Rmin/2. +2.*RMax*Rmin*(Snf2-Snf1) +
Rmin*Rmin/2.*(Snf2*Cnf2-Snf1*Cnf1);
Standard_Real ICn2 = IR2*(Teta2-Teta1 +Snt2*Cnt2-Snt1*Cnt1)/2.;
Standard_Real ISn2 = IR2*(Teta2-Teta1 -Snt2*Cnt2+Snt1*Cnt1)/2.;
Standard_Real ICnSn = IR2*(Snt2*Snt2-Snt1*Snt1)/2.;
Standard_Real IZ2 =
(Teta2-Teta1)*Rmin*Rmin*(Alpha2-Alpha1-Snf2*Cnf2+Snf1*Cnf1)/2.;
Standard_Real ICnz = Rmin*(Snt2-Snt1)*(Cnf1-Cnf2)*(RMax+Rmin*(Cnf1+Cnf2)/2.);
Standard_Real ISnz = Rmin*(Cnt2-Cnt1)*(Cnf1-Cnf2)*(RMax+Rmin*(Cnf1+Cnf2)/2.);
g.SetCoord(X0 + Ix * Xa1 + Iy * Xa2 + Iz * Xa3,
Y0 + Ix * Ya1 + Iy * Ya2 + Iz * Ya3,
Z0 + Ix * Za1 + Iy * Za2 + Iz * Za3);
math_Matrix Dm(1,3,1,3);
Dm(1,1) = ISn2 + IZ2;
Dm(2,2) = ICn2 + IZ2;
Dm(3,3) = IR2*(Teta2-Teta1);
Dm(1,2) = Dm(2,1) = -ICnSn;
Dm(1,3) = Dm(3,1) = -ICnz;
Dm(3,2) = Dm(2,3) = -ISnz;
Standard_Real IR2 = RMax * RMax + Rmin * Rmin / 2. + 2. * RMax * Rmin * (Snf2 - Snf1)
+ Rmin * Rmin / 2. * (Snf2 * Cnf2 - Snf1 * Cnf1);
Standard_Real ICn2 = IR2 * (Teta2 - Teta1 + Snt2 * Cnt2 - Snt1 * Cnt1) / 2.;
Standard_Real ISn2 = IR2 * (Teta2 - Teta1 - Snt2 * Cnt2 + Snt1 * Cnt1) / 2.;
Standard_Real ICnSn = IR2 * (Snt2 * Snt2 - Snt1 * Snt1) / 2.;
Standard_Real IZ2 =
(Teta2 - Teta1) * Rmin * Rmin * (Alpha2 - Alpha1 - Snf2 * Cnf2 + Snf1 * Cnf1) / 2.;
Standard_Real ICnz = Rmin * (Snt2 - Snt1) * (Cnf1 - Cnf2) * (RMax + Rmin * (Cnf1 + Cnf2) / 2.);
Standard_Real ISnz = Rmin * (Cnt2 - Cnt1) * (Cnf1 - Cnf2) * (RMax + Rmin * (Cnf1 + Cnf2) / 2.);
math_Matrix Passage (1,3,1,3);
Passage(1,1) = Xa1; Passage(1,2) = Xa2 ;Passage(1,3) = Xa3;
Passage(2,1) = Ya1; Passage(2,2) = Ya2 ;Passage(2,3) = Ya3;
Passage(3,1) = Za1; Passage(3,2) = Za2 ;Passage(3,3) = Za3;
math_Matrix Dm(1, 3, 1, 3);
Dm(1, 1) = ISn2 + IZ2;
Dm(2, 2) = ICn2 + IZ2;
Dm(3, 3) = IR2 * (Teta2 - Teta1);
Dm(1, 2) = Dm(2, 1) = -ICnSn;
Dm(1, 3) = Dm(3, 1) = -ICnz;
Dm(3, 2) = Dm(2, 3) = -ISnz;
math_Matrix Passage(1, 3, 1, 3);
Passage(1, 1) = Xa1;
Passage(1, 2) = Xa2;
Passage(1, 3) = Xa3;
Passage(2, 1) = Ya1;
Passage(2, 2) = Ya2;
Passage(2, 3) = Ya3;
Passage(3, 1) = Za1;
Passage(3, 2) = Za2;
Passage(3, 3) = Za3;
math_Jacobi J(Dm);
RMax = RMax*Rmin*Rmin/2.;
math_Vector V1(1,3), V2(1,3), V3(1,3);
J.Vector(1,V1);
V1.Multiply(Passage,V1);
V1.Multiply(RMax*J.Value(1));
J.Vector(2,V2);
V2.Multiply(Passage,V2);
V2.Multiply(RMax*J.Value(2));
J.Vector(3,V3);
V3.Multiply(Passage,V3);
V3.Multiply(RMax*J.Value(3));
RMax = RMax * Rmin * Rmin / 2.;
math_Vector V1(1, 3), V2(1, 3), V3(1, 3);
J.Vector(1, V1);
V1.Multiply(Passage, V1);
V1.Multiply(RMax * J.Value(1));
J.Vector(2, V2);
V2.Multiply(Passage, V2);
V2.Multiply(RMax * J.Value(2));
J.Vector(3, V3);
V3.Multiply(Passage, V3);
V3.Multiply(RMax * J.Value(3));
inertia = gp_Mat (gp_XYZ(V1(1),V2(1),V3(1)),
gp_XYZ(V1(2),V2(2),V3(2)),
gp_XYZ(V1(3),V2(3),V3(3)));
inertia =
gp_Mat(gp_XYZ(V1(1), V2(1), V3(1)), gp_XYZ(V1(2), V2(2), V3(2)), gp_XYZ(V1(3), V2(3), V3(3)));
gp_Mat Hop;
GProp::HOperator(g,loc,dim,Hop);
inertia = inertia+Hop;
GProp::HOperator(g, loc, dim, Hop);
inertia = inertia + Hop;
}

View File

@@ -27,59 +27,72 @@ class gp_Cone;
class gp_Sphere;
class gp_Torus;
//! Computes the global properties and the volume of a geometric solid
//! (3D closed region of space)
//! The solid can be elementary(definition in the gp package)
class GProp_VelGProps : public GProp_GProps
class GProp_VelGProps : public GProp_GProps
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT GProp_VelGProps();
Standard_EXPORT GProp_VelGProps(const gp_Cylinder& S, const Standard_Real Alpha1, const Standard_Real Alpha2, const Standard_Real Z1, const Standard_Real Z2, const gp_Pnt& VLocation);
Standard_EXPORT GProp_VelGProps(const gp_Cone& S, const Standard_Real Alpha1, const Standard_Real Alpha2, const Standard_Real Z1, const Standard_Real Z2, const gp_Pnt& VLocation);
Standard_EXPORT GProp_VelGProps(const gp_Sphere& S, const Standard_Real Teta1, const Standard_Real Teta2, const Standard_Real Alpha1, const Standard_Real Alpha2, const gp_Pnt& VLocation);
Standard_EXPORT GProp_VelGProps(const gp_Torus& S, const Standard_Real Teta1, const Standard_Real Teta2, const Standard_Real Alpha1, const Standard_Real Alpha2, const gp_Pnt& VLocation);
Standard_EXPORT void SetLocation (const gp_Pnt& VLocation);
Standard_EXPORT void Perform (const gp_Cylinder& S, const Standard_Real Alpha1, const Standard_Real Alpha2, const Standard_Real Z1, const Standard_Real Z2);
Standard_EXPORT void Perform (const gp_Cone& S, const Standard_Real Alpha1, const Standard_Real Alpha2, const Standard_Real Z1, const Standard_Real Z2);
Standard_EXPORT void Perform (const gp_Sphere& S, const Standard_Real Teta1, const Standard_Real Teta2, const Standard_Real Alpha1, const Standard_Real Alpha2);
Standard_EXPORT void Perform (const gp_Torus& S, const Standard_Real Teta1, const Standard_Real Teta2, const Standard_Real Alpha1, const Standard_Real Alpha2);
Standard_EXPORT GProp_VelGProps(const gp_Cylinder& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2,
const gp_Pnt& VLocation);
Standard_EXPORT GProp_VelGProps(const gp_Cone& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2,
const gp_Pnt& VLocation);
Standard_EXPORT GProp_VelGProps(const gp_Sphere& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const gp_Pnt& VLocation);
Standard_EXPORT GProp_VelGProps(const gp_Torus& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const gp_Pnt& VLocation);
Standard_EXPORT void SetLocation(const gp_Pnt& VLocation);
Standard_EXPORT void Perform(const gp_Cylinder& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2);
Standard_EXPORT void Perform(const gp_Cone& S,
const Standard_Real Alpha1,
const Standard_Real Alpha2,
const Standard_Real Z1,
const Standard_Real Z2);
Standard_EXPORT void Perform(const gp_Sphere& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2);
Standard_EXPORT void Perform(const gp_Torus& S,
const Standard_Real Teta1,
const Standard_Real Teta2,
const Standard_Real Alpha1,
const Standard_Real Alpha2);
protected:
private:
};
#endif // _GProp_VelGProps_HeaderFile