1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #define No_Standard_OutOfRange
20 #include <gp_GTrsf.hxx>
22 #include <gp_Trsf.hxx>
24 #include <Standard_ConstructionError.hxx>
25 #include <Standard_OutOfRange.hxx>
27 void gp_GTrsf::SetTranslationPart (const gp_XYZ& Coord)
30 if (Form() == gp_CompoundTrsf || Form() == gp_Other ||
31 Form() == gp_Translation) { }
32 else if (Form() == gp_Identity) { shape = gp_Translation; }
33 else { shape = gp_CompoundTrsf; }
36 void gp_GTrsf::Invert ()
38 if (shape == gp_Other) {
40 loc.Multiply (matrix);
50 void gp_GTrsf::Multiply (const gp_GTrsf& T)
52 if (Form() == gp_Other || T.Form() == gp_Other) {
54 loc.Add (T.loc.Multiplied (matrix));
55 matrix.Multiply(T.matrix);
59 gp_Trsf T2 = T.Trsf();
68 void gp_GTrsf::Power (const Standard_Integer N)
74 loc = gp_XYZ (0.,0.,0.);
77 else if (N == -1) { Invert(); }
79 if (shape == gp_Other) {
80 Standard_Integer Npower = N;
81 if (Npower < 0) Npower = - Npower;
84 // Standard_Real Tempscale = scale;
85 gp_Mat Tempmatrix (matrix);
88 loc.Add (Temploc.Multiplied (matrix));
89 matrix.Multiply (Tempmatrix);
91 if (Npower == 1) { break; }
92 Temploc.Add (Temploc.Multiplied (Tempmatrix));
93 Tempmatrix.Multiply (Tempmatrix);
105 void gp_GTrsf::PreMultiply (const gp_GTrsf& T)
107 if (Form() == gp_Other || T.Form() == gp_Other) {
109 loc.Multiply (T.matrix);
111 matrix.PreMultiply(T.matrix);
115 gp_Trsf T2 = T.Trsf();
124 void gp_GTrsf::SetForm()
126 Standard_Real tol = 1.e-12; // Precision::Angular();
128 // don t trust the initial values !
131 Standard_Real s = M.Determinant();
133 if ( Abs(s) < gp::Resolution() )
134 throw Standard_ConstructionError("gp_GTrsf::SetForm, null determinant");
142 // check if the matrix is an uniform matrix
143 // the transposition should be the invert.
148 anIdentity.SetIdentity() ;
149 TM.Subtract(anIdentity);
150 if (shape==gp_Other) shape = gp_CompoundTrsf;
152 for (Standard_Integer i = 1; i <= 3; i++)
153 for (Standard_Integer j = 1; j <= 3; j++)
154 if ( Abs( TM.Value(i, j) ) > tol )