0030731: Modeling Data - B-Spline should have explicit data check error messages
[occt.git] / src / Geom / Geom_VectorWithMagnitude.cxx
1 // Created on: 1993-03-10
2 // Created by: JCV
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Geom_Geometry.hxx>
19 #include <Geom_Vector.hxx>
20 #include <Geom_VectorWithMagnitude.hxx>
21 #include <gp_Pnt.hxx>
22 #include <gp_Trsf.hxx>
23 #include <gp_Vec.hxx>
24 #include <Standard_ConstructionError.hxx>
25 #include <Standard_Type.hxx>
26
27 IMPLEMENT_STANDARD_RTTIEXT(Geom_VectorWithMagnitude,Geom_Vector)
28
29 typedef Geom_VectorWithMagnitude         VectorWithMagnitude;
30 typedef Geom_Vector                      Vector;
31 typedef gp_Ax1  Ax1;
32 typedef gp_Ax2  Ax2;
33 typedef gp_Pnt  Pnt;
34 typedef gp_Trsf Trsf;
35
36 //=======================================================================
37 //function : Geom_VectorWithMagnitude
38 //purpose  : 
39 //=======================================================================
40
41 Geom_VectorWithMagnitude::Geom_VectorWithMagnitude (const gp_Vec& V) 
42 { gpVec = V; }
43
44
45 //=======================================================================
46 //function : Geom_VectorWithMagnitude
47 //purpose  : 
48 //=======================================================================
49
50 Geom_VectorWithMagnitude::Geom_VectorWithMagnitude (
51 const Standard_Real X,  const Standard_Real Y,  const Standard_Real Z)  { gpVec = gp_Vec (X, Y, Z); }
52
53
54 //=======================================================================
55 //function : Geom_VectorWithMagnitude
56 //purpose  : 
57 //=======================================================================
58
59 Geom_VectorWithMagnitude::Geom_VectorWithMagnitude (
60 const Pnt& P1, const Pnt& P2) { gpVec = gp_Vec (P1, P2); }
61
62
63 //=======================================================================
64 //function : Copy
65 //purpose  : 
66 //=======================================================================
67
68 Handle(Geom_Geometry) Geom_VectorWithMagnitude::Copy() const {
69
70   Handle(Geom_VectorWithMagnitude) V;
71   V = new VectorWithMagnitude (gpVec);
72   return V; 
73 }
74
75
76 //=======================================================================
77 //function : SetCoord
78 //purpose  : 
79 //=======================================================================
80
81 void Geom_VectorWithMagnitude::SetCoord (
82 const Standard_Real X,  const Standard_Real Y,  const Standard_Real Z) { gpVec = gp_Vec (X, Y ,Z); }
83
84 //=======================================================================
85 //function : SetVec
86 //purpose  : 
87 //=======================================================================
88
89 void Geom_VectorWithMagnitude::SetVec (const gp_Vec& V) { gpVec = V; }
90
91 //=======================================================================
92 //function : SetX
93 //purpose  : 
94 //=======================================================================
95
96 void Geom_VectorWithMagnitude::SetX (const Standard_Real X) { gpVec.SetX (X); }
97
98 //=======================================================================
99 //function : SetY
100 //purpose  : 
101 //=======================================================================
102
103 void Geom_VectorWithMagnitude::SetY (const Standard_Real Y) { gpVec.SetY (Y); }
104
105 //=======================================================================
106 //function : SetZ
107 //purpose  : 
108 //=======================================================================
109
110 void Geom_VectorWithMagnitude::SetZ (const Standard_Real Z) {  gpVec.SetZ (Z); }
111
112 //=======================================================================
113 //function : Magnitude
114 //purpose  : 
115 //=======================================================================
116
117 Standard_Real Geom_VectorWithMagnitude::Magnitude () const {return gpVec.Magnitude ();}
118
119 //=======================================================================
120 //function : SquareMagnitude
121 //purpose  : 
122 //=======================================================================
123
124 Standard_Real Geom_VectorWithMagnitude::SquareMagnitude () const { 
125
126   return gpVec.SquareMagnitude ();
127 }
128
129
130 //=======================================================================
131 //function : Add
132 //purpose  : 
133 //=======================================================================
134
135 void Geom_VectorWithMagnitude::Add (const Handle(Geom_Vector)& Other) { 
136
137   gpVec.Add (Other->Vec());
138 }
139
140
141 //=======================================================================
142 //function : Added
143 //purpose  : 
144 //=======================================================================
145
146 Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Added (
147 const Handle(Geom_Vector)& Other) const { 
148
149    gp_Vec V1 = gpVec;
150    V1.Add (Other->Vec());
151    return new VectorWithMagnitude (V1);
152 }
153
154
155 //=======================================================================
156 //function : Cross
157 //purpose  : 
158 //=======================================================================
159
160 void  Geom_VectorWithMagnitude::Cross (const Handle(Geom_Vector)& Other) { 
161
162   gpVec.Cross (Other->Vec());
163 }
164
165
166
167 //=======================================================================
168 //function : Crossed
169 //purpose  : 
170 //=======================================================================
171
172 Handle(Geom_Vector) Geom_VectorWithMagnitude::Crossed (
173 const Handle(Geom_Vector)& Other) const { 
174
175   gp_Vec V (gpVec);
176   V.Cross (Other->Vec());
177   return new VectorWithMagnitude (V);
178 }
179
180
181 //=======================================================================
182 //function : CrossCross
183 //purpose  : 
184 //=======================================================================
185
186 void Geom_VectorWithMagnitude::CrossCross (
187 const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) {
188
189   gpVec.CrossCross (V1->Vec(), V2->Vec());
190 }
191
192
193 //=======================================================================
194 //function : CrossCrossed
195 //purpose  : 
196 //=======================================================================
197
198 Handle(Geom_Vector) Geom_VectorWithMagnitude::CrossCrossed (
199 const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) const { 
200
201   gp_Vec V (gpVec);
202   V.CrossCross (V1->Vec(), V2->Vec());
203   return new VectorWithMagnitude (V);
204 }
205
206
207 //=======================================================================
208 //function : Divide
209 //purpose  : 
210 //=======================================================================
211
212 void Geom_VectorWithMagnitude::Divide (const Standard_Real Scalar) { 
213
214   gpVec.Divide (Scalar);
215 }
216
217
218 //=======================================================================
219 //function : Divided
220 //purpose  : 
221 //=======================================================================
222
223 Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Divided (
224 const Standard_Real Scalar) const { 
225
226   gp_Vec V (gpVec);
227   V.Divide (Scalar);
228   return new VectorWithMagnitude (V);
229 }
230
231
232 //=======================================================================
233 //function : Multiplied
234 //purpose  : 
235 //=======================================================================
236
237 Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Multiplied (
238 const Standard_Real Scalar) const { 
239
240   gp_Vec V (gpVec);
241   V.Multiply (Scalar);
242   return new VectorWithMagnitude (V);
243 }
244
245
246 //=======================================================================
247 //function : Multiply
248 //purpose  : 
249 //=======================================================================
250
251 void Geom_VectorWithMagnitude::Multiply (const Standard_Real Scalar) { 
252
253   gpVec.Multiply (Scalar);
254 }
255
256
257 //=======================================================================
258 //function : Normalize
259 //purpose  : 
260 //=======================================================================
261
262 void Geom_VectorWithMagnitude::Normalize () { gpVec.Normalize (); }
263
264
265 //=======================================================================
266 //function : Normalized
267 //purpose  : 
268 //=======================================================================
269
270 Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Normalized () const { 
271
272   gp_Vec V (gpVec);
273   V.Normalize ();
274   return new VectorWithMagnitude (V);
275 }
276
277
278 //=======================================================================
279 //function : Subtract
280 //purpose  : 
281 //=======================================================================
282
283 void Geom_VectorWithMagnitude::Subtract (const Handle(Geom_Vector)& Other) { 
284
285   gpVec.Subtract (Other->Vec());
286 }
287
288
289 //=======================================================================
290 //function : Subtracted
291 //purpose  : 
292 //=======================================================================
293
294 Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Subtracted (
295 const Handle(Geom_Vector)& Other) const { 
296
297   gp_Vec V (gpVec);
298   V.Subtract (Other->Vec());
299   return new VectorWithMagnitude (V);
300 }
301
302
303
304 //=======================================================================
305 //function : Transform
306 //purpose  : 
307 //=======================================================================
308
309 void Geom_VectorWithMagnitude::Transform (const Trsf& T) { 
310
311   gpVec.Transform (T);
312 }