1 // Copyright (C) 2010-2016 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 "vtkParaGEOMCorbaSource.h"
22 #include "vtkMultiBlockDataSet.h"
23 #include "vtkUnstructuredGrid.h"
25 #include "vtkStreamingDemandDrivenPipeline.h"
26 #include "vtkInformationVector.h"
27 #include "vtkObjectFactory.h"
28 #include "vtkInformation.h"
30 #include <SALOME_LifeCycleCORBA.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include "vtkPolyData.h"
33 #include <SalomeApp_Application.h>
34 #include "GEOM_Gen.hh"
35 #include "GEOM_Client.hxx"
36 #include "OCC2VTK_Tools.h"
40 //----------------------------------------------
41 vtkStandardNewMacro(vtkParaGEOMCorbaSource);
43 void *vtkParaGEOMCorbaSource::Orb=0;
45 //----------------------------------------------
46 vtkParaGEOMCorbaSource::vtkParaGEOMCorbaSource():Deflection(0.0)
49 CORBA::ORB_var *OrbC=new CORBA::ORB_var;
51 *OrbC=CORBA::ORB_init(argc,0);
54 this->SetNumberOfInputPorts(0);
55 this->SetNumberOfOutputPorts(1);
58 //----------------------------------------------
59 vtkParaGEOMCorbaSource::~vtkParaGEOMCorbaSource() {
62 //----------------------------------------------
63 const char* vtkParaGEOMCorbaSource::GetIORCorba()
68 //----------------------------------------------
69 void vtkParaGEOMCorbaSource::SetIORCorba(char *ior) {
74 int length=strlen(ior);
76 std::copy(ior,ior+length+1,&IOR[0]);
80 //----------------------------------------------
81 int vtkParaGEOMCorbaSource::ProcessRequest(vtkInformation* request,
82 vtkInformationVector** inputVector,
83 vtkInformationVector* outputVector) {
85 if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) {
86 return this->RequestData(request, inputVector, outputVector);
88 return this->Superclass::ProcessRequest(request, inputVector, outputVector);
91 //----------------------------------------------
92 int vtkParaGEOMCorbaSource::FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) {
93 info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet");
97 //----------------------------------------------
98 int vtkParaGEOMCorbaSource::RequestData(vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outputVector) {
99 vtkInformation *outInfo=outputVector->GetInformationObject(0);
100 vtkMultiBlockDataSet *ret0=vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
102 if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()))
103 reqTS = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
105 //Client request on ORB.
106 CORBA::ORB_var *OrbC=(CORBA::ORB_var *)this->Orb;
107 CORBA::Object_var obj=(*OrbC)->string_to_object(&IOR[0]);
108 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow(obj);
110 if(!CORBA::is_nil(geomObj)) {
111 SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
112 Engines::EngineComponent_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","GEOM");
113 GEOM::GEOM_Gen_var geomGen = GEOM::GEOM_Gen::_narrow(aComponent);
114 if ( !CORBA::is_nil( geomGen ) ) {
115 TopoDS_Shape aTopoDSShape = GEOM_Client::get_client().GetShape( geomGen, geomObj );
117 if ( !aTopoDSShape.IsNull() ) {
118 vtkPolyData *ret=GEOM::GetVTKData(aTopoDSShape, this->Deflection);
120 vtkErrorMacro("On geom object CORBA fetching an error occurs !");
123 ret0->SetBlock(0,ret);
129 vtkErrorMacro("Unrecognized CORBA reference!");
131 catch(CORBA::Exception& ex) {
132 vtkErrorMacro("On fetching object error occurs");
137 //----------------------------------------------
138 void vtkParaGEOMCorbaSource::PrintSelf(ostream& os, vtkIndent indent) {
139 this->Superclass::PrintSelf( os, indent );
140 os << "Deflection: " << this->Deflection << "\n";