0022820: OCCT IGES writer loses plane information
[occt.git] / src / GeomToIGES / GeomToIGES_GeomVector.cxx
1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
2 //
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
7 //
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10 //
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
17
18
19 // modif du 14/09/95 mjm
20 // prise en compte de l'unite choisi par l'utilisateur
21 // pour l'ecriture du fichier IGES.
22
23 #include <GeomToIGES_GeomVector.ixx>
24
25 #include <Geom_Vector.hxx>
26 #include <Geom_VectorWithMagnitude.hxx>
27 #include <Geom_Direction.hxx>
28
29 #include <gp_Dir.hxx>
30 #include <gp_GTrsf.hxx>
31 #include <gp_Pnt.hxx>
32 #include <gp_Trsf.hxx>
33 #include <gp_XYZ.hxx>
34
35 #include <IGESData_IGESEntity.hxx>
36 #include <IGESData_ToolLocation.hxx>
37
38 #include <IGESGeom_CopiousData.hxx>
39 #include <IGESGeom_Line.hxx>
40 #include <IGESGeom_Point.hxx>
41
42 #include <Interface_Macros.hxx>
43
44
45
46 //=============================================================================
47 // GeomToIGES_GeomVector
48 //=============================================================================
49
50 GeomToIGES_GeomVector::GeomToIGES_GeomVector()
51 :GeomToIGES_GeomEntity()
52 {
53 }
54
55
56 //=============================================================================
57 // GeomToIGES_GeomVector
58 //=============================================================================
59
60 GeomToIGES_GeomVector::GeomToIGES_GeomVector
61 (const GeomToIGES_GeomEntity& GE)
62 :GeomToIGES_GeomEntity(GE)
63 {
64 }
65
66
67 //=============================================================================
68 // Transfer des Entites Vector de Geom vers IGES
69 // TransferVector
70 //=============================================================================
71
72 Handle(IGESGeom_Direction) GeomToIGES_GeomVector::TransferVector
73 (const Handle(Geom_Vector)& start)
74 {
75   Handle(IGESGeom_Direction) res;
76   if (start.IsNull()) {
77     return res;
78   }
79
80   if (start->IsKind(STANDARD_TYPE(Geom_VectorWithMagnitude))) {
81     DeclareAndCast(Geom_VectorWithMagnitude, VMagn, start);
82     res = TransferVector(VMagn);
83   }
84   else if (start->IsKind(STANDARD_TYPE(Geom_Direction))) {
85     DeclareAndCast(Geom_Direction, Direction, start);
86     res = TransferVector(Direction);
87   }
88
89   return res;
90 }
91  
92
93 //=============================================================================
94 // Transfer des Entites VectorWithMagnitude de Geom vers IGES
95 // TransferVector
96 //=============================================================================
97
98 Handle(IGESGeom_Direction) GeomToIGES_GeomVector::TransferVector
99 (const Handle(Geom_VectorWithMagnitude)& start)
100 {
101   Handle(IGESGeom_Direction) Dir = new IGESGeom_Direction;
102   if (start.IsNull()) {
103     return Dir;
104   }
105
106   Standard_Real X,Y,Z;
107   start->Coord(X,Y,Z); 
108   Standard_Real M = start->Magnitude();
109   Dir->Init(gp_XYZ(X/(M*GetUnit()),Y/(M*GetUnit()),Z/(M*GetUnit())));
110   return Dir;
111 }
112  
113
114 //=============================================================================
115 // Transfer des Entites Direction de Geom vers IGES
116 // TransferVector
117 //=============================================================================
118
119 Handle(IGESGeom_Direction) GeomToIGES_GeomVector::TransferVector
120 (const Handle(Geom_Direction)& start)
121 {
122   Handle(IGESGeom_Direction) Dir = new IGESGeom_Direction;
123   if (start.IsNull()) {
124     return Dir;
125   }
126
127   Standard_Real X,Y,Z;
128   start->Coord(X,Y,Z);
129   Dir->Init(gp_XYZ(X/GetUnit(),Y/GetUnit(),Z/GetUnit()));
130   return Dir;
131 }