0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / Geom2dToIGES / Geom2dToIGES_Geom2dVector.cxx
CommitLineData
b311480e 1// Created on: 1995-02-01
2// Created by: Marie Jose MARTZ
3// Copyright (c) 1995-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_Direction.hxx>
7fd59977 19#include <Geom2d_Vector.hxx>
20#include <Geom2d_VectorWithMagnitude.hxx>
42cf5bc1 21#include <Geom2dToIGES_Geom2dEntity.hxx>
22#include <Geom2dToIGES_Geom2dVector.hxx>
7fd59977 23#include <gp_XYZ.hxx>
7fd59977 24#include <IGESGeom_Direction.hxx>
7fd59977 25#include <Interface_Macros.hxx>
26
27//=============================================================================
28// Geom2dToIGES_Geom2dVector
29//=============================================================================
7fd59977 30Geom2dToIGES_Geom2dVector::Geom2dToIGES_Geom2dVector()
31:Geom2dToIGES_Geom2dEntity()
32{
33}
34
35
36//=============================================================================
37// Geom2dToIGES_Geom2dVector
38//=============================================================================
39
40Geom2dToIGES_Geom2dVector::Geom2dToIGES_Geom2dVector
41(const Geom2dToIGES_Geom2dEntity& G2dE)
42:Geom2dToIGES_Geom2dEntity(G2dE)
43{
44}
45
46
47//=============================================================================
48// Transfer des Entites Vector de Geom2d vers IGES
49// Transfer2dVector
50//=============================================================================
51
52Handle(IGESGeom_Direction) Geom2dToIGES_Geom2dVector::Transfer2dVector
53(const Handle(Geom2d_Vector)& start)
54{
55 Handle(IGESGeom_Direction) res;
56 if (start.IsNull()) {
57 return res;
58 }
59
60 if (start->IsKind(STANDARD_TYPE(Geom2d_VectorWithMagnitude))) {
61 DeclareAndCast(Geom2d_VectorWithMagnitude, VMagn, start);
62 res = Transfer2dVector(VMagn);
63 }
64 else if (start->IsKind(STANDARD_TYPE(Geom2d_Direction))) {
65 DeclareAndCast(Geom2d_Direction, Direction, start);
66 res = Transfer2dVector(Direction);
67 }
68
69 return res;
70}
71
72
73//=============================================================================
74// Transfer des Entites VectorWithMagnitude de Geom2d vers IGES
75// Transfer2dVector
76//=============================================================================
77
78Handle(IGESGeom_Direction) Geom2dToIGES_Geom2dVector::Transfer2dVector
79(const Handle(Geom2d_VectorWithMagnitude)& start)
80{
81 Handle(IGESGeom_Direction) Dir = new IGESGeom_Direction;
82 if (start.IsNull()) {
83 return Dir;
84 }
85
86 Standard_Real X,Y;
87 start->Coord(X,Y);
88 Standard_Real M = start->Magnitude();
89 Dir->Init(gp_XYZ(X/M, Y/M, 0.));
90 return Dir;
91}
92
93
94//=============================================================================
95// Transfer des Entites Direction de Geom2d vers IGES
96// Transfer2dVector
97//=============================================================================
98
99Handle(IGESGeom_Direction) Geom2dToIGES_Geom2dVector::Transfer2dVector
100(const Handle(Geom2d_Direction)& start)
101{
102 Handle(IGESGeom_Direction) Dir = new IGESGeom_Direction;
103 if (start.IsNull()) {
104 return Dir;
105 }
106
107 Standard_Real X,Y;
108 start->Coord(X,Y);
109 Dir->Init(gp_XYZ(X, Y, 0.));
110 return Dir;
111}