1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <gp_Ax3.hxx>
16 #include <gp_Dir.hxx>
17 #include <gp_Pnt.hxx>
18 #include <gp_Trsf.hxx>
19 #include <Precision.hxx>
20 #include <Vrml_MatrixTransform.hxx>
21
Vrml_MatrixTransform()22 Vrml_MatrixTransform::Vrml_MatrixTransform()
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,
33 0, 0, 1, 0);
34 T.SetScaleFactor(1);
35
36 myMatrix = T;
37 }
38
Vrml_MatrixTransform(const gp_Trsf & aMatrix)39 Vrml_MatrixTransform::Vrml_MatrixTransform(const gp_Trsf& aMatrix)
40 {
41 myMatrix = aMatrix;
42 }
43
SetMatrix(const gp_Trsf & aMatrix)44 void Vrml_MatrixTransform::SetMatrix(const gp_Trsf& aMatrix)
45 {
46 myMatrix = aMatrix;
47 }
48
Matrix() const49 gp_Trsf Vrml_MatrixTransform::Matrix() const
50 {
51 return myMatrix;
52 }
53
Print(Standard_OStream & anOStream) const54 Standard_OStream& Vrml_MatrixTransform::Print(Standard_OStream& anOStream) const
55 {
56 Standard_Integer i,j;
57 anOStream << "MatrixTransform {\n";
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 {
64 anOStream << " matrix\t";
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 {
75 anOStream << "0\n";
76 anOStream << "\t\t";
77 }
78 else
79 {
80 anOStream << myMatrix.ScaleFactor() << "\n";
81 }
82 }
83 }
84 anOStream << "}\n";
85 return anOStream;
86 }
87