b311480e |
1 | // Created on: 1993-03-24 |
2 | // Created by: JCV |
3 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <Geom2d_Geometry.hxx> |
19 | #include <Geom2d_Vector.hxx> |
20 | #include <Geom2d_VectorWithMagnitude.hxx> |
21 | #include <gp_Pnt2d.hxx> |
22 | #include <gp_Trsf2d.hxx> |
23 | #include <gp_Vec2d.hxx> |
24 | #include <Standard_ConstructionError.hxx> |
25 | #include <Standard_Type.hxx> |
7fd59977 |
26 | |
27 | typedef Geom2d_Vector Vector; |
28 | typedef Geom2d_VectorWithMagnitude VectorWithMagnitude; |
7fd59977 |
29 | typedef gp_Ax2d Ax2d; |
30 | typedef gp_Pnt2d Pnt2d; |
31 | typedef gp_Trsf2d Trsf2d; |
32 | |
7fd59977 |
33 | Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (const gp_Vec2d& V) |
34 | { gpVec2d = V; } |
35 | |
36 | |
37 | Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude ( |
38 | const Standard_Real X, const Standard_Real Y) { gpVec2d = gp_Vec2d (X, Y); } |
39 | |
40 | |
41 | Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude ( |
42 | const Pnt2d& P1, const Pnt2d& P2) { gpVec2d = gp_Vec2d (P1, P2); } |
43 | |
44 | |
45 | Handle(Geom2d_Geometry) Geom2d_VectorWithMagnitude::Copy() const { |
46 | |
c04c30b3 |
47 | Handle(Geom2d_VectorWithMagnitude) V; |
7fd59977 |
48 | V = new VectorWithMagnitude (gpVec2d); |
49 | return V; |
50 | } |
51 | |
52 | |
53 | void Geom2d_VectorWithMagnitude::SetCoord (const Standard_Real X, const Standard_Real Y) { |
54 | |
55 | gpVec2d = gp_Vec2d (X, Y); |
56 | } |
57 | |
58 | |
59 | void Geom2d_VectorWithMagnitude::SetVec2d (const gp_Vec2d& V) { gpVec2d = V; } |
60 | |
61 | void Geom2d_VectorWithMagnitude::SetX (const Standard_Real X) { gpVec2d.SetX (X); } |
62 | |
63 | |
64 | void Geom2d_VectorWithMagnitude::SetY (const Standard_Real Y) { gpVec2d.SetY (Y); } |
65 | |
66 | |
67 | Standard_Real Geom2d_VectorWithMagnitude::Magnitude () const { |
68 | |
69 | return gpVec2d.Magnitude (); |
70 | } |
71 | |
72 | |
73 | Standard_Real Geom2d_VectorWithMagnitude::SquareMagnitude () const { |
74 | |
75 | return gpVec2d.SquareMagnitude (); |
76 | } |
77 | |
78 | |
c04c30b3 |
79 | void Geom2d_VectorWithMagnitude::Add (const Handle(Geom2d_Vector)& Other) { |
7fd59977 |
80 | |
81 | gpVec2d.Add (Other->Vec2d()); |
82 | } |
83 | |
84 | |
c04c30b3 |
85 | Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Added ( |
7fd59977 |
86 | |
c04c30b3 |
87 | const Handle(Geom2d_Vector)& Other) const { |
7fd59977 |
88 | |
89 | gp_Vec2d Temp = Other->Vec2d(); |
90 | Temp.Add (gpVec2d); |
91 | return new VectorWithMagnitude (Temp); |
92 | } |
93 | |
94 | |
c04c30b3 |
95 | Standard_Real Geom2d_VectorWithMagnitude::Crossed (const Handle(Geom2d_Vector)& Other) const{ |
7fd59977 |
96 | |
97 | return gpVec2d.Crossed (Other->Vec2d()); |
98 | } |
99 | |
100 | |
101 | void Geom2d_VectorWithMagnitude::Divide (const Standard_Real Scalar) { |
102 | |
103 | gpVec2d.Divide (Scalar); |
104 | } |
105 | |
106 | |
c04c30b3 |
107 | Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Divided ( |
7fd59977 |
108 | const Standard_Real Scalar) const { |
109 | |
110 | gp_Vec2d V (gpVec2d); |
111 | V.Divide (Scalar); |
112 | return new VectorWithMagnitude (V); |
113 | } |
114 | |
115 | |
c04c30b3 |
116 | Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Multiplied ( |
7fd59977 |
117 | const Standard_Real Scalar) const { |
118 | |
119 | gp_Vec2d V(gpVec2d); |
120 | V.Multiply (Scalar); |
121 | return new VectorWithMagnitude (V); |
122 | } |
123 | |
124 | |
125 | void Geom2d_VectorWithMagnitude::Multiply (const Standard_Real Scalar) { |
126 | |
127 | gpVec2d.Multiply (Scalar); |
128 | } |
129 | |
130 | |
131 | void Geom2d_VectorWithMagnitude::Normalize () { gpVec2d.Normalize (); } |
132 | |
133 | |
c04c30b3 |
134 | Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Normalized () const { |
7fd59977 |
135 | |
136 | gp_Vec2d V = gpVec2d; |
137 | V.Normalized (); |
138 | return new VectorWithMagnitude (V); |
139 | } |
140 | |
141 | |
c04c30b3 |
142 | void Geom2d_VectorWithMagnitude::Subtract (const Handle(Geom2d_Vector)& Other) { |
7fd59977 |
143 | |
144 | gpVec2d.Subtract (Other->Vec2d()); |
145 | } |
146 | |
147 | |
c04c30b3 |
148 | Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Subtracted ( |
149 | const Handle(Geom2d_Vector)& Other) const { |
7fd59977 |
150 | |
151 | gp_Vec2d V = gpVec2d; |
152 | V.Subtract (Other->Vec2d()); |
153 | return new VectorWithMagnitude (V); |
154 | } |
155 | |
156 | |
157 | |
158 | void Geom2d_VectorWithMagnitude::Transform (const Trsf2d& T) { |
159 | |
160 | gpVec2d.Transform (T); |
161 | } |