0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / GeomToStep / GeomToStep_MakeAxis2Placement3d.cxx
1 // Created on: 1993-06-16
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 <Geom_Axis2Placement.hxx>
19 #include <GeomToStep_MakeAxis2Placement3d.hxx>
20 #include <GeomToStep_MakeCartesianPoint.hxx>
21 #include <GeomToStep_MakeDirection.hxx>
22 #include <gp_Ax2.hxx>
23 #include <gp_Ax3.hxx>
24 #include <gp_Trsf.hxx>
25 #include <StdFail_NotDone.hxx>
26 #include <StepGeom_Axis2Placement3d.hxx>
27 #include <StepGeom_CartesianPoint.hxx>
28 #include <StepGeom_Direction.hxx>
29 #include <TCollection_HAsciiString.hxx>
30
31 static Handle(StepGeom_Axis2Placement3d)  MakeAxis2Placement3d
32   (const gp_Pnt& O, const gp_Dir& D, const gp_Dir& X, const Standard_CString nom)
33 {
34   Handle(StepGeom_Axis2Placement3d) Axe;
35   Handle(StepGeom_CartesianPoint) P;
36   Handle(StepGeom_Direction) D1, D2;
37
38   GeomToStep_MakeCartesianPoint MkPoint(O);
39   GeomToStep_MakeDirection      MkDir1(D);
40   GeomToStep_MakeDirection      MkDir2(X);
41   
42   P  = MkPoint.Value();
43   D1 = MkDir1.Value();
44   D2 = MkDir2.Value();
45
46   Axe = new StepGeom_Axis2Placement3d;
47   Axe->SetLocation(P);
48   Axe->SetAxis(D1);
49   Axe->SetRefDirection(D2);
50   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString(nom);
51   Axe->SetName(name);
52   return Axe;
53 }
54
55 //=============================================================================
56 // Creation d' un axis2_placement_3d a l origine
57 //=============================================================================
58
59 GeomToStep_MakeAxis2Placement3d::GeomToStep_MakeAxis2Placement3d ( )
60 {
61   gp_Ax2 A (gp_Pnt(0.,0.,0.), gp_Dir (0.,0.,1.), gp_Dir (1.,0.,0.));
62 //   le reste inchange
63
64   Handle(StepGeom_Axis2Placement3d) Axe = MakeAxis2Placement3d
65     (A.Location(), A.Direction(), A.XDirection(), "");
66   theAxis2Placement3d = Axe;
67   done = Standard_True;
68 }
69
70 //=============================================================================
71 // Creation d' un axis2_placement_3d de prostep a partir d' un Ax2 de gp
72 //=============================================================================
73
74 GeomToStep_MakeAxis2Placement3d::GeomToStep_MakeAxis2Placement3d( const gp_Ax2&
75                                                                A)
76 {
77   Handle(StepGeom_Axis2Placement3d) Axe = MakeAxis2Placement3d
78     (A.Location(), A.Direction(), A.XDirection(), "");
79   theAxis2Placement3d = Axe;
80   done = Standard_True;
81 }
82
83 //=============================================================================
84 // Creation d' un axis2_placement_3d de prostep a partir d' un Ax3 de gp
85 //=============================================================================
86
87 GeomToStep_MakeAxis2Placement3d::GeomToStep_MakeAxis2Placement3d
88 ( const gp_Ax3&  A)
89 {
90   Handle(StepGeom_Axis2Placement3d) Axe = MakeAxis2Placement3d
91     (A.Location(), A.Direction(), A.XDirection(), "");
92   theAxis2Placement3d = Axe;
93   done = Standard_True;
94 }
95
96 //=============================================================================
97 // Creation d' un axis2_placement_3d de prostep a partir d' un Trsf de gp
98 //=============================================================================
99
100 GeomToStep_MakeAxis2Placement3d::GeomToStep_MakeAxis2Placement3d
101   ( const gp_Trsf& T)
102 {
103   gp_Ax2 A (gp_Pnt(0.,0.,0.), gp_Dir (0.,0.,1.), gp_Dir (1.,0.,0.));
104   A.Transform (T);
105 //   le reste inchange
106
107   Handle(StepGeom_Axis2Placement3d) Axe = MakeAxis2Placement3d
108     (A.Location(), A.Direction(), A.XDirection(), "");
109   theAxis2Placement3d = Axe;
110   done = Standard_True;
111 }
112
113 //=============================================================================
114 // Creation d' un axis2_placement_3d de prostep a partir d' un Axis2Placement
115 // de Geom
116 //=============================================================================
117
118 GeomToStep_MakeAxis2Placement3d::GeomToStep_MakeAxis2Placement3d
119   ( const Handle(Geom_Axis2Placement)& Axis2)
120 {
121   gp_Ax2 A;
122   A = Axis2->Ax2();
123
124   Handle(StepGeom_Axis2Placement3d) Axe = MakeAxis2Placement3d
125     (A.Location(), A.Direction(), A.XDirection(), "");
126   theAxis2Placement3d = Axe;
127   done = Standard_True;
128 }
129
130 //=============================================================================
131 // renvoi des valeurs
132 //=============================================================================
133
134 const Handle(StepGeom_Axis2Placement3d) &
135       GeomToStep_MakeAxis2Placement3d::Value() const
136 {
137   StdFail_NotDone_Raise_if(!done == Standard_True,"");
138   return theAxis2Placement3d;
139 }