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
17 #include <gp_GTrsf.ixx>
20 void gp_GTrsf::SetTranslationPart (const gp_XYZ& Coord)
23 if (Form() == gp_CompoundTrsf || Form() == gp_Other ||
24 Form() == gp_Translation) { }
25 else if (Form() == gp_Identity) { shape = gp_Translation; }
26 else { shape = gp_CompoundTrsf; }
29 void gp_GTrsf::Invert ()
31 if (shape == gp_Other) {
33 loc.Multiply (matrix);
43 void gp_GTrsf::Multiply (const gp_GTrsf& T)
45 if (Form() == gp_Other || T.Form() == gp_Other) {
47 loc.Add (T.loc.Multiplied (matrix));
48 matrix.Multiply(T.matrix);
52 gp_Trsf T2 = T.Trsf();
61 void gp_GTrsf::Power (const Standard_Integer N)
67 loc = gp_XYZ (0.,0.,0.);
70 else if (N == -1) { Invert(); }
72 if (shape == gp_Other) {
73 Standard_Integer Npower = N;
74 if (Npower < 0) Npower = - Npower;
77 // Standard_Real Tempscale = scale;
78 gp_Mat Tempmatrix (matrix);
81 loc.Add (Temploc.Multiplied (matrix));
82 matrix.Multiply (Tempmatrix);
84 if (Npower == 1) { break; }
85 Temploc.Add (Temploc.Multiplied (Tempmatrix));
86 Tempmatrix.Multiply (Tempmatrix);
98 void gp_GTrsf::PreMultiply (const gp_GTrsf& T)
100 if (Form() == gp_Other || T.Form() == gp_Other) {
102 loc.Multiply (T.matrix);
104 matrix.PreMultiply(T.matrix);
108 gp_Trsf T2 = T.Trsf();
117 void gp_GTrsf::SetForm()
119 Standard_Real tol = 1.e-12; // Precision::Angular();
121 // don t trust the initial values !
124 Standard_Real s = M.Determinant();
125 Standard_Real As = s;
126 if (As < 0) As = - As;
127 Standard_ConstructionError_Raise_if
128 (As < gp::Resolution(),"gp_GTrsf::SetForm, null determinant");
135 // check if the matrix is an uniform matrix
136 // the transposition should be the invert.
141 anIdentity.SetIdentity() ;
142 TM.Subtract(anIdentity);
143 if (shape==gp_Other) shape = gp_CompoundTrsf;
145 Standard_Integer i, j;
146 for (i=1; i<=3; i++) {
147 for (j=1; j<=3; j++) {
149 if (As < 0) As = - As;