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.
#!/bin/perl
use strict;
use warnings;
use feature 'say';
package Graphics::VTK {
use Moose;
use Inline::Python qw(py_call_function);
use Inline Python => "import vtk";
sub main {
my $self = shift;
my $o = \py_call_function("vtk","vtkPoints", @_);
my $p = [0,0,0];
bless $o, 'vtk::vtkPoints';
{
no strict 'refs';
push @{ "vtk::vtkPoints::ISA" }, 'Inline::Python::Object';
}
$o->InsertNextPoint($p);
}
__PACKAGE__->meta->make_immutable;
}
Graphics::VTK->new->main unless caller;
1;