0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / GeomToStep / GeomToStep_MakeDirection.cxx
CommitLineData
b311480e 1// Created on: 1993-06-17
2// Created by: Martine LANGLOIS
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 <Geom2d_Direction.hxx>
19#include <Geom_Direction.hxx>
20#include <GeomToStep_MakeDirection.hxx>
7fd59977 21#include <gp_Dir.hxx>
22#include <gp_Dir2d.hxx>
42cf5bc1 23#include <StdFail_NotDone.hxx>
7fd59977 24#include <StepGeom_Direction.hxx>
7fd59977 25#include <TCollection_HAsciiString.hxx>
42cf5bc1 26#include <TColStd_HArray1OfReal.hxx>
7fd59977 27
28//=============================================================================
29// Creation d' une direction de prostep a partir d' une Dir de gp
30//=============================================================================
7fd59977 31GeomToStep_MakeDirection::GeomToStep_MakeDirection( const gp_Dir& D)
32{
33 Handle(StepGeom_Direction) Dir = new StepGeom_Direction;
34 Handle(TColStd_HArray1OfReal) aDirRatios = new TColStd_HArray1OfReal(1,3);
35 Standard_Real X, Y, Z;
36
37 D.Coord(X, Y, Z);
38 aDirRatios->SetValue(1,X);
39 aDirRatios->SetValue(2,Y);
40 aDirRatios->SetValue(3,Z);
41 Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
42 Dir->Init(name, aDirRatios);
43 theDirection = Dir;
44 done = Standard_True;
45}
46//=============================================================================
47// Creation d' une direction de prostep a partir d' une Dir2d de gp
48//=============================================================================
49
50GeomToStep_MakeDirection::GeomToStep_MakeDirection( const gp_Dir2d& D)
51{
52 Handle(StepGeom_Direction) Dir = new StepGeom_Direction;
53 Handle(TColStd_HArray1OfReal) aDirRatios = new TColStd_HArray1OfReal(1,2);
54 Standard_Real X, Y;
55
56 D.Coord(X, Y);
57 aDirRatios->SetValue(1,X);
58 aDirRatios->SetValue(2,Y);
59 Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
60 Dir->Init(name, aDirRatios);
61 theDirection = Dir;
62 done = Standard_True;
63}
64
65//=============================================================================
66// Creation d' une direction de prostep a partir d' une Direction de Geom
67//=============================================================================
68
69GeomToStep_MakeDirection::GeomToStep_MakeDirection
70 ( const Handle(Geom_Direction)& Direc)
71{
72 gp_Dir D;
73 Handle(StepGeom_Direction) Dir = new StepGeom_Direction;
74 Handle(TColStd_HArray1OfReal) aDirRatios = new TColStd_HArray1OfReal(1,3);
75 Standard_Real X, Y, Z;
76
77 D=Direc->Dir();
78 D.Coord(X, Y, Z);
79 aDirRatios->SetValue(1,X);
80 aDirRatios->SetValue(2,Y);
81 aDirRatios->SetValue(3,Z);
82 Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
83 Dir->Init(name, aDirRatios);
84 theDirection = Dir;
85 done = Standard_True;
86
87}
88//=============================================================================
89// Creation d' une direction de prostep a partir d' une Direction de Geom2d
90//=============================================================================
91
92GeomToStep_MakeDirection::GeomToStep_MakeDirection
93 ( const Handle(Geom2d_Direction)& Direc)
94{
95 gp_Dir2d D;
96 Handle(StepGeom_Direction) Dir = new StepGeom_Direction;
97 Handle(TColStd_HArray1OfReal) aDirRatios = new TColStd_HArray1OfReal(1,2);
98 Standard_Real X, Y;
99
100 D=Direc->Dir2d();
101 D.Coord(X, Y);
102 aDirRatios->SetValue(1,X);
103 aDirRatios->SetValue(2,Y);
104 Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
105 Dir->Init(name, aDirRatios);
106 theDirection = Dir;
107 done = Standard_True;
108
109}
110
111//=============================================================================
112// renvoi des valeurs
113//=============================================================================
114
115const Handle(StepGeom_Direction) &
116 GeomToStep_MakeDirection::Value() const
117{
11bf7051 118 StdFail_NotDone_Raise_if(!done, "");
7fd59977 119 return theDirection;
120}