1 // Copyright (C) 2014 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 "ACISPlugin_Operations_i.hh"
22 #include <ACISPLUGIN_version.h>
25 #include <utilities.h>
27 //=============================================================================
31 //=============================================================================
32 ACISPlugin_Operations_i::ACISPlugin_Operations_i( PortableServer::POA_ptr thePOA,
33 GEOM::GEOM_Gen_ptr theEngine,
34 ::ACISPlugin_IOperations* theImpl )
35 :GEOM_IOperations_i( thePOA, theEngine, theImpl )
37 MESSAGE( "ACISPlugin_Operations_i::ACISPlugin_Operations_i" );
40 //=============================================================================
44 //=============================================================================
45 ACISPlugin_Operations_i::~ACISPlugin_Operations_i()
47 MESSAGE( "ACISPlugin_Operations_i::~ACISPlugin_Operations_i" );
50 //=============================================================================
53 * Export a shape to ACIS format
54 * \param theOriginal The shape to export
55 * \param theFileName The name of the exported file
57 //=============================================================================
58 void ACISPlugin_Operations_i::ExportACIS( 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 char* aFileName = strdup( theFileName );
74 GetOperations()->ExportACIS( anOriginal, aFileName );
78 //=============================================================================
81 * Import a shape from ACIS format
82 * \param theFileName The name of the file to import
83 * \return List of GEOM_Objects, containing the created shape and propagation groups.
85 //=============================================================================
86 GEOM::ListOfGO* ACISPlugin_Operations_i::ImportACIS( const char* theFileName )
88 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
91 GetOperations()->SetNotDone();
93 //Import the shape from the file
94 char* aFileName = strdup( theFileName );
95 TCollection_AsciiString fileName( aFileName );
97 //Import the shape from the file
98 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportACIS( fileName );
101 if( !GetOperations()->IsDone() || aHSeq.IsNull() )
104 // Copy created objects.
105 Standard_Integer aLength = aHSeq->Length();
106 aSeq->length( aLength );
107 for( Standard_Integer i = 1; i <= aLength; i++ )
108 aSeq[i-1] = GetObject( Handle(GEOM_Object)::DownCast( aHSeq->Value(i) ) );
113 //=============================================================================
115 * \brief Get version of the plugin.
116 * \return the version of the plugin
118 //=============================================================================
120 int ACISPlugin_Operations_i::GetVersion()
122 return ACISPLUGIN_VERSION;
124 //=============================================================================
126 * \brief Get version of the plugin.
127 * \return the string representation of the plugin's version
129 //=============================================================================
131 char* ACISPlugin_Operations_i::GetVersionStr()
133 return (char*)ACISPLUGIN_VERSION_STR;