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

[email protected] (Jason McVeigh) Fri, 20 May 2016 13:16:59 -0400
Newsgroups perl.inline
Message-ID <[email protected]>
--_89b8ab26-b225-40a6-8e98-151b20525f9f_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

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 som=
e example code below=2C however=2C I get a segmentation fault due to someth=
ing wrong.

#!/bin/perl

use strict=3B
use warnings=3B

use feature 'say'=3B

package Graphics::VTK {
    use Moose=3B

    use Inline::Python qw(py_call_function)=3B
    use Inline Python =3D> "import vtk"=3B

    sub main {
        my $self =3D shift=3B
        my $o =3D \py_call_function("vtk"=2C"vtkPoints"=2C @_)=3B       =20
        my $p =3D [0=2C0=2C0]=3B
        bless $o=2C 'vtk::vtkPoints'=3B
        {
            no strict 'refs'=3B
            push @{ "vtk::vtkPoints::ISA" }=2C 'Inline::Python::Object'=3B
        }
       =20
        $o->InsertNextPoint($p)=3B
    }

    __PACKAGE__->meta->make_immutable=3B
}

Graphics::VTK->new->main unless caller=3B

1=3B

 		 	   		  =

--_89b8ab26-b225-40a6-8e98-151b20525f9f_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px=3B
padding:0px
}
body.hmmessage
{
font-size: 12pt=3B
font-family:Calibri
}
--></style></head>
<body class=3D'hmmessage'><div dir=3D'ltr'>How do I create a VTK object fro=
m Perl using Inline::Python?<br><br>I am using the Visualization Toolkit (h=
ttp://vtk.org) for 3D visualizations.&nbsp=3B I had hoped to use Perl to ca=
ll the Python bindings for VTK.&nbsp=3B I have some example code below=2C h=
owever=2C I get a segmentation fault due to something wrong.<br><br>#!/bin/=
perl<br><br>use strict=3B<br>use warnings=3B<br><br>use feature 'say'=3B<br=
><br>package Graphics::VTK {<br>&nbsp=3B&nbsp=3B&nbsp=3B use Moose=3B<br><b=
r>&nbsp=3B&nbsp=3B&nbsp=3B use Inline::Python qw(py_call_function)=3B<br>&n=
bsp=3B&nbsp=3B&nbsp=3B use Inline Python =3D&gt=3B "import vtk"=3B<br><br>&=
nbsp=3B&nbsp=3B&nbsp=3B sub main {<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbs=
p=3B&nbsp=3B my $self =3D shift=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbs=
p=3B&nbsp=3B my $o =3D \py_call_function("vtk"=2C"vtkPoints"=2C @_)=3B&nbsp=
=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B <br>&nbsp=3B&nbsp=3B&nbsp=3B &=
nbsp=3B&nbsp=3B&nbsp=3B my $p =3D [0=2C0=2C0]=3B<br>&nbsp=3B&nbsp=3B&nbsp=
=3B &nbsp=3B&nbsp=3B&nbsp=3B bless $o=2C 'vtk::vtkPoints'=3B<br>&nbsp=3B&nb=
sp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B {<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=
=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B no strict 'refs'=3B<br>&nbsp=
=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B push =
@{ "vtk::vtkPoints::ISA" }=2C 'Inline::Python::Object'=3B<br>&nbsp=3B&nbsp=
=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B }<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B=
&nbsp=3B&nbsp=3B <br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B $o-&=
gt=3BInsertNextPoint($p)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B }<br><br>&nbsp=3B&n=
bsp=3B&nbsp=3B __PACKAGE__-&gt=3Bmeta-&gt=3Bmake_immutable=3B<br>}<br><br>G=
raphics::VTK-&gt=3Bnew-&gt=3Bmain unless caller=3B<br><br>1=3B<br><br> 		 	=
   		  </div></body>
</html>=

--_89b8ab26-b225-40a6-8e98-151b20525f9f_--