1 // Copyright (C) 2010-2015 CEA/DEN, EDF R&D
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
20 #include "vtkParaSMESHCorbaSource.h"
22 #include <SALOME_LifeCycleCORBA.hxx>
23 #include <SalomeApp_Application.h>
25 #include "vtkStreamingDemandDrivenPipeline.h"
26 #include "vtkInformationVector.h"
27 #include "vtkInformation.h"
28 #include "vtkMultiBlockDataSet.h"
29 #include "vtkObjectFactory.h"
30 #include "vtkUnstructuredGridReader.h"
32 #include "SMDS_UnstructuredGrid.hxx"
33 #include "SMESH_Mesh.hh"
37 vtkStandardNewMacro(vtkParaSMESHCorbaSource);
39 void *vtkParaSMESHCorbaSource::Orb=0;
41 //----------------------------------------------
42 vtkParaSMESHCorbaSource::vtkParaSMESHCorbaSource() {
44 CORBA::ORB_var *OrbC=new CORBA::ORB_var;
46 *OrbC=CORBA::ORB_init(argc,0);
49 this->SetNumberOfInputPorts(0);
50 this->SetNumberOfOutputPorts(1);
53 //----------------------------------------------
54 vtkParaSMESHCorbaSource::~vtkParaSMESHCorbaSource() {
58 //----------------------------------------------
59 const char* vtkParaSMESHCorbaSource::GetIORCorba()
64 //----------------------------------------------
65 void vtkParaSMESHCorbaSource::SetIORCorba(char *ior) {
70 int length=strlen(ior);
72 std::copy(ior,ior+length+1,&IOR[0]);
76 //----------------------------------------------
77 int vtkParaSMESHCorbaSource::ProcessRequest(vtkInformation* request,
78 vtkInformationVector** inputVector,
79 vtkInformationVector* outputVector) {
81 if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) {
82 return this->RequestData(request, inputVector, outputVector);
84 return this->Superclass::ProcessRequest(request, inputVector, outputVector);
87 //----------------------------------------------
88 int vtkParaSMESHCorbaSource::FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) {
89 info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet");
93 //----------------------------------------------
94 int vtkParaSMESHCorbaSource::RequestData(vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outputVector) {
95 vtkInformation *outInfo=outputVector->GetInformationObject(0);
96 vtkMultiBlockDataSet *ret0=vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
98 if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()))
99 reqTS = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
102 CORBA::ORB_var *OrbC=(CORBA::ORB_var *)this->Orb;
103 CORBA::Object_var obj=(*OrbC)->string_to_object(&IOR[0]);
104 SMESH::SMESH_Mesh_var meshObj = SMESH::SMESH_Mesh::_narrow(obj);
105 if(!CORBA::is_nil(meshObj)) {
106 SALOMEDS::TMPFile* SeqFile = meshObj->GetVtkUgStream();
107 int aSize = SeqFile->length();
108 char* buf = (char*)SeqFile->NP_data();
109 vtkUnstructuredGridReader* aReader = vtkUnstructuredGridReader::New();
110 aReader->ReadFromInputStringOn();
111 aReader->SetBinaryInputString(buf, aSize);
113 vtkUnstructuredGrid* ret = vtkUnstructuredGrid::New();
114 ret->ShallowCopy(aReader->GetOutput());
117 vtkErrorMacro("On smesh object CORBA fetching an error occurs !");
121 ret0->SetBlock(0, ret);
126 vtkErrorMacro("Unrecognized CORBA reference!");
128 catch(CORBA::Exception&) {
129 vtkErrorMacro("On fetching object error occurs");