1 // Copyright (C) 2014-2015 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 "IGESPlugin_IOperations_i.hh"
22 #include "IGESPlugin_IOperations.hxx"
25 #include <utilities.h>
27 //=============================================================================
31 //=============================================================================
32 IGESPlugin_IOperations_i::IGESPlugin_IOperations_i( PortableServer::POA_ptr thePOA,
33 GEOM::GEOM_Gen_ptr theEngine,
34 IGESPlugin_IOperations* theImpl )
35 :GEOM_IOperations_i( thePOA, theEngine, theImpl )
37 MESSAGE( "IGESPlugin_IOperations_i::IGESPlugin_IOperations_i" );
40 //=============================================================================
44 //=============================================================================
45 IGESPlugin_IOperations_i::~IGESPlugin_IOperations_i()
47 MESSAGE( "IGESPlugin_IOperations_i::~IGESPlugin_IOperations_i" );
50 //=============================================================================
53 * Export a shape to IGES format
54 * \param theOriginal The shape to export
55 * \param theFileName The name of the exported file
56 * \param theVersion The version of IGES format which defines, whether to write
57 * only faces (5.1 IGES format) or shells and solids also (5.3 IGES format).
59 //=============================================================================
60 void IGESPlugin_IOperations_i::ExportIGES( GEOM::GEOM_Object_ptr theOriginal,
61 const char* theFileName,
62 const char* theVersion )
64 // duplicate the original shape
65 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate( theOriginal );
68 GetOperations()->SetNotDone();
70 //Get the reference shape
71 Handle(GEOM_Object) anOriginal = GetObjectImpl( theOriginal );
72 if (anOriginal.IsNull()) return;
74 GetOperations()->ExportIGES( anOriginal, theFileName, theVersion );
77 //=============================================================================
80 * Import a shape from IGES format
81 * \param theFileName The name of the file to import
82 * \param theIsIgnoreUnits If True, file length units will be ignored (set to 'meter')
83 * and result model will be scaled, if its units are not meters.
84 * If False (default), file length units will be taken into account.
85 * \return List of GEOM_Objects, containing the created shape and propagation groups.
87 //=============================================================================
88 GEOM::ListOfGO* IGESPlugin_IOperations_i::ImportIGES( const char* theFileName,
89 const bool theIsIgnoreUnits = false )
91 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
94 GetOperations()->SetNotDone();
96 //Import the shape from the file
97 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportIGES( theFileName, theIsIgnoreUnits );
99 if( !GetOperations()->IsDone() || aHSeq.IsNull() )
102 // Copy created objects.
103 Standard_Integer aLength = aHSeq->Length();
104 aSeq->length( aLength );
105 for( Standard_Integer i = 1; i <= aLength; i++ )
106 aSeq[i-1] = GetObject( Handle(GEOM_Object)::DownCast( aHSeq->Value(i) ) );
111 //=============================================================================
115 //=============================================================================
116 char* IGESPlugin_IOperations_i::ReadValue( const char* theFileName,
117 const char* theParameterName )
119 //Set a not done flag
120 GetOperations()->SetNotDone();
122 TCollection_AsciiString aParam = GetOperations()->ReadValue( theFileName, theParameterName );
124 return CORBA::string_dup( aParam.ToCString() );
127 IGESPlugin_IOperations* IGESPlugin_IOperations_i::GetOperations()
129 return (IGESPlugin_IOperations*)GetImpl();