0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / Geom2d / Geom2d_VectorWithMagnitude.cxx
CommitLineData
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
92efcf78 27IMPLEMENT_STANDARD_RTTIEXT(Geom2d_VectorWithMagnitude,Geom2d_Vector)
28
7fd59977 29typedef Geom2d_Vector Vector;
30typedef Geom2d_VectorWithMagnitude VectorWithMagnitude;
7fd59977 31typedef gp_Ax2d Ax2d;
32typedef gp_Pnt2d Pnt2d;
33typedef gp_Trsf2d Trsf2d;
34
7fd59977 35Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (const gp_Vec2d& V)
36{ gpVec2d = V; }
37
38
39Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (
40const Standard_Real X, const Standard_Real Y) { gpVec2d = gp_Vec2d (X, Y); }
41
42
43Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (
44const Pnt2d& P1, const Pnt2d& P2) { gpVec2d = gp_Vec2d (P1, P2); }
45
46
47Handle(Geom2d_Geometry) Geom2d_VectorWithMagnitude::Copy() const {
48
c04c30b3 49 Handle(Geom2d_VectorWithMagnitude) V;
7fd59977 50 V = new VectorWithMagnitude (gpVec2d);
51 return V;
52}
53
54
55void Geom2d_VectorWithMagnitude::SetCoord (const Standard_Real X, const Standard_Real Y) {
56
57 gpVec2d = gp_Vec2d (X, Y);
58}
59
60
61void Geom2d_VectorWithMagnitude::SetVec2d (const gp_Vec2d& V) { gpVec2d = V; }
62
63void Geom2d_VectorWithMagnitude::SetX (const Standard_Real X) { gpVec2d.SetX (X); }
64
65
66void Geom2d_VectorWithMagnitude::SetY (const Standard_Real Y) { gpVec2d.SetY (Y); }
67
68
69Standard_Real Geom2d_VectorWithMagnitude::Magnitude () const {
70
71 return gpVec2d.Magnitude ();
72}
73
74
75Standard_Real Geom2d_VectorWithMagnitude::SquareMagnitude () const {
76
77 return gpVec2d.SquareMagnitude ();
78}
79
80
c04c30b3 81void Geom2d_VectorWithMagnitude::Add (const Handle(Geom2d_Vector)& Other) {
7fd59977 82
83 gpVec2d.Add (Other->Vec2d());
84}
85
86
c04c30b3 87Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Added (
7fd59977 88
c04c30b3 89const Handle(Geom2d_Vector)& Other) const {
7fd59977 90
91 gp_Vec2d Temp = Other->Vec2d();
92 Temp.Add (gpVec2d);
93 return new VectorWithMagnitude (Temp);
94}
95
96
c04c30b3 97Standard_Real Geom2d_VectorWithMagnitude::Crossed (const Handle(Geom2d_Vector)& Other) const{
7fd59977 98
99 return gpVec2d.Crossed (Other->Vec2d());
100}
101
102
103void Geom2d_VectorWithMagnitude::Divide (const Standard_Real Scalar) {
104
105 gpVec2d.Divide (Scalar);
106}
107
108
c04c30b3 109Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Divided (
7fd59977 110const Standard_Real Scalar) const {
111
112 gp_Vec2d V (gpVec2d);
113 V.Divide (Scalar);
114 return new VectorWithMagnitude (V);
115}
116
117
c04c30b3 118Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Multiplied (
7fd59977 119const Standard_Real Scalar) const {
120
121 gp_Vec2d V(gpVec2d);
122 V.Multiply (Scalar);
123 return new VectorWithMagnitude (V);
124}
125
126
127void Geom2d_VectorWithMagnitude::Multiply (const Standard_Real Scalar) {
128
129 gpVec2d.Multiply (Scalar);
130}
131
132
133void Geom2d_VectorWithMagnitude::Normalize () { gpVec2d.Normalize (); }
134
135
c04c30b3 136Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Normalized () const {
7fd59977 137
0be7dbe1 138 gp_Vec2d V = gpVec2d.Normalized();
7fd59977 139 return new VectorWithMagnitude (V);
140}
141
142
c04c30b3 143void Geom2d_VectorWithMagnitude::Subtract (const Handle(Geom2d_Vector)& Other) {
7fd59977 144
145 gpVec2d.Subtract (Other->Vec2d());
146}
147
148
c04c30b3 149Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Subtracted (
150const Handle(Geom2d_Vector)& Other) const {
7fd59977 151
152 gp_Vec2d V = gpVec2d;
153 V.Subtract (Other->Vec2d());
154 return new VectorWithMagnitude (V);
155}
156
157
158
159void Geom2d_VectorWithMagnitude::Transform (const Trsf2d& T) {
160
161 gpVec2d.Transform (T);
162}