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. =3B I had hoped to use Perl to ca=
ll the Python bindings for VTK. =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> =3B =3B =3B use Moose=3B<br><b=
r> =3B =3B =3B use Inline::Python qw(py_call_function)=3B<br>&n=
bsp=3B =3B =3B use Inline Python =3D>=3B "import vtk"=3B<br><br>&=
nbsp=3B =3B =3B sub main {<br> =3B =3B =3B  =3B&nbs=
p=3B =3B my $self =3D shift=3B<br> =3B =3B =3B  =3B&nbs=
p=3B =3B my $o =3D \py_call_function("vtk"=2C"vtkPoints"=2C @_)=3B =
=3B =3B =3B  =3B =3B =3B <br> =3B =3B =3B &=
nbsp=3B =3B =3B my $p =3D [0=2C0=2C0]=3B<br> =3B =3B =
=3B  =3B =3B =3B bless $o=2C 'vtk::vtkPoints'=3B<br> =3B&nb=
sp=3B =3B  =3B =3B =3B {<br> =3B =3B =3B  =
=3B =3B =3B  =3B =3B =3B no strict 'refs'=3B<br> =
=3B =3B =3B  =3B =3B =3B  =3B =3B =3B push =
@{ "vtk::vtkPoints::ISA" }=2C 'Inline::Python::Object'=3B<br> =3B =
=3B =3B  =3B =3B =3B }<br> =3B =3B =3B  =3B=
 =3B =3B <br> =3B =3B =3B  =3B =3B =3B $o-&=
gt=3BInsertNextPoint($p)=3B<br> =3B =3B =3B }<br><br> =3B&n=
bsp=3B =3B __PACKAGE__->=3Bmeta->=3Bmake_immutable=3B<br>}<br><br>G=
raphics::VTK->=3Bnew->=3Bmain unless caller=3B<br><br>1=3B<br><br> =
</div></body>
</html>=
--_89b8ab26-b225-40a6-8e98-151b20525f9f_--