Salome HOME
add XAO import and modify export
[modules/geom.git] / src / GEOMImpl / GEOMImpl_XAODriver.cxx
1 //  Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
19 #include <Standard_Stream.hxx>
20
21 #include <GEOMImpl_XAODriver.hxx>
22 #include <GEOMImpl_IImportExportXAO.hxx>
23 #include <GEOMImpl_Types.hxx>
24 #include <GEOM_Function.hxx>
25
26 #include <TFunction_Logbook.hxx>
27 #include <StdFail_NotDone.hxx>
28
29 #include "Xao.hxx"
30 #include "Geometry.hxx"
31 #include "Group.hxx"
32 #include "XaoUtils.hxx"
33 //@@ include required header files here @@//
34
35 //=======================================================================
36 //function : GetID
37 //purpose  :
38 //=======================================================================
39 const Standard_GUID& GEOMImpl_XAODriver::GetID()
40 {
41     static Standard_GUID aGUID("1C3A0F3F-729D-4E83-8232-78E74FC5637C");
42     return aGUID;
43 }
44
45 //=======================================================================
46 //function : GEOMImpl_XAODriver
47 //purpose  :
48 //=======================================================================
49 GEOMImpl_XAODriver::GEOMImpl_XAODriver()
50 {
51 }
52
53 //=======================================================================
54 //function : Execute
55 //purpose  :
56 //=======================================================================
57 Standard_Integer GEOMImpl_XAODriver::Execute(TFunction_Logbook& log) const
58 {
59     if (Label().IsNull()) return 0;
60     Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
61
62     GEOMImpl_IImportExportXAO iexao(function);
63     TCollection_AsciiString xao   = iexao.GetData();
64
65     TopoDS_Shape shape;
66
67     Standard_Integer functionType = function->GetType();
68     if (functionType == IMPORTEXPORT_EXPORTXAO)
69     {
70     }
71     else if (functionType == IMPORTEXPORT_IMPORTXAO)
72     {
73     }
74     else
75     {
76         // other construction modes here
77     }
78
79     if (shape.IsNull()) return 0;
80
81     function->SetValue(shape);
82
83     log.SetTouched(Label());
84
85     return 1;
86 }
87
88 //=======================================================================
89 //function :  GEOMImpl_XAODriver_Type_
90 //purpose  :
91 //=======================================================================
92 Standard_EXPORT Handle_Standard_Type& GEOMImpl_XAODriver_Type_()
93 {
94     static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
95     if (aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
96     static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
97     if (aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
98     static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
99     if (aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
100
101     static Handle_Standard_Transient _Ancestors[] = { aType1, aType2, aType3, NULL };
102     static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_XAODriver",
103             sizeof(GEOMImpl_XAODriver),
104             1,
105             (Standard_Address) _Ancestors,
106             (Standard_Address) NULL);
107     return _aType;
108 }
109
110 //=======================================================================
111 //function : DownCast
112 //purpose  :
113 //=======================================================================
114 const Handle(GEOMImpl_XAODriver) Handle(GEOMImpl_XAODriver)::DownCast(
115         const Handle(Standard_Transient)& AnObject)
116 {
117     Handle(GEOMImpl_XAODriver) _anOtherObject;
118
119     if (!AnObject.IsNull())
120     {
121         if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_XAODriver)))
122         {
123             _anOtherObject = Handle(GEOMImpl_XAODriver)((Handle(GEOMImpl_XAODriver)&) AnObject);
124         }
125     }
126
127     return _anOtherObject;
128 }