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 | |
15 | #include <gp_Vec.hxx> |
16 | #include <Vrml_SFRotation.hxx> |
17 | #include <Vrml_Transform.hxx> |
7fd59977 |
18 | |
19 | Vrml_Transform::Vrml_Transform() |
20 | { |
21 | gp_Vec tmpV(0,0,0); |
22 | myTranslation = tmpV; |
23 | |
24 | Vrml_SFRotation tmpSFR(0,0,1,0); |
25 | myRotation = tmpSFR; |
26 | |
27 | tmpV.SetX(1); |
28 | tmpV.SetY(1); |
29 | tmpV.SetZ(1); |
30 | myScaleFactor = tmpV; |
31 | |
32 | tmpSFR.SetRotationX(0); |
33 | tmpSFR.SetRotationY(0); |
34 | tmpSFR.SetRotationZ(1); |
35 | tmpSFR.SetAngle(0); |
36 | myScaleOrientation = tmpSFR; |
37 | |
38 | tmpV.SetX(0); |
39 | tmpV.SetY(0); |
40 | tmpV.SetZ(0); |
41 | myCenter = tmpV; |
42 | } |
43 | |
44 | Vrml_Transform::Vrml_Transform(const gp_Vec& aTranslation, |
45 | const Vrml_SFRotation& aRotation, |
46 | const gp_Vec& aScaleFactor, |
47 | const Vrml_SFRotation& aScaleOrientation, |
48 | const gp_Vec& aCenter) |
49 | { |
50 | myTranslation = aTranslation; |
51 | myRotation = aRotation; |
52 | myScaleFactor = aScaleFactor; |
53 | myScaleOrientation = aScaleOrientation; |
54 | myCenter = aCenter; |
55 | } |
56 | |
57 | void Vrml_Transform::SetTranslation(const gp_Vec& aTranslation) |
58 | { |
59 | myTranslation = aTranslation; |
60 | } |
61 | |
62 | gp_Vec Vrml_Transform::Translation() const |
63 | { |
64 | return myTranslation; |
65 | } |
66 | |
67 | void Vrml_Transform::SetRotation(const Vrml_SFRotation& aRotation) |
68 | { |
69 | myRotation = aRotation; |
70 | } |
71 | |
72 | Vrml_SFRotation Vrml_Transform::Rotation() const |
73 | { |
74 | return myRotation; |
75 | } |
76 | |
77 | void Vrml_Transform::SetScaleFactor(const gp_Vec& aScaleFactor) |
78 | { |
79 | myScaleFactor = aScaleFactor; |
80 | } |
81 | |
82 | gp_Vec Vrml_Transform::ScaleFactor() const |
83 | { |
84 | return myScaleFactor; |
85 | } |
86 | |
87 | void Vrml_Transform::SetScaleOrientation(const Vrml_SFRotation& aScaleOrientation) |
88 | { |
89 | myScaleOrientation = aScaleOrientation; |
90 | } |
91 | |
92 | Vrml_SFRotation Vrml_Transform::ScaleOrientation() const |
93 | { |
94 | return myScaleOrientation; |
95 | } |
96 | |
97 | void Vrml_Transform::SetCenter(const gp_Vec& aCenter) |
98 | { |
99 | myCenter = aCenter; |
100 | } |
101 | |
102 | gp_Vec Vrml_Transform::Center() const |
103 | { |
104 | return myCenter; |
105 | } |
106 | |
107 | Standard_OStream& Vrml_Transform::Print(Standard_OStream& anOStream) const |
108 | { |
586db386 |
109 | anOStream << "Transform {\n"; |
7fd59977 |
110 | |
111 | if ( Abs(myTranslation.X() - 0) > 0.0001 || |
112 | Abs(myTranslation.Y() - 0) > 0.0001 || |
113 | Abs(myTranslation.Z() - 0) > 0.0001 ) |
114 | { |
586db386 |
115 | anOStream << " translation\t\t"; |
116 | anOStream << myTranslation.X() << " " << myTranslation.Y() << " " << myTranslation.Z() << "\n"; |
7fd59977 |
117 | } |
118 | |
119 | if ( Abs(myRotation.RotationX() - 0) > 0.0001 || |
120 | Abs(myRotation.RotationY() - 0) > 0.0001 || |
121 | Abs(myRotation.RotationZ() - 1) > 0.0001 || |
122 | Abs(myRotation.Angle() - 0) > 0.0001 ) |
123 | { |
586db386 |
124 | anOStream << " rotation\t\t"; |
125 | anOStream << myRotation.RotationX() << " " << myRotation.RotationY() << " "; |
126 | anOStream << myRotation.RotationZ() << " " << myRotation.Angle() << "\n"; |
7fd59977 |
127 | } |
128 | |
129 | if ( Abs(myScaleFactor.X() - 1) > 0.0001 || |
130 | Abs(myScaleFactor.Y() - 1) > 0.0001 || |
131 | Abs(myScaleFactor.Z() - 1) > 0.0001 ) |
132 | { |
586db386 |
133 | anOStream << " scaleFactor\t\t"; |
134 | anOStream << myTranslation.X() << " " << myTranslation.Y() << " " << myTranslation.Z() << "\n"; |
7fd59977 |
135 | } |
136 | |
137 | if ( Abs(myScaleOrientation.RotationX() - 0) > 0.0001 || |
138 | Abs(myScaleOrientation.RotationY() - 0) > 0.0001 || |
139 | Abs(myScaleOrientation.RotationZ() - 1) > 0.0001 || |
140 | Abs(myScaleOrientation.Angle() - 0) > 0.0001 ) |
141 | { |
586db386 |
142 | anOStream << " scaleOrientation\t"; |
143 | anOStream << myScaleOrientation.RotationX() << " " << myScaleOrientation.RotationY() << " "; |
144 | anOStream << myScaleOrientation.RotationZ() << " " << myScaleOrientation.Angle() << "\n"; |
7fd59977 |
145 | } |
146 | |
147 | if ( Abs(myCenter.X() - 0) > 0.0001 || |
148 | Abs(myCenter.Y() - 0) > 0.0001 || |
149 | Abs(myCenter.Z() - 0) > 0.0001 ) |
150 | { |
586db386 |
151 | anOStream << " center\t\t"; |
152 | anOStream << myCenter.X() << " " << myCenter.Y() << " " << myCenter.Z() << "\n"; |
7fd59977 |
153 | } |
154 | |
586db386 |
155 | anOStream << "}\n"; |
7fd59977 |
156 | return anOStream; |
157 | } |