Back to index

salome-paravis  6.5.0
VTKMEDCouplingMeshClient.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "VTKMEDCouplingMeshClient.hxx"
00021 #include "VTKMEDCouplingUMeshClient.hxx"
00022 #include "VTKMEDCouplingCMeshClient.hxx"
00023 
00024 #include "vtkErrorCode.h"
00025 #include "vtkUnstructuredGrid.h"
00026 #include "vtkRectilinearGrid.h"
00027 
00028 #include <vector>
00029 #include <string>
00030 
00031 //vtkErrorMacro("Cannot call Start() twice before calling Finish().");
00032 void ParaMEDMEM2VTK::FillMEDCouplingMeshInstanceFrom(SALOME_MED::MEDCouplingMeshCorbaInterface_ptr meshPtr, vtkDataSet *ret)
00033 {
00034   SALOME_MED::MEDCouplingUMeshCorbaInterface_var umeshPtr=SALOME_MED::MEDCouplingUMeshCorbaInterface::_narrow(meshPtr);
00035   if(!CORBA::is_nil(umeshPtr))
00036     {
00037       vtkUnstructuredGrid *ret1=vtkUnstructuredGrid::SafeDownCast(ret);
00038       if(!ret1)
00039         {
00040           vtkErrorWithObjectMacro(ret,"Internal error in ParaMEDCorba plugin : mismatch between VTK type and CORBA type UMesh !");
00041           return ;
00042         }
00043       bool dummy;//VTK bug
00044       ParaMEDMEM2VTK::FillMEDCouplingUMeshInstanceFrom(umeshPtr,ret1,dummy);//VTK bug
00045       return ;
00046     }
00047   SALOME_MED::MEDCouplingCMeshCorbaInterface_var cmeshPtr=SALOME_MED::MEDCouplingCMeshCorbaInterface::_narrow(meshPtr);
00048   if(!CORBA::is_nil(cmeshPtr))
00049     {
00050       vtkRectilinearGrid *ret1=vtkRectilinearGrid::SafeDownCast(ret);
00051       if(!ret1)
00052         {
00053           vtkErrorWithObjectMacro(ret,"Internal error in ParaMEDCorba plugin : mismatch between VTK type and CORBA type CMesh !");
00054           return ;
00055         }
00056       ParaMEDMEM2VTK::FillMEDCouplingCMeshInstanceFrom(cmeshPtr,ret1);
00057       return ;
00058     }
00059   vtkErrorWithObjectMacro(ret,"Error : CORBA mesh type ! Mesh type not managed !");
00060 }
00061 
00062 vtkDataSet *ParaMEDMEM2VTK::BuildFromMEDCouplingMeshInstance(SALOME_MED::MEDCouplingMeshCorbaInterface_ptr meshPtr, bool& isPolyh)
00063 {
00064   SALOME_MED::MEDCouplingUMeshCorbaInterface_var umeshPtr=SALOME_MED::MEDCouplingUMeshCorbaInterface::_narrow(meshPtr);
00065   if(!CORBA::is_nil(umeshPtr))
00066     {
00067       vtkUnstructuredGrid *ret1=vtkUnstructuredGrid::New();
00068       ParaMEDMEM2VTK::FillMEDCouplingUMeshInstanceFrom(umeshPtr,ret1,isPolyh);
00069       return ret1;
00070     }
00071   SALOME_MED::MEDCouplingCMeshCorbaInterface_var cmeshPtr=SALOME_MED::MEDCouplingCMeshCorbaInterface::_narrow(meshPtr);
00072   if(!CORBA::is_nil(cmeshPtr))
00073     {
00074       vtkRectilinearGrid *ret1=vtkRectilinearGrid::New();
00075       ParaMEDMEM2VTK::FillMEDCouplingCMeshInstanceFrom(cmeshPtr,ret1);
00076       return ret1;
00077     }
00078   vtkOutputWindowDisplayErrorText("Error : CORBA mesh type ! Mesh type not managed #2 !");
00079   return 0;
00080 }