1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 #include "GEOMImpl_ImportDriver.hxx"
25 #include "GEOMImpl_IImportExport.hxx"
26 #include "GEOMImpl_IECallBack.hxx"
27 #include "GEOMImpl_Types.hxx"
30 #include <GEOM_Function.hxx>
33 #include <Standard_Stream.hxx>
34 #include <TopoDS_Shape.hxx>
36 //=======================================================================
39 //=======================================================================
40 const Standard_GUID& GEOMImpl_ImportDriver::GetID()
42 static Standard_GUID aImportDriver("FF1BBB60-5D14-4df2-980B-3A668264EA16");
46 //=======================================================================
47 //function : GEOMImpl_ImportDriver
49 //=======================================================================
50 GEOMImpl_ImportDriver::GEOMImpl_ImportDriver()
54 //=======================================================================
57 //=======================================================================
58 Standard_Integer GEOMImpl_ImportDriver::Execute(LOGBOOK& log) const
60 if (Label().IsNull()) return 0;
61 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
63 GEOMImpl_IImportExport aCI (aFunction);
65 // retrieve the file and plugin library names
66 TCollection_AsciiString aFileName = aCI.GetFileName();
67 TCollection_AsciiString aFormatName = aCI.GetFormatName();
68 if (aFileName.IsEmpty() || aFormatName.IsEmpty() )
71 Handle(TColStd_HSequenceOfTransient) aSeq =
72 GEOMImpl_IECallBack::GetCallBack( aFormatName )->Import( GetDocID(), aFormatName, aFileName );
76 Handle(GEOM_Object) anImported = Handle(GEOM_Object)::DownCast( aSeq->Value(1) );
77 TopoDS_Shape aShape = anImported->GetValue();
78 aFunction->SetValue( aShape );
79 #if OCC_VERSION_MAJOR < 7
80 log.SetTouched(Label());
82 log->SetTouched(Label());
88 bool GEOMImpl_ImportDriver::
89 GetCreationInformation(std::string& theOperationName,
90 std::vector<GEOM_Param>& theParams)
92 if (Label().IsNull()) return 0;
93 Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
95 GEOMImpl_IImportExport aCI( function );
96 Standard_Integer aType = function->GetType();
98 theOperationName = "IMPORT";
102 AddParam( theParams, "File name", aCI.GetFileName() );
103 AddParam( theParams, "Format", aCI.GetFormatName() );
104 AddParam( theParams, "Plugin name", aCI.GetPluginName() );
113 OCCT_IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_ImportDriver,GEOM_BaseDriver);