develooper Front page | perl.inline | Postings from May 2016

How do I create a VTK object from Perl using Inline::Python?

Thread Next
From:
Jason McVeigh
Date:
May 20, 2016 17:17
Subject:
How do I create a VTK object from Perl using Inline::Python?
Message ID:
BAY169-W5C03C747AB7EFD15D285CCD4B0@phx.gbl
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;

 		 	   		  
Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About