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 "BREPPlugin_IOperations_i.hh"
22 #include "BREPPlugin_IOperations.hxx"
25 #include <utilities.h>
27 //=============================================================================
31 //=============================================================================
32 BREPPlugin_IOperations_i::BREPPlugin_IOperations_i( PortableServer::POA_ptr thePOA,
33 GEOM::GEOM_Gen_ptr theEngine,
34 BREPPlugin_IOperations* theImpl )
35 :GEOM_IOperations_i( thePOA, theEngine, theImpl )
37 MESSAGE( "BREPPlugin_IOperations_i::BREPPlugin_IOperations_i" );
40 //=============================================================================
44 //=============================================================================
45 BREPPlugin_IOperations_i::~BREPPlugin_IOperations_i()
47 MESSAGE( "BREPPlugin_IOperations_i::~BREPPlugin_IOperations_i" );
50 //=============================================================================
53 * Export a shape to BREP format
54 * \param theOriginal The shape to export
55 * \param theFileName The name of the exported file
57 //=============================================================================
58 void BREPPlugin_IOperations_i::ExportBREP( GEOM::GEOM_Object_ptr theOriginal,
59 const char* theFileName )
61 // duplicate the original shape
62 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate( theOriginal );
65 GetOperations()->SetNotDone();
67 //Get the reference shape
68 Handle(GEOM_Object) anOriginal = GetObjectImpl( theOriginal );
69 if (anOriginal.IsNull()) return;
71 //Export the shape to the file
72 GetOperations()->ExportBREP( anOriginal, theFileName );
75 //=============================================================================
78 * Import a shape from BREP format
79 * \param theFileName The name of the file to import
80 * \return List of GEOM_Objects, containing the created shape and propagation groups.
82 //=============================================================================
83 GEOM::ListOfGO* BREPPlugin_IOperations_i::ImportBREP( const char* theFileName )
85 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
88 GetOperations()->SetNotDone();
90 //Import the shape from the file
91 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportBREP( theFileName );
93 if( !GetOperations()->IsDone() || aHSeq.IsNull() )
96 // Copy created objects.
97 Standard_Integer aLength = aHSeq->Length();
98 aSeq->length( aLength );
99 for( Standard_Integer i = 1; i <= aLength; i++ )
100 aSeq[i-1] = GetObject( Handle(GEOM_Object)::DownCast( aHSeq->Value(i) ) );
105 BREPPlugin_IOperations* BREPPlugin_IOperations_i::GetOperations()
107 return (BREPPlugin_IOperations*)GetImpl();