1 // Copyright (C) 2010-2020 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>
24 #include "vtkStreamingDemandDrivenPipeline.h"
25 #include "vtkInformationVector.h"
26 #include "vtkInformation.h"
27 #include "vtkMultiBlockDataSet.h"
28 #include "vtkObjectFactory.h"
29 #include "vtkUnstructuredGridReader.h"
31 #include "SMDS_UnstructuredGrid.hxx"
32 #include "SMESH_Mesh.hh"
36 vtkStandardNewMacro(vtkParaSMESHCorbaSource)
38 void *vtkParaSMESHCorbaSource::Orb=0;
40 //----------------------------------------------
41 vtkParaSMESHCorbaSource::vtkParaSMESHCorbaSource() {
43 CORBA::ORB_var *OrbC=new CORBA::ORB_var;
45 *OrbC=CORBA::ORB_init(argc,0);
48 this->SetNumberOfInputPorts(0);
49 this->SetNumberOfOutputPorts(1);
52 //----------------------------------------------
53 vtkParaSMESHCorbaSource::~vtkParaSMESHCorbaSource() {
57 //----------------------------------------------
58 const char* vtkParaSMESHCorbaSource::GetIORCorba()
63 //----------------------------------------------
64 void vtkParaSMESHCorbaSource::SetIORCorba(char *ior) {
69 int length=strlen(ior);
71 std::copy(ior,ior+length+1,&IOR[0]);
75 //----------------------------------------------
76 int vtkParaSMESHCorbaSource::ProcessRequest(vtkInformation* request,
77 vtkInformationVector** inputVector,
78 vtkInformationVector* outputVector) {
80 if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) {
81 return this->RequestData(request, inputVector, outputVector);
83 return this->Superclass::ProcessRequest(request, inputVector, outputVector);
86 //----------------------------------------------
87 int vtkParaSMESHCorbaSource::FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) {
88 info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet");
92 //----------------------------------------------
93 int vtkParaSMESHCorbaSource::RequestData(vtkInformation* /*request*/, vtkInformationVector** /*inInfo*/, vtkInformationVector* outputVector) {
94 vtkInformation *outInfo=outputVector->GetInformationObject(0);
95 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");