1 // Created on: 1993-03-10
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Geom_Geometry.hxx>
19 #include <Geom_Vector.hxx>
20 #include <Geom_VectorWithMagnitude.hxx>
22 #include <gp_Trsf.hxx>
24 #include <Standard_ConstructionError.hxx>
25 #include <Standard_Type.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(Geom_VectorWithMagnitude,Geom_Vector)
29 typedef Geom_VectorWithMagnitude VectorWithMagnitude;
30 typedef Geom_Vector Vector;
36 //=======================================================================
37 //function : Geom_VectorWithMagnitude
39 //=======================================================================
41 Geom_VectorWithMagnitude::Geom_VectorWithMagnitude (const gp_Vec& V)
45 //=======================================================================
46 //function : Geom_VectorWithMagnitude
48 //=======================================================================
50 Geom_VectorWithMagnitude::Geom_VectorWithMagnitude (
51 const Standard_Real X, const Standard_Real Y, const Standard_Real Z) { gpVec = gp_Vec (X, Y, Z); }
54 //=======================================================================
55 //function : Geom_VectorWithMagnitude
57 //=======================================================================
59 Geom_VectorWithMagnitude::Geom_VectorWithMagnitude (
60 const Pnt& P1, const Pnt& P2) { gpVec = gp_Vec (P1, P2); }
63 //=======================================================================
66 //=======================================================================
68 Handle(Geom_Geometry) Geom_VectorWithMagnitude::Copy() const {
70 Handle(Geom_VectorWithMagnitude) V;
71 V = new VectorWithMagnitude (gpVec);
76 //=======================================================================
79 //=======================================================================
81 void Geom_VectorWithMagnitude::SetCoord (
82 const Standard_Real X, const Standard_Real Y, const Standard_Real Z) { gpVec = gp_Vec (X, Y ,Z); }
84 //=======================================================================
87 //=======================================================================
89 void Geom_VectorWithMagnitude::SetVec (const gp_Vec& V) { gpVec = V; }
91 //=======================================================================
94 //=======================================================================
96 void Geom_VectorWithMagnitude::SetX (const Standard_Real X) { gpVec.SetX (X); }
98 //=======================================================================
101 //=======================================================================
103 void Geom_VectorWithMagnitude::SetY (const Standard_Real Y) { gpVec.SetY (Y); }
105 //=======================================================================
108 //=======================================================================
110 void Geom_VectorWithMagnitude::SetZ (const Standard_Real Z) { gpVec.SetZ (Z); }
112 //=======================================================================
113 //function : Magnitude
115 //=======================================================================
117 Standard_Real Geom_VectorWithMagnitude::Magnitude () const {return gpVec.Magnitude ();}
119 //=======================================================================
120 //function : SquareMagnitude
122 //=======================================================================
124 Standard_Real Geom_VectorWithMagnitude::SquareMagnitude () const {
126 return gpVec.SquareMagnitude ();
130 //=======================================================================
133 //=======================================================================
135 void Geom_VectorWithMagnitude::Add (const Handle(Geom_Vector)& Other) {
137 gpVec.Add (Other->Vec());
141 //=======================================================================
144 //=======================================================================
146 Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Added (
147 const Handle(Geom_Vector)& Other) const {
150 V1.Add (Other->Vec());
151 return new VectorWithMagnitude (V1);
155 //=======================================================================
158 //=======================================================================
160 void Geom_VectorWithMagnitude::Cross (const Handle(Geom_Vector)& Other) {
162 gpVec.Cross (Other->Vec());
167 //=======================================================================
170 //=======================================================================
172 Handle(Geom_Vector) Geom_VectorWithMagnitude::Crossed (
173 const Handle(Geom_Vector)& Other) const {
176 V.Cross (Other->Vec());
177 return new VectorWithMagnitude (V);
181 //=======================================================================
182 //function : CrossCross
184 //=======================================================================
186 void Geom_VectorWithMagnitude::CrossCross (
187 const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) {
189 gpVec.CrossCross (V1->Vec(), V2->Vec());
193 //=======================================================================
194 //function : CrossCrossed
196 //=======================================================================
198 Handle(Geom_Vector) Geom_VectorWithMagnitude::CrossCrossed (
199 const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) const {
202 V.CrossCross (V1->Vec(), V2->Vec());
203 return new VectorWithMagnitude (V);
207 //=======================================================================
210 //=======================================================================
212 void Geom_VectorWithMagnitude::Divide (const Standard_Real Scalar) {
214 gpVec.Divide (Scalar);
218 //=======================================================================
221 //=======================================================================
223 Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Divided (
224 const Standard_Real Scalar) const {
228 return new VectorWithMagnitude (V);
232 //=======================================================================
233 //function : Multiplied
235 //=======================================================================
237 Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Multiplied (
238 const Standard_Real Scalar) const {
242 return new VectorWithMagnitude (V);
246 //=======================================================================
247 //function : Multiply
249 //=======================================================================
251 void Geom_VectorWithMagnitude::Multiply (const Standard_Real Scalar) {
253 gpVec.Multiply (Scalar);
257 //=======================================================================
258 //function : Normalize
260 //=======================================================================
262 void Geom_VectorWithMagnitude::Normalize () { gpVec.Normalize (); }
265 //=======================================================================
266 //function : Normalized
268 //=======================================================================
270 Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Normalized () const {
274 return new VectorWithMagnitude (V);
278 //=======================================================================
279 //function : Subtract
281 //=======================================================================
283 void Geom_VectorWithMagnitude::Subtract (const Handle(Geom_Vector)& Other) {
285 gpVec.Subtract (Other->Vec());
289 //=======================================================================
290 //function : Subtracted
292 //=======================================================================
294 Handle(Geom_VectorWithMagnitude) Geom_VectorWithMagnitude::Subtracted (
295 const Handle(Geom_Vector)& Other) const {
298 V.Subtract (Other->Vec());
299 return new VectorWithMagnitude (V);
304 //=======================================================================
305 //function : Transform
307 //=======================================================================
309 void Geom_VectorWithMagnitude::Transform (const Trsf& T) {