]> SALOME platform Git repositories - plugins/ghs3dplugin.git/blob - src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.cxx
Salome HOME
Changing version to 6.4.0
[plugins/ghs3dplugin.git] / src / GHS3DPlugin / GHS3DPlugin_GHS3D_i.cxx
1 // Copyright (C) 2004-2011  CEA/DEN, EDF R&D
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.
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 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
21 //  File   : GHS3DPlugin_GHS3D_i.cxx
22 //  Author : Edward AGAPOV
23 //  Module : GHS3DPlugin
24 //  $Header$
25 //
26 #include "GHS3DPlugin_GHS3D_i.hxx"
27 #include "SMESH_Gen.hxx"
28 #include "SMESH_Mesh_i.hxx"
29 #include "SMESH_Gen_i.hxx"
30 #include "GHS3DPlugin_GHS3D.hxx"
31 #include "SMESH_PythonDump.hxx"
32
33 #include "utilities.h"
34 #include <cstring>
35
36 using namespace std;
37
38 //=============================================================================
39 /*!
40  *  GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i
41  *
42  *  Constructor
43  */
44 //=============================================================================
45
46 GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i (PortableServer::POA_ptr thePOA,
47                                           int                     theStudyId,
48                                           ::SMESH_Gen*            theGenImpl )
49      : SALOME::GenericObj_i( thePOA ), 
50        SMESH_Hypothesis_i( thePOA ), 
51        SMESH_Algo_i( thePOA ),
52        SMESH_3D_Algo_i( thePOA )
53 {
54   MESSAGE( "GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i" );
55   myBaseImpl = new ::GHS3DPlugin_GHS3D (theGenImpl->GetANewId(),
56                                         theStudyId,
57                                         theGenImpl );
58 }
59
60 //=============================================================================
61 /*!
62  *  GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i
63  *
64  *  Destructor
65  */
66 //=============================================================================
67
68 GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i()
69 {
70   MESSAGE( "GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i" );
71 }
72
73 //=============================================================================
74 /*!
75  *  GHS3DPlugin_GHS3D_i::GetImpl
76  *
77  *  Get implementation
78  */
79 //=============================================================================
80
81 ::GHS3DPlugin_GHS3D* GHS3DPlugin_GHS3D_i::GetImpl()
82 {
83   MESSAGE( "GHS3DPlugin_GHS3D_i::GetImpl" );
84   return ( ::GHS3DPlugin_GHS3D* )myBaseImpl;
85 }
86
87 //=============================================================================
88 /*!
89  *  GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i
90  *
91  *  Destructor
92  */
93 //=============================================================================
94
95 SMESH::SMESH_Mesh_ptr GHS3DPlugin_GHS3D_i::importGMFMesh(const char* theGMFFileName)
96 {
97   MESSAGE( "GHS3DPlugin_GHS3D_i::importGMFMesh" );
98   SMESH_Gen_i* smeshGen = SMESH_Gen_i::GetSMESHGen();
99   SMESH::SMESH_Mesh_ptr theMesh = smeshGen->CreateEmptyMesh();
100   smeshGen->RemoveLastFromPythonScript(smeshGen->GetCurrentStudy()->StudyId());
101   SALOMEDS::SObject_ptr theSMesh = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(), theMesh);
102 #ifdef WINNT
103 #define SEP '\\'
104 #else
105 #define SEP '/'
106 #endif
107   string strFileName (theGMFFileName);
108   strFileName = strFileName.substr(strFileName.rfind(SEP)+1);
109   strFileName.erase(strFileName.rfind('.'));
110   smeshGen->SetName(theSMesh, strFileName.c_str());
111   SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( smeshGen->GetServant( theMesh ).in() );
112   ASSERT( meshServant );
113   if ( meshServant ) {
114     if (GetImpl()->importGMFMesh(theGMFFileName, meshServant->GetImpl()))
115       SMESH::TPythonDump() << theSMesh << " = " << _this() << ".importGMFMesh( \"" << theGMFFileName << "\")";
116   }
117   return theMesh;
118 }