0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / Geom / Geom_Direction.cxx
CommitLineData
b311480e 1// Created on: 1993-03-10
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
42cf5bc1 17
18#include <Geom_Direction.hxx>
19#include <Geom_Geometry.hxx>
20#include <Geom_Vector.hxx>
7fd59977 21#include <gp.hxx>
42cf5bc1 22#include <gp_Dir.hxx>
23#include <gp_Trsf.hxx>
7fd59977 24#include <Standard_ConstructionError.hxx>
42cf5bc1 25#include <Standard_Type.hxx>
7fd59977 26
92efcf78 27IMPLEMENT_STANDARD_RTTIEXT(Geom_Direction,Geom_Vector)
28
7fd59977 29typedef Geom_Direction Direction;
7fd59977 30typedef Geom_Vector Vector;
7fd59977 31typedef gp_Ax1 Ax1;
32typedef gp_Ax2 Ax2;
33typedef gp_Pnt Pnt;
34typedef gp_Trsf Trsf;
35
36
37
38//=======================================================================
39//function : Copy
40//purpose :
41//=======================================================================
42
43Handle(Geom_Geometry) Geom_Direction::Copy() const {
44
c04c30b3 45 Handle(Geom_Direction) D;
7fd59977 46 D = new Direction (gpVec);
47 return D;
48}
49
50//=======================================================================
51//function : Geom_Direction
52//purpose :
53//=======================================================================
54
55Geom_Direction::Geom_Direction (const Standard_Real X, const Standard_Real Y, const Standard_Real Z) {
56
57 Standard_Real D = sqrt (X * X + Y * Y + Z * Z);
2d2b3d53 58 Standard_ConstructionError_Raise_if (D <= gp::Resolution(),
59 "Geom_Direction() - input vector has zero length");
7fd59977 60 gpVec = gp_Vec (X/D, Y/D, Z/D);
61}
62
63Geom_Direction::Geom_Direction (const gp_Dir& V) { gpVec = V; }
64
65void Geom_Direction::SetDir (const gp_Dir& V) { gpVec = V; }
66
67gp_Dir Geom_Direction::Dir () const { return gpVec; }
68
69Standard_Real Geom_Direction::Magnitude () const { return 1.0; }
70
71Standard_Real Geom_Direction::SquareMagnitude () const { return 1.0; }
72
73void Geom_Direction::SetCoord (const Standard_Real X, const Standard_Real Y, const Standard_Real Z) {
74
75 Standard_Real D = Sqrt (X * X + Y * Y + Z * Z);
2d2b3d53 76 Standard_ConstructionError_Raise_if (D <= gp::Resolution(),
77 "Geom_Direction::SetCoord() - input vector has zero length");
7fd59977 78 gpVec = gp_Vec(X/D, Y/D, Z/D);
79}
80
81
82void Geom_Direction::SetX (const Standard_Real X) {
83
84 Standard_Real D = Sqrt (X * X + gpVec.Y() * gpVec.Y() + gpVec.Z() * gpVec.Z());
2d2b3d53 85 Standard_ConstructionError_Raise_if (D <= gp::Resolution(),
86 "Geom_Direction::SetX() - input vector has zero length");
7fd59977 87 gpVec = gp_Vec (X/D, gpVec.Y()/D, gpVec.Z()/D);
88}
89
90
91void Geom_Direction::SetY (const Standard_Real Y) {
92
93 Standard_Real D = Sqrt (gpVec.X() * gpVec.X() + Y * Y + gpVec.Z() * gpVec.Z());
2d2b3d53 94 Standard_ConstructionError_Raise_if (D <= gp::Resolution(),
95 "Geom_Direction::SetY() - input vector has zero length");
7fd59977 96 gpVec = gp_Vec (gpVec.X()/D, Y/D, gpVec.Z()/D);
97}
98
99
100void Geom_Direction::SetZ (const Standard_Real Z) {
101
102 Standard_Real D = Sqrt (gpVec.X() * gpVec.X() + gpVec.Y() * gpVec.Y() + Z * Z);
2d2b3d53 103 Standard_ConstructionError_Raise_if (D <= gp::Resolution(),
104 "Geom_Direction::SetZ() - input vector has zero length");
7fd59977 105 gpVec = gp_Vec (gpVec.X()/D, gpVec.Y()/D, Z/D);
106}
107
108
c04c30b3 109void Geom_Direction::Cross (const Handle(Geom_Vector)& Other) {
7fd59977 110
111 gp_Dir V (gpVec.Crossed(Other->Vec()));
112 gpVec = V;
113}
114
115
116void Geom_Direction::CrossCross (
c04c30b3 117const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) {
7fd59977 118
119 gp_Dir V (gpVec.CrossCrossed (V1->Vec(), V2->Vec()));
120 gpVec = V;
121}
122
123
c04c30b3 124Handle(Geom_Vector) Geom_Direction::Crossed (const Handle(Geom_Vector)& Other)
7fd59977 125const {
126
127 gp_Dir V (gpVec.Crossed (Other->Vec()));
128 return new Direction (V);
129}
130
131
c04c30b3 132Handle(Geom_Vector) Geom_Direction::CrossCrossed (
133const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) const {
7fd59977 134
135 gp_Dir V (gpVec.CrossCrossed (V1->Vec(), V2->Vec()));
136 return new Direction (V);
137}
138
139
140void Geom_Direction::Transform (const gp_Trsf& T) {
141
142 gp_Dir V (gpVec);
143 V.Transform (T);
144 gpVec = V;
145}