Integration of OCCT 6.5.0 from SVN
[occt.git] / src / GeomToStep / GeomToStep_MakeDirection.cxx
1 // File:        GeomToStep_MakeDirection.cxx
2 // Created:     Thu Jun 17 10:41:50 1993
3 // Author:      Martine LANGLOIS
4 //              <mla@mastox>
5
6 #include <GeomToStep_MakeDirection.ixx>
7 #include <StdFail_NotDone.hxx>
8 #include <gp_Dir.hxx>
9 #include <gp_Dir2d.hxx>
10 #include <Geom_Direction.hxx>
11 #include <Geom2d_Direction.hxx>
12 #include <StepGeom_Direction.hxx>
13 #include <TColStd_HArray1OfReal.hxx>
14 #include <TCollection_HAsciiString.hxx>
15
16 //=============================================================================
17 // Creation d' une direction de prostep a partir d' une Dir de gp
18 //=============================================================================
19
20 GeomToStep_MakeDirection::GeomToStep_MakeDirection( const gp_Dir& D)
21 {
22   Handle(StepGeom_Direction) Dir = new StepGeom_Direction;
23   Handle(TColStd_HArray1OfReal) aDirRatios = new TColStd_HArray1OfReal(1,3);
24   Standard_Real X, Y, Z;
25
26   D.Coord(X, Y, Z);
27   aDirRatios->SetValue(1,X);
28   aDirRatios->SetValue(2,Y);
29   aDirRatios->SetValue(3,Z);
30   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
31   Dir->Init(name, aDirRatios);
32   theDirection = Dir;
33   done = Standard_True;
34 }
35 //=============================================================================
36 // Creation d' une direction de prostep a partir d' une Dir2d de gp
37 //=============================================================================
38
39 GeomToStep_MakeDirection::GeomToStep_MakeDirection( const gp_Dir2d& D)
40 {
41   Handle(StepGeom_Direction) Dir = new StepGeom_Direction;
42   Handle(TColStd_HArray1OfReal) aDirRatios = new TColStd_HArray1OfReal(1,2);
43   Standard_Real X, Y;
44
45   D.Coord(X, Y);
46   aDirRatios->SetValue(1,X);
47   aDirRatios->SetValue(2,Y);
48   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
49   Dir->Init(name, aDirRatios);
50   theDirection = Dir;
51   done = Standard_True;
52 }
53
54 //=============================================================================
55 // Creation d' une direction de prostep a partir d' une Direction de Geom
56 //=============================================================================
57
58 GeomToStep_MakeDirection::GeomToStep_MakeDirection
59   ( const Handle(Geom_Direction)& Direc)
60 {
61   gp_Dir D;
62   Handle(StepGeom_Direction) Dir = new StepGeom_Direction;
63   Handle(TColStd_HArray1OfReal) aDirRatios = new TColStd_HArray1OfReal(1,3);
64   Standard_Real X, Y, Z;
65
66   D=Direc->Dir();
67   D.Coord(X, Y, Z);
68   aDirRatios->SetValue(1,X);
69   aDirRatios->SetValue(2,Y);
70   aDirRatios->SetValue(3,Z);
71   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
72   Dir->Init(name, aDirRatios);
73   theDirection = Dir;
74   done = Standard_True;
75
76 }
77 //=============================================================================
78 // Creation d' une direction de prostep a partir d' une Direction de Geom2d
79 //=============================================================================
80
81 GeomToStep_MakeDirection::GeomToStep_MakeDirection
82   ( const Handle(Geom2d_Direction)& Direc)
83 {
84   gp_Dir2d D;
85   Handle(StepGeom_Direction) Dir = new StepGeom_Direction;
86   Handle(TColStd_HArray1OfReal) aDirRatios = new TColStd_HArray1OfReal(1,2);
87   Standard_Real X, Y;
88
89   D=Direc->Dir2d();
90   D.Coord(X, Y);
91   aDirRatios->SetValue(1,X);
92   aDirRatios->SetValue(2,Y);
93   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
94   Dir->Init(name, aDirRatios);
95   theDirection = Dir;
96   done = Standard_True;
97
98 }
99
100 //=============================================================================
101 // renvoi des valeurs
102 //=============================================================================
103
104 const Handle(StepGeom_Direction) &
105       GeomToStep_MakeDirection::Value() const
106 {
107   StdFail_NotDone_Raise_if(!done == Standard_True,"");
108   return theDirection;
109 }