@@ -45,26 +45,22 @@ use fields qw/Points Colors Options/;
4545$PDL::Graphics::TriD::verbose //= 0;
4646
4747sub new {
48- my ($type ,$points ,$colors ,$options ) = @_ ;
49- print " GObject new.. calling SUPER::new...\n " if ($PDL::Graphics::TriD::verbose );
50- my $this = $type -> SUPER::new();
51- print " GObject new - back (SUPER::new returned $this )\n " if ($PDL::Graphics::TriD::verbose );
52- if (!defined $options and ref $colors eq " HASH" ) {
53- $options = $colors ;
54- undef $colors ;
55- }
56- $options = { $options ? %$options : () };
57- $options -> {UseDefcols } = 1 if !defined $colors ; # for VRML efficiency
58- $this -> {Options } = $options ;
59- $this -> check_options;
60- print " GObject new - calling realcoords\n " if ($PDL::Graphics::TriD::verbose );
61- $this -> {Points } = $points = PDL::Graphics::TriD::realcoords($type -> r_type,$points );
62- print " GObject new - back from realcoords\n " if ($PDL::Graphics::TriD::verbose );
63- $this -> {Colors } = defined $colors
64- ? PDL::Graphics::TriD::realcoords(" COLOR" ,$colors )
65- : $this -> cdummies(PDL-> pdl(PDL::float(),1,1,1),$points );
66- print " GObject new - returning\n " if ($PDL::Graphics::TriD::verbose );
67- return $this ;
48+ my $options = ref ($_ [-1]) eq ' HASH' ? pop : {};
49+ my ($type ,$points ,$colors ) = @_ ;
50+ print " GObject new.. calling SUPER::new...\n " if $PDL::Graphics::TriD::verbose ;
51+ my $this = $type -> SUPER::new();
52+ print " GObject new - back (SUPER::new returned $this )\n " if $PDL::Graphics::TriD::verbose ;
53+ $options -> {UseDefcols } = 1 if !defined $colors ; # for VRML efficiency
54+ $this -> {Options } = $options ;
55+ $this -> check_options;
56+ print " GObject new - calling realcoords\n " if ($PDL::Graphics::TriD::verbose );
57+ $this -> {Points } = $points = PDL::Graphics::TriD::realcoords($type -> r_type,$points );
58+ print " GObject new - back from realcoords\n " if ($PDL::Graphics::TriD::verbose );
59+ $this -> {Colors } = defined $colors
60+ ? PDL::Graphics::TriD::realcoords(" COLOR" ,$colors )
61+ : $this -> cdummies(PDL-> pdl(PDL::float(),1,1,1),$points );
62+ print " GObject new - returning\n " if ($PDL::Graphics::TriD::verbose );
63+ return $this ;
6864}
6965
7066sub check_options {
@@ -142,11 +138,10 @@ sub get_valid_options { +{
142138package PDL::Graphics::TriD::Trigrid ;
143139use base qw/ PDL::Graphics::TriD::GObject/ ;
144140sub new {
145- my ($type ,$points ,$faceidx ,$colors ,$options ) = @_ ;
141+ my $options = ref ($_ [-1]) eq ' HASH' ? pop : {};
142+ my ($type ,$points ,$faceidx ,$colors ) = @_ ;
146143 # faceidx is 2D pdl of indices into points for each face
147144 $faceidx = $faceidx -> ulong;
148- if (!defined $options and ref $colors eq " HASH" ) {
149- $options = $colors ;undef $colors ; }
150145 $points = PDL::Graphics::TriD::realcoords($type -> r_type,$points );
151146 if (!defined $colors ) { $colors = PDL-> pdl(PDL::float(),0.8,0.8,0.8);
152147 $colors = $type -> cdummies($colors ,$points );
0 commit comments