1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0026746: Method gp_Torus::Coefficients(...) returns incorrect value.

Bug has been fixed.
Test case for this issue has been created (with corresponding DRAW-command).
This commit is contained in:
nbv 2015-10-09 17:48:36 +03:00 committed by bugmaster
parent 046a1c9dd9
commit 0b4abfb9e2
4 changed files with 271 additions and 175 deletions

View File

@ -4536,6 +4536,110 @@ static Standard_Integer OCC26750( Draw_Interpretor& theDI,
return 0;
}
//=======================================================================
//function : OCC26746
//purpose : Checks if coefficients of the torus are computed properly.
//=======================================================================
#include <Geom_ToroidalSurface.hxx>
static Standard_Integer OCC26746(
Draw_Interpretor& theDI,
Standard_Integer theNArg,
const char ** theArgVal)
{
if(theNArg < 2)
{
theDI << "Use: OCC26746 torus [toler NbCheckedPoints]\n";
return 1;
}
const Handle(Geom_ToroidalSurface) aGtor =
Handle(Geom_ToroidalSurface)::DownCast(DrawTrSurf::GetSurface(theArgVal[1]));
const Standard_Real aToler = (theNArg >= 3)? Draw::Atof(theArgVal[2]) : 1.0e-7;
const Standard_Integer aNbPntsMax = (theNArg >= 4)? Draw::Atoi(theArgVal[3]) : 5;
const Standard_Integer aLowIndex = 5;
const Standard_Real aStep = 2.0*M_PI/aNbPntsMax;
TColStd_Array1OfReal anArrCoeffs(aLowIndex, aLowIndex+34);
aGtor->Torus().Coefficients(anArrCoeffs);
Standard_Real aUpar = 0.0, aVpar = 0.0;
for(Standard_Integer aUind = 0; aUind <= aNbPntsMax; aUind++)
{
for(Standard_Integer aVind = 0; aVind <= aNbPntsMax; aVind++)
{
const gp_Pnt aPt(aGtor->Value(aUpar, aVpar));
const Standard_Real aX1 = aPt.X();
const Standard_Real aX2 = aX1*aX1;
const Standard_Real aX3 = aX2*aX1;
const Standard_Real aX4 = aX2*aX2;
const Standard_Real aY1 = aPt.Y();
const Standard_Real aY2 = aY1*aY1;
const Standard_Real aY3 = aY2*aY1;
const Standard_Real aY4 = aY2*aY2;
const Standard_Real aZ1 = aPt.Z();
const Standard_Real aZ2 = aZ1*aZ1;
const Standard_Real aZ3 = aZ2*aZ1;
const Standard_Real aZ4 = aZ2*aZ2;
Standard_Integer i = aLowIndex;
Standard_Real aDelta = anArrCoeffs(i++) * aX4; //1
aDelta+= anArrCoeffs(i++) * aY4; //2
aDelta+= anArrCoeffs(i++) * aZ4; //3
aDelta+= anArrCoeffs(i++) * aX3 * aY1; //4
aDelta+= anArrCoeffs(i++) * aX3 * aZ1; //5
aDelta+= anArrCoeffs(i++) * aY3 * aX1; //6
aDelta+= anArrCoeffs(i++) * aY3 * aZ1; //7
aDelta+= anArrCoeffs(i++) * aZ3 * aX1; //8
aDelta+= anArrCoeffs(i++) * aZ3 * aY1; //9
aDelta+= anArrCoeffs(i++) * aX2 * aY2; //10
aDelta+= anArrCoeffs(i++) * aX2 * aZ2; //11
aDelta+= anArrCoeffs(i++) * aY2 * aZ2; //12
aDelta+= anArrCoeffs(i++) * aX2 * aY1 * aZ1; //13
aDelta+= anArrCoeffs(i++) * aX1 * aY2 * aZ1; //14
aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ2; //15
aDelta+= anArrCoeffs(i++) * aX3; //16
aDelta+= anArrCoeffs(i++) * aY3; //17
aDelta+= anArrCoeffs(i++) * aZ3; //18
aDelta+= anArrCoeffs(i++) * aX2 * aY1; //19
aDelta+= anArrCoeffs(i++) * aX2 * aZ1; //20
aDelta+= anArrCoeffs(i++) * aY2 * aX1; //21
aDelta+= anArrCoeffs(i++) * aY2 * aZ1; //22
aDelta+= anArrCoeffs(i++) * aZ2 * aX1; //23
aDelta+= anArrCoeffs(i++) * aZ2 * aY1; //24
aDelta+= anArrCoeffs(i++) * aX1 * aY1 * aZ1; //25
aDelta+= anArrCoeffs(i++) * aX2; //26
aDelta+= anArrCoeffs(i++) * aY2; //27
aDelta+= anArrCoeffs(i++) * aZ2; //28
aDelta+= anArrCoeffs(i++) * aX1 * aY1; //29
aDelta+= anArrCoeffs(i++) * aX1 * aZ1; //30
aDelta+= anArrCoeffs(i++) * aY1 * aZ1; //31
aDelta+= anArrCoeffs(i++) * aX1; //32
aDelta+= anArrCoeffs(i++) * aY1; //33
aDelta+= anArrCoeffs(i++) * aZ1; //34
aDelta+= anArrCoeffs(i++); //35
if(Abs(aDelta) > aToler)
{
theDI << "(" << aUpar << ", " << aVpar << "): Error in torus coefficients computation (Delta = " << aDelta << ").\n";
}
else
{
theDI << "(" << aUpar << ", " << aVpar << "): OK (Delta = " << aDelta << ").\n";
}
aVpar = (aVind == aNbPntsMax)? 2.0*M_PI : aVpar + aStep;
}
aVpar = 0.0;
aUpar = (aUind == aNbPntsMax)? 2.0*M_PI : aUpar + aStep;
}
return 0;
}
void QABugs::Commands_19(Draw_Interpretor& theCommands) {
const char *group = "QABugs";
@ -4629,5 +4733,7 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
theCommands.Add ("OCC24537", "OCC24537 [file]", __FILE__, OCC24537, group);
theCommands.Add ("OCC26750", "OCC26750", __FILE__, OCC26750, group);
theCommands.Add ("OCC26746", "OCC26746 torus [toler NbCheckedPoints] ", __FILE__, OCC26746, group);
return;
}

View File

@ -24,170 +24,143 @@
#include <Standard_ConstructionError.hxx>
#include <Standard_DimensionError.hxx>
void gp_Torus::Coefficients (TColStd_Array1OfReal& Coef) const
void gp_Torus::Coefficients (TColStd_Array1OfReal& theCoef) const
{
// Dans le repere local du tore :
// X*X + Y*Y + Z*Z - 2.0 * majorRadius * sqrt (X*X + Y*Y)
// - minorRadius * minorRadius + majorRadius * majorRadius = 0.0
// X**4 + Y **4 + 2.0 * (X*Y)**2 + 2.0 * (X*Z)**2 + 2.0 * (Y*Z)**2 -
// 2.0 * (majorRadius + minorRadius) * (X**2 + Y**2) +
// 2.0 * (majorRadius - minorRadius) * Z**2 - 2.0 *
// majorRadius * minorRadius = 0.0
Standard_Integer Low = Coef.Lower();
Standard_DimensionError_Raise_if (Coef.Length() < 31, " ");
gp_Trsf T;
Standard_Real SumRadius = (majorRadius * majorRadius +
minorRadius * minorRadius);
Standard_Real SubRadius = (majorRadius * majorRadius -
minorRadius * minorRadius);
T.SetTransformation (pos);
Standard_Real T11 = T.Value (1, 1);
Standard_Real T12 = T.Value (1, 2);
Standard_Real T13 = T.Value (1, 3);
Standard_Real T14 = T.Value (1, 4);
Standard_Real T21 = T.Value (2, 1);
Standard_Real T22 = T.Value (2, 2);
Standard_Real T23 = T.Value (2, 3);
Standard_Real T24 = T.Value (2, 4);
Standard_Real T31 = T.Value (3, 1);
Standard_Real T32 = T.Value (3, 2);
Standard_Real T33 = T.Value (3, 3);
Standard_Real T34 = T.Value (3, 4);
Coef(Low) = Pow (T11, 4) + Pow (T21, 4) + Pow(T31, 4) +
2.0 * (T11 * T11 * T21 * T21 + T11 * T11 * T31 * T31 +
T21 * T21 * T31 * T31);
Coef(Low+1) = Pow (T12, 4) + Pow (T22, 4) + Pow(T32, 4) +
2.0 * (T12 * T12 * T22 * T22 + T12 * T12 * T32 * T32 +
T22 * T22 * T32 * T32);
Coef(Low+2) = Pow (T13, 4) + Pow (T23, 4) + Pow(T33, 4) +
2.0 * (T13 * T13 * T23 * T23 + T13 * T13 * T33 * T33 +
T23 * T23 * T33 * T33);
Coef(Low+3) = 4.0 * (Pow (T11, 3) * T12 + Pow (T21, 3) * T22 +
Pow (T31, 3) * T32 + T11 * T11 * T21 * T22 + T21 * T21 * T11 * T12 +
T11 * T11 * T31 * T32 + T31 * T31 * T11 * T12 + T21 * T21 * T31 * T32
+ T31 * T31 * T21 * T22);
Coef(Low+4) = 4.0 * (Pow (T11, 3) * T13 + Pow (T21, 3) * T23 +
Pow (T31, 3) * T33 + T11 * T11 * T21 * T23 + T21 * T21 * T11 * T13 +
T11 * T11 * T31 * T33 + T31 * T31 * T11 * T13 + T21 * T21 * T31 * T33
+ T31 * T31 * T21 * T23);
Coef(Low+5) = 4.0 * (Pow (T12, 3) * T11 + Pow (T22, 3) * T21 +
Pow (T32, 3) * T31 + T12 * T12 * T21 * T22 + T22 * T22 * T11 * T12 +
T12 * T12 * T31 * T32 + T32 * T32 * T11 * T12 + T22 * T22 * T31 * T32
+ T32 * T32 * T21 * T22);
Coef(Low+6) = 4.0 * (Pow (T12, 3) * T13 + Pow (T22, 3) * T23 +
Pow (T32, 3) * T33 + T12 * T12 * T22 * T23 + T22 * T22 * T12 * T13 +
T12 * T12 * T32 * T33 + T32 * T32 * T12 * T13 + T22 * T22 * T32 * T33
+ T32 * T32 * T22 * T23);
Coef(Low+7) = 4.0 * (Pow (T13, 3) * T11 + Pow (T23, 3) * T21 +
Pow (T33, 3) * T31 + T13 * T13 * T21 * T23 + T23 * T23 * T11 * T13 +
T13 * T13 * T31 * T33 + T33 * T33 * T11 * T13 + T23 * T23 * T31 * T33
+ T33 * T33 * T21 * T23);
Coef(Low+8) = 4.0 * (Pow (T13, 3) * T12 + Pow (T23, 3) * T22 +
Pow (T33, 3) * T32 + T13 * T13 * T22 * T23 + T23 * T23 * T12 * T13 +
T13 * T13 * T32 * T33 + T33 * T33 * T12 * T13 + T23 * T23 * T32 * T33
+ T33 * T33 * T22 * T23);
Coef(Low+9) = 6.0 * (T11 * T11 * T12 * T12 + T21 * T21 * T22 * T22 +
T31 * T31 * T32 * T32) + 8.0 * ( T11 * T12 * T21 * T22 +
T11 * T12 * T31 * T32 + T21 * T22 * T31 * T32) +
2.0 * (T11 * T11 * T22 * T22 + T11 * T11 * T32 * T32 +
T21 * T21 * T32 * T32 + T12 * T12 * T21 * T21 +
T12 * T12 * T31 * T31 + T22 * T22 * T31 * T31 );
Coef(Low+10) = 6.0 * (T11 * T11 * T13 * T13 + T21 * T21 * T23 * T23 +
T31 * T31 * T33 * T33) + 8.0 * ( T11 * T13 * T21 * T23 +
T11 * T13 * T31 * T33 + T21 * T23 * T31 * T33) +
2.0 * (T11 * T11 * T23 * T23 + T11 * T11 * T33 * T33 +
T21 * T21 * T33 * T33 + T13 * T13 * T21 * T21 +
T13 * T13 * T31 * T31 + T23 * T23 * T31 * T31);
Coef(Low+11) = 6.0 * (T12 * T12 * T13 * T13 + T22 * T22 * T23 * T23 +
T32 * T32 * T33 * T33) + 8.0 * ( T12 * T13 * T22 * T23 +
T12 * T23 * T32 * T33 + T22 * T23 * T32 * T33) +
2.0 * (T12 * T12 * T23 * T23 + T12 * T12 * T33 * T33 +
T22 * T22 * T33 * T33 + T13 * T13 * T22 * T22 +
T13 * T13 * T32 * T32 + T23 * T23 * T32 * T32);
Coef(Low+12) = 4.0 * (Pow (T11, 3) * T14 + Pow (T21, 3) * T24 +
Pow (T31, 3) * T34 + T11 * T11 * T21 * T24 + T11 * T11 * T31 * T34 +
T21 * T21 * T31 * T34 + T21 * T21 * T11 * T14 +
T31 * T31 * T11 * T34 + T31 * T31 * T21 * T24);
Coef(Low+13) = 4.0 * (Pow (T12, 3) * T14 + Pow (T22, 3) * T24 +
Pow (T32, 3) * T34 + T12 * T12 * T22 * T24 + T12 * T12 * T32 * T34 +
T22 * T22 * T32 * T34 + T22 * T22 * T12 * T14 +
T32 * T32 * T12 * T34 + T32 * T32 * T22 * T24);
Coef(Low+14) = 4.0 * (Pow (T13, 3) * T14 + Pow (T23, 3) * T24 +
Pow (T33, 3) * T34 + T13 * T13 * T23 * T24 + T13 * T13 * T33 * T34 +
T23 * T23 * T33 * T34 + T23 * T23 * T13 * T14 +
T33 * T33 * T13 * T34 + T33 * T33 * T23 * T24);
Coef(Low+15) = 4.0 * (T11 * T11 * T22 * T24 + T11 * T11 * T32 * T34 +
T21 * T21 * T32 * T34 + T21 * T21 * T12 * T14 + T31 * T31 * T12 * T14
+ T31 * T31 * T22 * T24);
Coef(Low+16) = 4.0 * (T11 * T11 * T23 * T24 + T11 * T11 * T33 * T34 +
T21 * T21 * T33 * T34 + T21 * T21 * T13 * T14 + T31 * T31 * T13 * T14
+ T31 * T31 * T23 * T24);
Coef(Low+17) = 4.0 * (T12 * T12 * T21 * T24 + T12 * T12 * T31 * T34 +
T22 * T22 * T31 * T34 + T22 * T22 * T11 * T14 + T32 * T32 * T11 * T14
+ T32 * T32 * T21 * T24);
Coef(Low+18) = 4.0 * (T12 * T12 * T23 * T24 + T12 * T12 * T33 * T34 +
T22 * T22 * T33 * T34 + T22 * T22 * T13 * T14 + T32 * T32 * T13 * T14
+ T32 * T32 * T23 * T24);
Coef(Low+19) = 4.0 * (T13 * T13 * T21 * T24 + T13 * T13 * T31 * T34 +
T23 * T23 * T31 * T34 + T23 * T23 * T11 * T14 + T33 * T33 * T11 * T14
+ T33 * T33 * T21 * T24);
Coef(Low+20) = 4.0 * (T13 * T13 * T22 * T24 + T13 * T13 * T32 * T34 +
T23 * T23 * T32 * T34 + T23 * T23 * T12 * T14 + T33 * T33 * T12 * T14
+ T33 * T33 * T22 * T24);
Coef(Low+21) = 6.0 * (T11 * T11 * T14 * T14 + T21 * T21 * T24 * T24 +
T31 * T31 * T34 * T34) + 2.0 * (T11 * T11 * T24 * T24 +
T11 * T11 * T34 * T34 + T21 * T21 * T34 * T34 + T21 * T21 * T14 * T14
+ T31 * T31 * T14 * T14 + T31 * T31 * T24 * T24 -
SumRadius * (T11 * T11 + T21 * T21) + SubRadius * T31 * T31);
Coef(Low+22) = 6.0 * (T12 * T12 * T14 * T14 + T22 * T22 * T24 * T24 +
T32 * T32 * T34 * T34) + 2.0 * (T12 * T12 * T24 * T24 +
T12 * T12 * T34 * T34 + T22 * T22 * T34 * T34 + T22 * T22 * T14 * T14
+ T32 * T32 * T14 * T14 + T32 * T32 * T24 * T24 -
SumRadius * (T12 * T12 + T22 * T22) + SubRadius * T32 * T32);
Coef(Low+23) = 6.0 * (T13 * T13 * T14 * T14 + T23 * T23 * T24 * T24 +
T33 * T33 * T34 * T34) + 2.0 * (T13 * T13 * T24 * T24 +
T13 * T13 * T34 * T34 + T23 * T23 * T34 * T34 + T23 * T23 * T14 * T14
+ T33 * T33 * T14 * T14 + T33 * T33 * T24 * T24 -
SumRadius * (T13 * T13 + T23 * T23) + SubRadius * T33 * T33);
Coef(Low+24) = 8.0 * (T11 * T14 * T22 * T24 + T11 * T14 * T32 * T34 +
T21 * T24 * T32 * T34 + T21 * T24 * T12 * T14 + T31 * T34 * T12 * T14
+ T31 * T34 *T22 * T24) + 4.0 * (T11 * T12 * T24 * T24 +
T11 * T12 * T34 * T34 + T21 * T22 * T34 * T34 + T21 * T22 * T14 * T14
+ T31 * T32 * T14 * T14 + T31 * T32 * T24 * T24 - SumRadius * (
T11 * T12 + T21 * T22) + SubRadius * T31 * T32);
Coef(Low+25) = 8.0 * (T11 * T14 * T23 * T24 + T11 * T14 * T33 * T34 +
T21 * T24 * T33 * T34 + T21 * T24 * T13 * T14 + T31 * T34 * T13 * T14
+ T31 * T34 *T23 * T24) + 4.0 * (T11 * T13 * T24 * T24 +
T11 * T13 * T34 * T34 + T21 * T23 * T34 * T34 + T21 * T23 * T14 * T14
+ T31 * T33 * T14 * T14 + T31 * T33 * T24 * T24 - SumRadius * (
T11 * T13 + T21 * T22) + SubRadius * T31 * T33);
Coef(Low+26) = 8.0 * (T12 * T14 * T23 * T24 + T12 * T14 * T33 * T34 +
T22 * T24 * T33 * T34 + T22 * T24 * T13 * T14 + T32 * T34 * T13 * T14
+ T32 * T34 *T23 * T24) + 4.0 * (T12 * T13 * T24 * T24 +
T12 * T13 * T34 * T34 + T22 * T23 * T34 * T34 + T22 * T23 * T14 * T14
+ T32 * T33 * T14 * T14 + T32 * T33 * T24 * T24 - SumRadius * (
T12 * T13 + T21 * T22) + SubRadius * T32 * T33);
// R = majorRadius;
// r = minorRadius.
// X = (R + r*cos(V))*cos(U)
// Y = (R + r*cos(V))*sin(U)
// Z = r*sin(V)
Coef(Low+27) = 4.0 * (Pow (T14, 3) * T11 + Pow (T24, 3) * T21 +
Pow (T34, 3) * T31 + T11 * T14 * T24 * T24 + T11 * T14 * T34 * T34
+ T21 * T24 * T34 * T34 + T21 * T24 * T14 * T14 +
T31 * T34 * T14 * T14 + T31 * T34 * T24 * T24 + SubRadius * T31 * T34
- SumRadius * (T11 * T14 + T21 * T24));
Coef(Low+28) = 4.0 * (Pow (T14, 3) * T12 + Pow (T24, 3) * T22 +
Pow (T34, 3) * T32 + T12 * T14 * T24 * T24 + T12 * T14 * T34 * T34
+ T22 * T24 * T34 * T34 + T22 * T24 * T14 * T14 +
T32 * T34 * T14 * T14 + T32 * T34 * T24 * T24 + SubRadius * T32 * T34
- SumRadius * (T12 * T14 + T22 * T24));
Coef(Low+29) = 4.0 * (Pow (T14, 3) * T13 + Pow (T24, 3) * T23 +
Pow (T34, 3) * T33 + T13 * T14 * T24 * T24 + T13 * T14 * T34 * T34
+ T23 * T24 * T34 * T34 + T23 * T24 * T14 * T14 +
T33 * T34 * T14 * T14 + T33 * T34 * T24 * T24 + SubRadius * T33 * T34
- SumRadius * (T13 * T14 + T21 * T24));
Coef(Low+30) = Pow (T14, 4) + Pow (T24, 4) + Pow (T34, 4) + 2.0 * (
T14 * T14 * T24 * T24 + T14 * T14 * T34 * T34 + T24 * T24 * T34 * T34
- SumRadius * (T14 * T14 + T24 * T24) + SubRadius * T34 * T34 -
majorRadius * majorRadius * minorRadius * minorRadius);
//Therefore,
// 4*R*R*(r*r - Z*Z) = (X*X + Y*Y + Z*Z - R*R - r*r)^2
//Or
// X^4+Y^4+Z^4+
// 2*((X*Y)^2+(X*Z)^2+(Y*Z)^2)-
// 2*(R^2+r^2)*(X^2+Y^2)+
// 2*(R^2-r^2)*Z^2+(R^2-r^2)^2 = 0.0
const Standard_Integer aLowIndex = theCoef.Lower();
Standard_DimensionError_Raise_if (theCoef.Length() < 35,
"gp_Torus::theCoefficients(): Dimension mismatch");
gp_Trsf aTr;
aTr.SetTransformation (pos);
const Standard_Real aT11 = aTr.Value (1, 1);
const Standard_Real aT12 = aTr.Value (1, 2);
const Standard_Real aT13 = aTr.Value (1, 3);
const Standard_Real aT14 = aTr.Value (1, 4);
const Standard_Real aT21 = aTr.Value (2, 1);
const Standard_Real aT22 = aTr.Value (2, 2);
const Standard_Real aT23 = aTr.Value (2, 3);
const Standard_Real aT24 = aTr.Value (2, 4);
const Standard_Real aT31 = aTr.Value (3, 1);
const Standard_Real aT32 = aTr.Value (3, 2);
const Standard_Real aT33 = aTr.Value (3, 3);
const Standard_Real aT34 = aTr.Value (3, 4);
const Standard_Real aTcol1sq = aT11*aT11 + aT21*aT21 + aT31*aT31;
const Standard_Real aTcol2sq = aT12*aT12 + aT22*aT22 + aT32*aT32;
const Standard_Real aTcol3sq = aT13*aT13 + aT23*aT23 + aT33*aT33;
const Standard_Real aTcol4sq = aT14*aT14 + aT24*aT24 + aT34*aT34;
const Standard_Real aTcol1Tcol2 = aT11*aT12 + aT21*aT22 + aT31*aT32;
const Standard_Real aTcol1Tcol3 = aT11*aT13 + aT21*aT23 + aT31*aT33;
const Standard_Real aTcol2Tcol3 = aT12*aT13 + aT22*aT23 + aT32*aT33;
const Standard_Real aTcol1Tcol4 = aT11*aT14 + aT21*aT24 + aT31*aT34;
const Standard_Real aTcol2Tcol4 = aT12*aT14 + aT22*aT24 + aT32*aT34;
const Standard_Real aTcol3Tcol4 = aT13*aT14 + aT23*aT24 + aT33*aT34;
const Standard_Real aSumRadius = (majorRadius*majorRadius +
minorRadius*minorRadius);
const Standard_Real aSubRadius = (majorRadius*majorRadius -
minorRadius*minorRadius);
/*
After substitution
Transpose([X Y Z 1]) = aTr*Transpose([X Y Z 1])
we will obtain:
*/
theCoef(aLowIndex) = aTcol1sq*aTcol1sq; //X^4
theCoef(aLowIndex+1) = aTcol2sq*aTcol2sq; //Y^4
theCoef(aLowIndex+2) = aTcol3sq*aTcol3sq; //Z^4
theCoef(aLowIndex+3) = 4.0*aTcol1sq*aTcol1Tcol2; //X^3*Y
theCoef(aLowIndex+4) = 4.0*aTcol1sq*aTcol1Tcol3; //X^3*Z
theCoef(aLowIndex+5) = 4.0*aTcol2sq*aTcol1Tcol2; //X*Y^3
theCoef(aLowIndex+6) = 4.0*aTcol2sq*aTcol2Tcol3; //Y^3*Z
theCoef(aLowIndex+7) = 4.0*aTcol3sq*aTcol1Tcol3; //X*Z^3
theCoef(aLowIndex+8) = 4.0*aTcol3sq*aTcol2Tcol3; //Y*Z^3
theCoef(aLowIndex+9) = 2.0*(aTcol1sq*aTcol2sq +
2.0*aTcol1Tcol2*aTcol1Tcol2); //X^2*Y^2
theCoef(aLowIndex+10) = 2.0*(aTcol1sq*aTcol3sq +
2.0*aTcol1Tcol3*aTcol1Tcol3); //X^2*Z^2
theCoef(aLowIndex+11) = 2.0*(aTcol2sq*aTcol3sq +
2.0*aTcol2Tcol3*aTcol2Tcol3); //Y^2*Z^2
theCoef(aLowIndex+12) = 4.0*(aTcol1sq*aTcol2Tcol3 +
2.0*aTcol1Tcol2*aTcol1Tcol3); //X^2*Y*Z
theCoef(aLowIndex+13) = 4.0*(aTcol2sq*aTcol1Tcol3 +
2.0*aTcol1Tcol2*aTcol2Tcol3); //X*Y^2*Z
theCoef(aLowIndex+14) = 4.0*(aTcol3sq*aTcol1Tcol2 +
2.0*aTcol1Tcol3*aTcol2Tcol3); //X*Y*Z^2
theCoef(aLowIndex+15) = 4.0*aTcol1sq*aTcol1Tcol4; //X^3
theCoef(aLowIndex+16) = 4.0*aTcol2sq*aTcol2Tcol4; //Y^3
theCoef(aLowIndex+17) = 4.0*aTcol3sq*aTcol3Tcol4; //Z^3
theCoef(aLowIndex+18) = 4.0*(aTcol1sq*aTcol2Tcol4 +
2.0*aTcol1Tcol4*aTcol1Tcol2); //X^2*Y
theCoef(aLowIndex+19) = 4.0*(aTcol1sq*aTcol3Tcol4 +
2.0*aTcol1Tcol4*aTcol1Tcol3); //X^2*Z
theCoef(aLowIndex+20) = 4.0*(aTcol2sq*aTcol1Tcol4 +
2.0*aTcol2Tcol4*aTcol1Tcol2); //X*Y^2
theCoef(aLowIndex+21) = 4.0*(aTcol2sq*aTcol3Tcol4 +
2.0*aTcol2Tcol4*aTcol2Tcol3); //Y^2*Z
theCoef(aLowIndex+22) = 4.0*(aTcol3sq*aTcol1Tcol4 +
2.0*aTcol3Tcol4*aTcol1Tcol3); //X*Z^2
theCoef(aLowIndex+23) = 4.0*(aTcol3sq*aTcol2Tcol4 +
2.0*aTcol3Tcol4*aTcol2Tcol3); //Y*Z^2
theCoef(aLowIndex+24) = 8.0*(aTcol1Tcol2*aTcol3Tcol4 +
aTcol2Tcol3*aTcol1Tcol4 +
aTcol2Tcol4*aTcol1Tcol3); //X*Y*Z
theCoef(aLowIndex+25) = 2.0*(aSubRadius*aT31*aT31 -
aSumRadius*(aT11*aT11 + aT21*aT21) +
aTcol4sq*aTcol1sq +
2.0*aTcol1Tcol4*aTcol1Tcol4); //X^2
theCoef(aLowIndex+26) = 2.0*(aSubRadius*aT32*aT32 -
aSumRadius*(aT12*aT12 + aT22*aT22) +
aTcol4sq*aTcol2sq +
2.0*aTcol2Tcol4*aTcol2Tcol4); //Y^2
theCoef(aLowIndex+27) = 2.0*(aSubRadius*aT33*aT33 -
aSumRadius*(aT13*aT13 + aT23*aT23) +
aTcol4sq*aTcol3sq +
2.0*aTcol3Tcol4*aTcol3Tcol4); //Z^2
theCoef(aLowIndex+28) = 4.0*(aSubRadius*aT31*aT32 -
aSumRadius*(aT11*aT12 + aT21*aT22) +
aTcol4sq*aTcol1Tcol2 +
2.0*aTcol1Tcol4*aTcol2Tcol4); //X*Y
theCoef(aLowIndex+29) = 4.0*(aSubRadius*aT31*aT33 -
aSumRadius*(aT11*aT13 + aT21*aT23) +
aTcol4sq*aTcol1Tcol3 +
2.0*aTcol1Tcol4*aTcol3Tcol4); //X*Z
theCoef(aLowIndex+30) = 4.0*(aSubRadius*aT32*aT33 -
aSumRadius*(aT12*aT13 + aT22*aT23) +
aTcol4sq*aTcol2Tcol3 +
2.0*aTcol2Tcol4*aTcol3Tcol4); //Y*Z
theCoef(aLowIndex+31) = 4.0*(aTcol4sq*aTcol1Tcol4 +
aSubRadius*aT31*aT34 -
aSumRadius*(aT11*aT14 + aT21*aT24)); //X
theCoef(aLowIndex+32) = 4.0*(aTcol4sq*aTcol2Tcol4 +
aSubRadius*aT32*aT34 -
aSumRadius*(aT12*aT14 + aT22*aT24)); //Y
theCoef(aLowIndex+33) = 4.0*(aTcol4sq*aTcol3Tcol4 +
aSubRadius*aT33*aT34 -
aSumRadius*(aT13*aT14 + aT23*aT24)); //Z;
theCoef(aLowIndex+34) = 2.0*aSubRadius*aT34*aT34 -
2.0*aSumRadius*(aT14*aT14 + aT24*aT24) +
aTcol4sq*aTcol4sq + aSubRadius*aSubRadius;
}
void gp_Torus::Mirror (const gp_Pnt& P)

View File

@ -128,21 +128,23 @@ public:
//! returns the symmetry axis of the torus.
const gp_Ax1& Axis() const;
//! Computes the coefficients of the implicit equation of the surface
//! in the absolute cartesian coordinate system :
//! Coef(1) * X**4 + Coef(2) * Y**4 + Coef(3) * Z**4 +
//! Coef(4) * X**3 * Y + Coef(5) * X**3 * Z + Coef(6) * Y**3 * X +
//! Coef(7) * Y**3 * Z + Coef(8) * Z**3 * X + Coef(9) * Z**3 * Y +
//! Coef(10) * X**2 * Y**2 + Coef(11) * X**2 * Z**2 +
//! Coef(12) * Y**2 * Z**2 + Coef(13) * X**3 + Coef(14) * Y**3 +
//! Coef(15) * Z**3 + Coef(16) * X**2 * Y + Coef(17) * X**2 * Z +
//! Coef(18) * Y**2 * X + Coef(19) * Y**2 * Z + Coef(20) * Z**2 * X +
//! Coef(21) * Z**2 * Y + Coef(22) * X**2 + Coef(23) * Y**2 +
//! Coef(24) * Z**2 + Coef(25) * X * Y + Coef(26) * X * Z +
//! Coef(27) * Y * Z + Coef(28) * X + Coef(29) * Y + Coef(30) * Z +
//! Coef(31) = 0.0
//! Raises DimensionError if the length of Coef is lower than 31.
//! in the absolute Cartesian coordinate system:
//! Coef(1) * X^4 + Coef(2) * Y^4 + Coef(3) * Z^4 +
//! Coef(4) * X^3 * Y + Coef(5) * X^3 * Z + Coef(6) * Y^3 * X +
//! Coef(7) * Y^3 * Z + Coef(8) * Z^3 * X + Coef(9) * Z^3 * Y +
//! Coef(10) * X^2 * Y^2 + Coef(11) * X^2 * Z^2 +
//! Coef(12) * Y^2 * Z^2 + Coef(13) * X^2 * Y * Z +
//! Coef(14) * X * Y^2 * Z + Coef(15) * X * Y * Z^2 +
//! Coef(16) * X^3 + Coef(17) * Y^3 + Coef(18) * Z^3 +
//! Coef(19) * X^2 * Y + Coef(20) * X^2 * Z + Coef(21) * Y^2 * X +
//! Coef(22) * Y^2 * Z + Coef(23) * Z^2 * X + Coef(24) * Z^2 * Y +
//! Coef(25) * X * Y * Z +
//! Coef(26) * X^2 + Coef(27) * Y^2 + Coef(28) * Z^2 +
//! Coef(29) * X * Y + Coef(30) * X * Z + Coef(31) * Y * Z +
//! Coef(32) * X + Coef(33) * Y + Coef(34) * Z +
//! Coef(35) = 0.0
//! Raises DimensionError if the length of Coef is lower than 35.
Standard_EXPORT void Coefficients (TColStd_Array1OfReal& Coef) const;
//! Returns the Torus's location.

View File

@ -0,0 +1,15 @@
puts "========"
puts "OCC26746"
puts "========"
puts ""
#################################################
# 0026746: Method gp_Torus::Coefficients(...) returns incorrect value.
#################################################
pload QAcommands
set Tol 3.0e-7
torus tr 55.52514413 2.070076585 73.83409062 0.37231784651136368 0.58886674834874120 0.71736697293527607 0.80682335496555135, 0.17666016102759910, -0.56376170618524390 87.08479625 23.14682176
OCC26746 tr $Tol 5