diff --git a/src/gp/gp_GTrsf.cxx b/src/gp/gp_GTrsf.cxx index d8951541a7..a9cd64d6e5 100644 --- a/src/gp/gp_GTrsf.cxx +++ b/src/gp/gp_GTrsf.cxx @@ -122,10 +122,10 @@ void gp_GTrsf::SetForm() // gp_Mat M(matrix); Standard_Real s = M.Determinant(); - Standard_Real As = s; - if (As < 0) As = - As; - Standard_ConstructionError_Raise_if - (As < gp::Resolution(),"gp_GTrsf::SetForm, null determinant"); + + if ( Abs(s) < gp::Resolution() ) + Standard_ConstructionError::Raise("gp_GTrsf::SetForm, null determinant"); + if (s > 0) s = Pow(s,1./3.); else @@ -142,15 +142,11 @@ void gp_GTrsf::SetForm() TM.Subtract(anIdentity); if (shape==gp_Other) shape = gp_CompoundTrsf; - Standard_Integer i, j; - for (i=1; i<=3; i++) { - for (j=1; j<=3; j++) { - As = TM.Value(i,j); - if (As < 0) As = - As; - if (As > tol) { - shape = gp_Other; - return; + for (Standard_Integer i = 1; i <= 3; i++) + for (Standard_Integer j = 1; j <= 3; j++) + if ( Abs( TM.Value(i, j) ) > tol ) + { + shape = gp_Other; + return; } - } - } } diff --git a/src/gp/gp_GTrsf.lxx b/src/gp/gp_GTrsf.lxx index 26d2f4abea..511bf892e7 100644 --- a/src/gp/gp_GTrsf.lxx +++ b/src/gp/gp_GTrsf.lxx @@ -176,9 +176,10 @@ inline void gp_GTrsf::Transforms (Standard_Real& X, inline gp_Trsf gp_GTrsf::Trsf () const { + if ( Form() == gp_Other ) + Standard_ConstructionError::Raise("gp_GTrsf::Trsf() - non-orthogonal GTrsf"); + gp_Trsf T; - Standard_ConstructionError_Raise_if - (Form() == gp_Other,""); T.shape = shape; T.scale = scale; T.matrix = matrix; diff --git a/src/gp/gp_GTrsf2d.cxx b/src/gp/gp_GTrsf2d.cxx index 8cbf37183b..d511b8f764 100644 --- a/src/gp/gp_GTrsf2d.cxx +++ b/src/gp/gp_GTrsf2d.cxx @@ -133,40 +133,35 @@ void gp_GTrsf2d::PreMultiply (const gp_GTrsf2d& T) gp_Trsf2d gp_GTrsf2d::Trsf2d () const { - gp_Trsf2d T; - Standard_Real value; -#ifndef No_Exception - Standard_Real tolerance = Precision::Angular() ; - Standard_Real tol2 = 2. * tolerance; -#endif + // Test of orthogonality + const Standard_Real aTolerance = Precision::Angular(); + const Standard_Real aTolerance2 = 2.0 * aTolerance; - Standard_ConstructionError_Raise_if - (Form() == gp_Other," gp_GTrsf2d::Trsf2d() - non-orthogonal GTrsf2d (0)"); + if ( Form() == gp_Other ) + Standard_ConstructionError::Raise("gp_GTrsf2d::Trsf2d() - non-orthogonal GTrsf2d(0)"); + + Standard_Real value = (matrix.Value(1, 1) * matrix.Value(1, 1) + + matrix.Value(2, 1) * matrix.Value(2, 1)); + if ( Abs(value - 1.) > aTolerance2 ) + Standard_ConstructionError::Raise("gp_GTrsf2d::Trsf2d() - non-orthogonal GTrsf2d(1)"); + + value = (matrix.Value(1, 2) * matrix.Value(1, 2) + + matrix.Value(2, 2) * matrix.Value(2, 2)); + if ( Abs(value - 1.) > aTolerance2 ) + Standard_ConstructionError::Raise("gp_GTrsf2d::Trsf2d() - non-orthogonal GTrsf2d(2)"); + + value = (matrix.Value(1, 1) * matrix.Value(1, 2) + + matrix.Value(2, 1) * matrix.Value(2, 2)); + if ( Abs(value) > aTolerance ) + Standard_ConstructionError::Raise("gp_GTrsf2d::Trsf2d() - non-orthogonal GTrsf2d(3)"); -//Test of orthogonality + gp_Trsf2d aTransformation; + aTransformation.matrix = matrix; + aTransformation.shape = shape; + aTransformation.scale = scale; + aTransformation.loc = loc; - value = (matrix.Value(1,1) * matrix.Value(1,1) + - matrix.Value(2,1) * matrix.Value(2,1)) ; - Standard_ConstructionError_Raise_if - (Abs(value - 1.) > tol2," gp_GTrsf2d::Trsf2d() - non-orthogonal GTrsf2d (1)"); - - value = (matrix.Value(1,2) * matrix.Value(1,2) + - matrix.Value(2,2) * matrix.Value(2,2)); - Standard_ConstructionError_Raise_if - (Abs(value - 1.) > tol2," gp_GTrsf2d::Trsf2d() - non-orthogonal GTrsf2d (2)"); - - value = (matrix.Value(1,1) * matrix.Value(1,2) + - matrix.Value(2,1) * matrix.Value(2,2)); - Standard_ConstructionError_Raise_if - (Abs(value) > tolerance," gp_GTrsf2d::Trsf2d() - non-orthogonal GTrsf2d (3)"); -// - - T.matrix = matrix ; - T.shape = shape; - T.scale = scale ; - T.loc = loc; - - return T; + return aTransformation; }