The idea was to use perl objects and vtk at the same time Either this approach - more perl/OO centric:
use strict; use Tcl; my $int = new Tcl; $int->Init; for my $name (qw( vtkRenderer vtkTkRenderWidget vtkRenderWindow vtkColor3d vtkColorTransferFunction vtkTextActor3D package mainwindow pack focus tkwait scale update ren1 renwin lut )) { no strict 'refs'; *{"Tcl::$name"} = sub {shift->call($name,@_)}; } $int->package(require=>'Tk'); $int->package(require=>'vtk'); $int->package(require=>'vtkinteraction'); # Renderer, renwin $int->vtkRenderer('ren1'); $int->ren1('SetBackground', 0.1, 0.2, 0.4); $int->vtkRenderWindow('renwin'); $int->renwin(AddRenderer => 'ren1'); $int->renwin(SetSize => 600, 600); # The Tk render widget $int->vtkTkRenderWidget('.ren', -width=>450, -height=>450, -rw =>'renwin'); $int->pack('.ren',-fill=>'both',-expand=>1); $int->icall("vtk::bind_tk_render_widget",'.ren'); #$int->Eval('[[renwin GetInteractor] GetInteractorStyle] SetCurrentStyleToTrackballCamera'); $int->icall( $int->icall( $int->renwin(GetInteractor=>), GetInteractorStyle=>), SetCurrentStyleToTrackballCamera=>); # Add text 'actor'-s $int->vtkColorTransferFunction('lut'); $int->lut(SetColorSpaceToHSV=>); $int->lut(AddRGBPoint=>0.0,0.0,1.0,1.0); $int->lut(AddRGBPoint=>1.0,1.0,1.0,1.0); for my $i (0 .. 9) { $int->vtkTextActor3D("ia$i"); $int->icall("ia$i", SetOrientation => 0, $i*36, 0); $int->icall("ia$i", SetPosition => cos($i * 0.0314), 0, 0); $int->icall("ia$i", SetScale=>0.0025); $int->icall("ia$i", SetInput=>"hello world"); my $tprop = $int->icall("ia$i", 'GetTextProperty'); $int->icall($tprop, SetColor=> $int->lut(GetColor=>$i/10.0)); $int->icall($tprop, SetFontSize=>48); $int->icall($tprop, ShadowOn=>); $int->icall($tprop, SetFontFamilyToArial=>); $int->ren1(AddActor=>"ia$i"); } $int->lut('Delete'); my $cam = $int->ren1(GetActiveCamera=>); $int->icall($cam,Elevation=>30); $int->icall($cam,Dolly=>0.4); $int->ren1(ResetCamera=>); $int->pack($int->scale('.sc1',-from=>0,-to=>100,-showvalue=>0,-orient=>'horizontal', -command=>sub{ $int->icall('coneActor', SetScale => $int->icall('.sc1','get')/100); $int->renwin(Render=>); })); $int->Eval(' vtkConeSource cone cone SetResolution 80 vtkPolyDataMapper mapper mapper SetInput [cone GetOutput] vtkActor coneActor coneActor SetMapper mapper coneActor SetScale 0.5 # assign our actor to the renderer ren1 AddActor coneActor'); $int->tkwait(window=>'.'); ----or this approach - more Tcl/centric: # example example example..... # use strict; use Tcl; my $int = new Tcl; $int->Init; $int->export_tcl_namespace; # build the GUI: $int->Eval(<<'EOS'); package require Tk pack [frame .f] -fill x -expand 0 pack [panedwindow .pw -showhandle 1 -sashrelief raised -orient horizontal] -fill both -expand 1 .pw add \ [text .pw.st -width 20 -height 7] \ [canvas .pw.sc -width 600 -height 400 -scrollregion {0 0 1000 1200}] .pw.st insert end Hi! pack [frame .fb] pack [button .fb.b1 -text {proba 1 (F9)} -command perl::prouba1] -side left -expand 1 bind . <F9> {.fb.b1 invoke} package require vtk package require vtkrendering package require vtkinteraction [vtkRenderWindow renw] AddRenderer [vtkRenderer ren1] ren1 SetBackground 0.1 0.2 0.4 # The Tk render widget vtkTkRenderWidget .pw.sc.ren -width 450 -height 450 -rw renw .pw.sc create window 5 5 -window .pw.sc.ren -anchor nw -width 350 -height 350 ::vtk::bind_tk_render_widget .pw.sc.ren # enable user interface interactor [[renw GetInteractor] GetInteractorStyle] SetCurrentStyleToTrackballCamera vtkUnstructuredGridReader rdr rdr SetFileName "/usr/VTKData/Data/hexa.vtk" rdr SetFileName "/usr/VTKData/Data/blow.vtk" rdr SetFileName "/usr/VTKData/Data/PentaHexa.vtk" vtkDataSetMapper moldMapper moldMapper SetInputConnection [rdr GetOutputPort] vtkActor moldActor moldActor SetMapper moldMapper [moldActor GetProperty] SetColor .2 .2 .2 moldActor SetScale 0.2 pack [button .f.b1 -text {SetRepresentationToWireframe} -command {[moldActor GetProperty] SetRepresentationToWireframe; ren1 Render }] -side left # assign our actor to the renderer ren1 AddActor moldActor wm protocol . WM_DELETE_WINDOW {destroy renw; exit} EOS # </>build the GUI: sub tcl::prouba1 { $int->icall(puts=>"hi, I'm here"); } $int->icall(tkwait=> window=>'.'); It would be nice if you'll take it lying on the floor and give it breath of a life:) From: Jason McVeigh [mailto:jmcve...@outlook.com] Sent: Sunday, May 22, 2016 2:27 PM To: Konovalov, Vadim Subject: RE: How do I create a VTK object from Perl using Inline::Python? Great. This is a nice head-start. I found the Tcl bindings for VTK. At this time they are both current and accessible. I'll spend some time with this and I'll report the results. I may have further questions. I thank you both for your time and consideration. ________________________________ From: vadim.konova...@emc.com<mailto:vadim.konova...@emc.com> To: jmcve...@outlook.com<mailto:jmcve...@outlook.com>; inline@perl.org<mailto:inline@perl.org> Subject: RE: How do I create a VTK object from Perl using Inline::Python? Date: Sat, 21 May 2016 18:12:05 +0000 > From: Jason McVeigh > > How do I create a VTK object from Perl using > Inline::Python? > > I am using the Visualization Toolkit (http://vtk.org) for > 3D visualizations. I had hoped to use Perl to call the > Python bindings for VTK. I have some example code below, > however, I get a segmentation fault due to something wrong. I used Tcl from Perl - at moment when vTk had close bindings to Tcl, and even made a talk at our Spb perl conference This provided me with just fine perl OO classes, but this relied on vTk<->tcl binding, which no more supported by vtk.org, (very unfortunately) Can provide more information if this is a possible way for you Regards, Vadim.