Skip to content

Commit 2d492b6

Browse files
committed
Trigrid use superclass constructor
1 parent a178db1 commit 2d492b6

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

lib/PDL/Graphics/TriD/Objects.pm

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,13 @@ sub get_valid_options { +{
137137

138138
package PDL::Graphics::TriD::Trigrid;
139139
use base qw/PDL::Graphics::TriD::GObject/;
140+
use fields qw/Faceidx FaceNormals Normals/;
140141
sub new {
141142
my $options = ref($_[-1]) eq 'HASH' ? pop : {};
142143
my($type,$points,$faceidx,$colors) = @_;
144+
my $this = $type->SUPER::new($points,$colors,$options);
143145
# faceidx is 2D pdl of indices into points for each face
144-
$faceidx = $faceidx->ulong;
145-
$points = PDL::Graphics::TriD::realcoords($type->r_type,$points);
146-
if(!defined $colors) { $colors = PDL->pdl(PDL::float(),0.8,0.8,0.8);
147-
$colors = $type->cdummies($colors,$points);
148-
$options->{ UseDefcols } = 1; } # for VRML efficiency
149-
else { $colors = PDL::Graphics::TriD::realcoords("COLOR",$colors); }
150-
my $this = bless { Points => $points, Faceidx => $faceidx,
151-
Colors => $colors, Options => $options},$type;
152-
$this->check_options;
146+
$this->{Faceidx} = $faceidx->ulong;
153147
$this->{Normals} = $this->smoothn($points->dice_axis(1,$faceidx->flat)->splitdim(1,3)) if $this->{Options}{Smooth};
154148
$this;
155149
}

0 commit comments

Comments
 (0)