973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
7fd59977 |
13 | |
14 | // modif du 14/09/95 mjm |
15 | // prise en compte de l'unite choisi par l'utilisateur |
16 | // pour l'ecriture du fichier IGES. |
17 | |
18 | #include <GeomToIGES_GeomVector.ixx> |
19 | |
20 | #include <Geom_Vector.hxx> |
21 | #include <Geom_VectorWithMagnitude.hxx> |
22 | #include <Geom_Direction.hxx> |
23 | |
24 | #include <gp_Dir.hxx> |
25 | #include <gp_GTrsf.hxx> |
26 | #include <gp_Pnt.hxx> |
27 | #include <gp_Trsf.hxx> |
28 | #include <gp_XYZ.hxx> |
29 | |
30 | #include <IGESData_IGESEntity.hxx> |
31 | #include <IGESData_ToolLocation.hxx> |
32 | |
33 | #include <IGESGeom_CopiousData.hxx> |
34 | #include <IGESGeom_Line.hxx> |
35 | #include <IGESGeom_Point.hxx> |
36 | |
37 | #include <Interface_Macros.hxx> |
b311480e |
38 | |
7fd59977 |
39 | |
40 | |
41 | //============================================================================= |
42 | // GeomToIGES_GeomVector |
43 | //============================================================================= |
44 | |
45 | GeomToIGES_GeomVector::GeomToIGES_GeomVector() |
46 | :GeomToIGES_GeomEntity() |
47 | { |
48 | } |
49 | |
50 | |
51 | //============================================================================= |
52 | // GeomToIGES_GeomVector |
53 | //============================================================================= |
54 | |
55 | GeomToIGES_GeomVector::GeomToIGES_GeomVector |
56 | (const GeomToIGES_GeomEntity& GE) |
57 | :GeomToIGES_GeomEntity(GE) |
58 | { |
59 | } |
60 | |
61 | |
62 | //============================================================================= |
63 | // Transfer des Entites Vector de Geom vers IGES |
64 | // TransferVector |
65 | //============================================================================= |
66 | |
67 | Handle(IGESGeom_Direction) GeomToIGES_GeomVector::TransferVector |
68 | (const Handle(Geom_Vector)& start) |
69 | { |
70 | Handle(IGESGeom_Direction) res; |
71 | if (start.IsNull()) { |
72 | return res; |
73 | } |
74 | |
75 | if (start->IsKind(STANDARD_TYPE(Geom_VectorWithMagnitude))) { |
76 | DeclareAndCast(Geom_VectorWithMagnitude, VMagn, start); |
77 | res = TransferVector(VMagn); |
78 | } |
79 | else if (start->IsKind(STANDARD_TYPE(Geom_Direction))) { |
80 | DeclareAndCast(Geom_Direction, Direction, start); |
81 | res = TransferVector(Direction); |
82 | } |
83 | |
84 | return res; |
85 | } |
86 | |
87 | |
88 | //============================================================================= |
89 | // Transfer des Entites VectorWithMagnitude de Geom vers IGES |
90 | // TransferVector |
91 | //============================================================================= |
92 | |
93 | Handle(IGESGeom_Direction) GeomToIGES_GeomVector::TransferVector |
94 | (const Handle(Geom_VectorWithMagnitude)& start) |
95 | { |
96 | Handle(IGESGeom_Direction) Dir = new IGESGeom_Direction; |
97 | if (start.IsNull()) { |
98 | return Dir; |
99 | } |
100 | |
101 | Standard_Real X,Y,Z; |
102 | start->Coord(X,Y,Z); |
103 | Standard_Real M = start->Magnitude(); |
104 | Dir->Init(gp_XYZ(X/(M*GetUnit()),Y/(M*GetUnit()),Z/(M*GetUnit()))); |
105 | return Dir; |
106 | } |
107 | |
108 | |
109 | //============================================================================= |
110 | // Transfer des Entites Direction de Geom vers IGES |
111 | // TransferVector |
112 | //============================================================================= |
113 | |
114 | Handle(IGESGeom_Direction) GeomToIGES_GeomVector::TransferVector |
115 | (const Handle(Geom_Direction)& start) |
116 | { |
117 | Handle(IGESGeom_Direction) Dir = new IGESGeom_Direction; |
118 | if (start.IsNull()) { |
119 | return Dir; |
120 | } |
121 | |
122 | Standard_Real X,Y,Z; |
123 | start->Coord(X,Y,Z); |
124 | Dir->Init(gp_XYZ(X/GetUnit(),Y/GetUnit(),Z/GetUnit())); |
125 | return Dir; |
126 | } |