973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
42cf5bc1 |
14 | |
7fd59977 |
15 | #include <gp_Ax3.hxx> |
42cf5bc1 |
16 | #include <gp_Dir.hxx> |
17 | #include <gp_Pnt.hxx> |
18 | #include <gp_Trsf.hxx> |
7fd59977 |
19 | #include <Precision.hxx> |
42cf5bc1 |
20 | #include <Vrml_MatrixTransform.hxx> |
7fd59977 |
21 | |
b311480e |
22 | Vrml_MatrixTransform::Vrml_MatrixTransform() |
7fd59977 |
23 | { |
24 | // SetValues(me : in out; |
25 | // a11, a12, a13, a14, |
26 | // a21, a22, a23, a24, |
27 | // a31, a32, a33, a34 : Real; |
28 | // Tolang, TolDist : Real) |
29 | |
30 | gp_Trsf T; |
31 | T.SetValues ( 1, 0, 0, 0, |
32 | 0, 1, 0, 0, |
7a8c6a36 |
33 | 0, 0, 1, 0); |
7fd59977 |
34 | T.SetScaleFactor(1); |
35 | |
36 | myMatrix = T; |
37 | } |
38 | |
39 | Vrml_MatrixTransform::Vrml_MatrixTransform(const gp_Trsf& aMatrix) |
40 | { |
41 | myMatrix = aMatrix; |
42 | } |
43 | |
44 | void Vrml_MatrixTransform::SetMatrix(const gp_Trsf& aMatrix) |
45 | { |
46 | myMatrix = aMatrix; |
47 | } |
48 | |
49 | gp_Trsf Vrml_MatrixTransform::Matrix() const |
50 | { |
51 | return myMatrix; |
52 | } |
53 | |
54 | Standard_OStream& Vrml_MatrixTransform::Print(Standard_OStream& anOStream) const |
55 | { |
56 | Standard_Integer i,j; |
586db386 |
57 | anOStream << "MatrixTransform {\n"; |
7fd59977 |
58 | |
59 | if ( Abs(myMatrix.Value(1,1) - 1) > 0.0000001 || Abs(myMatrix.Value(2,1) - 0) > 0.0000001 || Abs(myMatrix.Value(3,1) - 0) > 0.0000001 || |
60 | Abs(myMatrix.Value(1,2) - 0) > 0.0000001 || Abs(myMatrix.Value(2,2) - 1) > 0.0000001 || Abs(myMatrix.Value(3,2) - 0) > 0.0000001 || |
61 | Abs(myMatrix.Value(1,3) - 0) > 0.0000001 || Abs(myMatrix.Value(2,3) - 0) > 0.0000001 || Abs(myMatrix.Value(3,3) - 1) > 0.0000001 || |
62 | Abs(myMatrix.Value(1,4) - 0) > 0.0000001 || Abs(myMatrix.Value(2,4) - 0) > 0.0000001 || Abs(myMatrix.Value(3,4) - 0) > 0.0000001 ) |
63 | { |
586db386 |
64 | anOStream << " matrix\t"; |
7fd59977 |
65 | |
66 | for ( j = 1; j <=4; j++ ) |
67 | { |
68 | for ( i = 1; i <=3; i++ ) |
69 | { |
70 | // Value (me; Row, Col : Integer) returns Real |
71 | anOStream << myMatrix.Value(i,j) << ' '; |
72 | } |
73 | if (j!=4) |
74 | { |
586db386 |
75 | anOStream << "0\n"; |
7fd59977 |
76 | anOStream << "\t\t"; |
77 | } |
78 | else |
79 | { |
586db386 |
80 | anOStream << myMatrix.ScaleFactor() << "\n"; |
7fd59977 |
81 | } |
82 | } |
83 | } |
586db386 |
84 | anOStream << "}\n"; |
7fd59977 |
85 | return anOStream; |
86 | } |