0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / GeomToStep / GeomToStep_MakeCartesianPoint.cxx
1 // Created on: 1993-06-15
2 // Created by: Martine LANGLOIS
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Geom2d_CartesianPoint.hxx>
19 #include <Geom_CartesianPoint.hxx>
20 #include <GeomToStep_MakeCartesianPoint.hxx>
21 #include <gp_Pnt.hxx>
22 #include <gp_Pnt2d.hxx>
23 #include <StdFail_NotDone.hxx>
24 #include <StepGeom_CartesianPoint.hxx>
25 #include <TCollection_HAsciiString.hxx>
26 #include <TColStd_HArray1OfReal.hxx>
27 #include <UnitsMethods.hxx>
28
29 //=============================================================================
30 // Creation d' un cartesian_point de prostep a partir d' un point3d de gp
31 //=============================================================================
32 GeomToStep_MakeCartesianPoint::GeomToStep_MakeCartesianPoint( const gp_Pnt& P)
33 {
34   Handle(StepGeom_CartesianPoint) Pstep = new StepGeom_CartesianPoint;
35 //  Handle(TColStd_HArray1OfReal) Acoord = new TColStd_HArray1OfReal(1,3);
36   Standard_Real X, Y, Z;
37   
38   P.Coord(X, Y, Z);
39 //  Acoord->SetValue(1,X);
40 //  Acoord->SetValue(2,Y);
41 //  Acoord->SetValue(3,Z);
42 //  Pstep->SetCoordinates(Acoord);
43   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
44 //  Pstep->SetName(name);
45   Standard_Real fact = UnitsMethods::LengthFactor();
46   Pstep->Init3D (name,X/fact,Y/fact,Z/fact);
47   theCartesianPoint = Pstep;
48   done = Standard_True;
49 }
50 //=============================================================================
51 // Creation d' un cartesian_point de prostep a partir d' un point 2d de gp
52 //=============================================================================
53
54 GeomToStep_MakeCartesianPoint::GeomToStep_MakeCartesianPoint( const gp_Pnt2d& P)
55 {
56   Handle(StepGeom_CartesianPoint) Pstep = new StepGeom_CartesianPoint;
57 //  Handle(TColStd_HArray1OfReal) Acoord = new TColStd_HArray1OfReal(1,2);
58   Standard_Real X, Y;
59   
60   P.Coord(X, Y);
61 //  Acoord->SetValue(1,X);
62 //  Acoord->SetValue(2,Y);
63 //  Pstep->SetCoordinates(Acoord);
64   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
65 //  Pstep->SetName(name);
66   Pstep->Init2D (name,X,Y);
67   theCartesianPoint = Pstep;
68   done = Standard_True;
69 }
70
71 //=============================================================================
72 // Creation d' un cartesian_point de prostep a partir d' un point 3d de Geom
73 //=============================================================================
74
75 GeomToStep_MakeCartesianPoint::
76   GeomToStep_MakeCartesianPoint( const Handle(Geom_CartesianPoint)& P)
77
78 {
79   Handle(StepGeom_CartesianPoint) Pstep = new StepGeom_CartesianPoint;
80 //  Handle(TColStd_HArray1OfReal) Acoord = new TColStd_HArray1OfReal(1,3);
81   Standard_Real X, Y, Z;
82   
83   P->Coord(X, Y, Z);
84 //  Acoord->SetValue(1,X);
85 //  Acoord->SetValue(2,Y);
86 //  Acoord->SetValue(3,Z);
87 //  Pstep->SetCoordinates(Acoord);
88   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
89 //  Pstep->SetName(name);
90   Standard_Real fact = UnitsMethods::LengthFactor();
91   Pstep->Init3D (name,X/fact,Y/fact,Z/fact);
92   theCartesianPoint = Pstep;
93   done = Standard_True;
94 }
95
96 //=============================================================================
97 // Creation d' un cartesian_point de prostep a partir d' un point 2d de Geom2d
98 //=============================================================================
99
100 GeomToStep_MakeCartesianPoint::
101   GeomToStep_MakeCartesianPoint( const Handle(Geom2d_CartesianPoint)& P)
102
103 {
104   Handle(StepGeom_CartesianPoint) Pstep = new StepGeom_CartesianPoint;
105 //  Handle(TColStd_HArray1OfReal) Acoord = new TColStd_HArray1OfReal(1,2);
106   Standard_Real X, Y;
107   
108   P->Coord(X, Y);
109 //  Acoord->SetValue(1,X);
110 //  Acoord->SetValue(2,Y);
111 //  Pstep->SetCoordinates(Acoord);
112   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
113 //  Pstep->SetName(name);
114   Pstep->Init2D (name,X,Y);
115   theCartesianPoint = Pstep;
116   done = Standard_True;
117 }
118
119 //=============================================================================
120 // renvoi des valeurs
121 //=============================================================================
122
123 const Handle(StepGeom_CartesianPoint) &
124       GeomToStep_MakeCartesianPoint::Value() const
125 {
126   StdFail_NotDone_Raise_if(!done, "");
127   return theCartesianPoint;
128 }