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 "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"
39 //----------------------------------------------
40 vtkStandardNewMacro(vtkParaGEOMCorbaSource);
42 void *vtkParaGEOMCorbaSource::Orb=0;
44 //----------------------------------------------
45 vtkParaGEOMCorbaSource::vtkParaGEOMCorbaSource():Deflection(0.0)
48 CORBA::ORB_var *OrbC=new CORBA::ORB_var;
50 *OrbC=CORBA::ORB_init(argc,0);
53 this->SetNumberOfInputPorts(0);
54 this->SetNumberOfOutputPorts(1);
57 //----------------------------------------------
58 vtkParaGEOMCorbaSource::~vtkParaGEOMCorbaSource() {
61 //----------------------------------------------
62 const char* vtkParaGEOMCorbaSource::GetIORCorba()
67 //----------------------------------------------
68 void vtkParaGEOMCorbaSource::SetIORCorba(char *ior) {
73 int length=strlen(ior);
75 vtksys_stl::copy(ior,ior+length+1,&IOR[0]);
79 //----------------------------------------------
80 int vtkParaGEOMCorbaSource::ProcessRequest(vtkInformation* request,
81 vtkInformationVector** inputVector,
82 vtkInformationVector* outputVector) {
84 if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) {
85 return this->RequestData(request, inputVector, outputVector);
87 return this->Superclass::ProcessRequest(request, inputVector, outputVector);
90 //----------------------------------------------
91 int vtkParaGEOMCorbaSource::FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) {
92 info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet");
96 //----------------------------------------------
97 int vtkParaGEOMCorbaSource::RequestData(vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outputVector) {
98 vtkInformation *outInfo=outputVector->GetInformationObject(0);
99 vtkMultiBlockDataSet *ret0=vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
101 if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()))
102 reqTS = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
104 //Client request on ORB.
105 CORBA::ORB_var *OrbC=(CORBA::ORB_var *)this->Orb;
106 CORBA::Object_var obj=(*OrbC)->string_to_object(&IOR[0]);
107 GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow(obj);
109 if(!CORBA::is_nil(geomObj)) {
110 SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
111 Engines::EngineComponent_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","GEOM");
112 GEOM::GEOM_Gen_var geomGen = GEOM::GEOM_Gen::_narrow(aComponent);
113 if ( !CORBA::is_nil( geomGen ) ) {
114 TopoDS_Shape aTopoDSShape = GEOM_Client::get_client().GetShape( geomGen, geomObj );
116 if ( !aTopoDSShape.IsNull() ) {
117 vtkPolyData *ret=GEOM::GetVTKData(aTopoDSShape, this->Deflection);
119 vtkErrorMacro("On geom object CORBA fetching an error occurs !");
122 ret0->SetBlock(0,ret);
128 vtkErrorMacro("Unrecognized CORBA reference!");
130 catch(CORBA::Exception& ex) {
131 vtkErrorMacro("On fetching object error occurs");
136 //----------------------------------------------
137 void vtkParaGEOMCorbaSource::PrintSelf(ostream& os, vtkIndent indent) {
138 this->Superclass::PrintSelf( os, indent );
139 os << "Deflection: " << this->Deflection << "\n";