Salome HOME
Implementation of XTPLUGIN as a GEOM plugin (added files)
[plugins/xtplugin.git] / src / XTPlugin_Operations_i.cc
1 // Copyright (C) 2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // internal includes
21 #include "XTPlugin_Operations_i.hh"
22 #include <XTPLUGIN_version.h>
23
24 // KERNEL includes
25 #include <utilities.h>
26
27 //=============================================================================
28 /*!
29  *   constructor:
30  */
31 //=============================================================================
32 XTPlugin_Operations_i::XTPlugin_Operations_i( PortableServer::POA_ptr thePOA,
33                                                             GEOM::GEOM_Gen_ptr theEngine,
34                                                             ::XTPlugin_IOperations* theImpl )
35 :GEOM_IOperations_i( thePOA, theEngine, theImpl )
36 {
37   MESSAGE( "XTPlugin_Operations_i::XTPlugin_Operations_i" );
38 }
39
40 //=============================================================================
41 /*!
42  *  destructor
43  */
44 //=============================================================================
45 XTPlugin_Operations_i::~XTPlugin_Operations_i()
46 {
47   MESSAGE( "XTPlugin_Operations_i::~XTPlugin_Operations_i" );
48 }
49
50 //=============================================================================
51 /*!
52  *  ImportXT
53  *  Import a shape from XT format
54  *  \param theFileName The name of the file to import
55  *  \return List of GEOM_Objects, containing the created shape and propagation groups.
56  */
57 //=============================================================================
58 GEOM::ListOfGO* XTPlugin_Operations_i::ImportXT( const char* theFileName )
59 {
60   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
61
62   //Set a not done flag
63   GetOperations()->SetNotDone();
64
65   //Import the shape from the file
66   char* aFileName = strdup( theFileName );
67   TCollection_AsciiString fileName( aFileName );
68
69   //Import the shape from the file
70   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportXT( fileName );
71
72   free( aFileName );
73   if( !GetOperations()->IsDone() || aHSeq.IsNull() )
74     return aSeq._retn();
75
76   // Copy created objects.
77   Standard_Integer aLength = aHSeq->Length();
78   aSeq->length( aLength );
79   for( Standard_Integer i = 1; i <= aLength; i++ )
80     aSeq[i-1] = GetObject( Handle(GEOM_Object)::DownCast( aHSeq->Value(i) ) );
81
82   return aSeq._retn();
83 }
84
85 //=============================================================================
86 /*!
87  *  \brief Get version of the plugin.
88  *  \return the version of the plugin
89 */
90 //=============================================================================
91
92 int XTPlugin_Operations_i::GetVersion()
93 {
94   return XTPLUGIN_VERSION;
95 }
96 //=============================================================================
97 /*!
98  *  \brief Get version of the plugin.
99  *  \return the string representation of the plugin's version
100 */
101 //=============================================================================
102
103 char* XTPlugin_Operations_i::GetVersionStr()
104 {
105   return (char*)XTPLUGIN_VERSION_STR;
106 }