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"
35 vtkStandardNewMacro(vtkParaSMESHCorbaSource);
37 void *vtkParaSMESHCorbaSource::Orb=0;
39 //----------------------------------------------
40 vtkParaSMESHCorbaSource::vtkParaSMESHCorbaSource() {
42 CORBA::ORB_var *OrbC=new CORBA::ORB_var;
44 *OrbC=CORBA::ORB_init(argc,0);
47 this->SetNumberOfInputPorts(0);
48 this->SetNumberOfOutputPorts(1);
51 //----------------------------------------------
52 vtkParaSMESHCorbaSource::~vtkParaSMESHCorbaSource() {
56 //----------------------------------------------
57 const char* vtkParaSMESHCorbaSource::GetIORCorba()
62 //----------------------------------------------
63 void vtkParaSMESHCorbaSource::SetIORCorba(char *ior) {
68 int length=strlen(ior);
70 vtksys_stl::copy(ior,ior+length+1,&IOR[0]);
74 //----------------------------------------------
75 int vtkParaSMESHCorbaSource::ProcessRequest(vtkInformation* request,
76 vtkInformationVector** inputVector,
77 vtkInformationVector* outputVector) {
79 if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) {
80 return this->RequestData(request, inputVector, outputVector);
82 return this->Superclass::ProcessRequest(request, inputVector, outputVector);
85 //----------------------------------------------
86 int vtkParaSMESHCorbaSource::FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) {
87 info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet");
91 //----------------------------------------------
92 int vtkParaSMESHCorbaSource::RequestData(vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outputVector) {
93 vtkInformation *outInfo=outputVector->GetInformationObject(0);
94 vtkMultiBlockDataSet *ret0=vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
96 if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()))
97 reqTS = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
100 CORBA::ORB_var *OrbC=(CORBA::ORB_var *)this->Orb;
101 CORBA::Object_var obj=(*OrbC)->string_to_object(&IOR[0]);
102 SMESH::SMESH_Mesh_var meshObj = SMESH::SMESH_Mesh::_narrow(obj);
103 if(!CORBA::is_nil(meshObj)) {
104 SALOMEDS::TMPFile* SeqFile = meshObj->GetVtkUgStream();
105 int aSize = SeqFile->length();
106 char* buf = (char*)SeqFile->NP_data();
107 vtkUnstructuredGridReader* aReader = vtkUnstructuredGridReader::New();
108 aReader->ReadFromInputStringOn();
109 aReader->SetBinaryInputString(buf, aSize);
111 vtkUnstructuredGrid* ret = vtkUnstructuredGrid::New();
112 ret->ShallowCopy(aReader->GetOutput());
115 vtkErrorMacro("On smesh object CORBA fetching an error occurs !");
119 ret0->SetBlock(0, ret);
124 vtkErrorMacro("Unrecognized CORBA reference!");
126 catch(CORBA::Exception&) {
127 vtkErrorMacro("On fetching object error occurs");