1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D, OPEN CASCADE
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, or (at your option) any later version.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "XAOPlugin_IECallBack.hxx"
22 #include "XAOPlugin_IOperations.hxx"
23 #include "XAOPlugin_OperationsCreator.hxx"
24 #include "GEOMImpl_IShapesOperations.hxx"
26 //=============================================================================
30 //=============================================================================
31 XAOPlugin_IECallBack::XAOPlugin_IECallBack()
35 //=============================================================================
39 //=============================================================================
40 XAOPlugin_IECallBack::~XAOPlugin_IECallBack()
44 //=============================================================================
48 //=============================================================================
50 XAOPlugin_IECallBack::Export( int theDocId,
51 const Handle(GEOM_Object) theOriginal,
52 const TCollection_AsciiString& theFileName,
53 const TCollection_AsciiString& theFormatName,
54 const TCollection_AsciiString& theShapeFileName )
56 XAOPlugin_IOperations* aPluginOperations = XAOPlugin_OperationsCreator::get( GetEngine(), theDocId );
57 GEOMImpl_IShapesOperations* aShapesOperations = GetEngine()->GetIShapesOperations( theDocId );
59 Handle(TColStd_HSequenceOfTransient) groups = aShapesOperations->GetExistingSubObjects( theOriginal, GEOMImpl_IShapesOperations::Groups );
60 Handle(TColStd_HSequenceOfTransient) fields = aShapesOperations->GetExistingSubObjects( theOriginal, GEOMImpl_IShapesOperations::Fields );
61 std::list<Handle(GEOM_Object)> lgroups;
62 std::list<Handle(GEOM_Field)> lfields;
63 for (int i = 1; i <= groups->Length(); i++)
64 lgroups.push_back( Handle(GEOM_Object)::DownCast( groups->Value(i) ) );
65 for (int i = 1; i <= fields->Length(); i++)
66 lfields.push_back( Handle(GEOM_Field)::DownCast( fields->Value(i) ) );
67 aPluginOperations->ExportXAO( theOriginal, lgroups, lfields, "SIMAN Author", theFileName.ToCString(), theShapeFileName.ToCString() );
71 //=============================================================================
75 //=============================================================================
76 Handle(TColStd_HSequenceOfTransient)
77 XAOPlugin_IECallBack::Import( int theDocId,
78 const TCollection_AsciiString& theFormatName,
79 const TCollection_AsciiString& theFileName )
81 XAOPlugin_IOperations* aPluginOperations = XAOPlugin_OperationsCreator::get( GetEngine(), theDocId );
83 Handle(TColStd_HSequenceOfTransient) result = new TColStd_HSequenceOfTransient();
84 Handle(TColStd_HSequenceOfTransient) subshapes = new TColStd_HSequenceOfTransient();
85 Handle(TColStd_HSequenceOfTransient) groups = new TColStd_HSequenceOfTransient();
86 Handle(TColStd_HSequenceOfTransient) fields = new TColStd_HSequenceOfTransient();
87 Handle(GEOM_Object) shape;
89 bool ok = aPluginOperations->ImportXAO( theFileName.ToCString(), shape, subshapes, groups, fields );
91 result->Append( shape );
92 for ( int i = 1; i <= groups->Length(); i++ )
93 result->Append( groups->Value(i) );
94 for ( int i = 1; i <= fields->Length(); i++ )
95 result->Append( fields->Value(i) );