Skip to content

Commit 0324e29

Browse files
committed
::Lattice points must be 3,x,y
1 parent 02f63d9 commit 0324e29

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

lib/PDL/Graphics/TriD/Objects.pm

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -254,24 +254,24 @@ sub new {
254254
$colors = $this->normalise_as("COLOR",$colors,$points);
255255
$options = $this->{Options};
256256
my $shading = $options->{Shading};
257-
my (undef, $x, $y, @extradims) = $points->dims;
257+
my ($tri, $x, $y, @extradims) = $points->dims;
258+
PDL::barf "Lattice: points must be 3,x,y: got ($x $y @extradims)" if @extradims or $tri != 3;
258259
if ($shading) {
259260
my $inds = PDL::ulong(0,1,$x,$x+1,$x,1)->slice(',*'.($x-1).',*'.($y-1));
260-
$inds = $inds->dupN(1,1,@extradims) if @extradims;
261-
my $indadd = PDL->sequence($x,$y,@extradims)->slice('*1,:-2,:-2');
262-
my $faceidx = ($inds + $indadd)->splitdim(0,3)->clump(1..3+@extradims);
261+
my $indadd = PDL->sequence($x,$y)->slice('*1,:-2,:-2');
262+
my $faceidx = ($inds + $indadd)->splitdim(0,3)->clump(1..3);
263263
my %less = %$options; delete @less{qw(Lines)};
264-
$this->add_object(PDL::Graphics::TriD::Triangles->new($points->clump(1..2+@extradims), $faceidx, $colors->clump(1..$colors->ndims-1), \%less));
264+
$this->add_object(PDL::Graphics::TriD::Triangles->new($points->clump(1..2), $faceidx, $colors->clump(1..$colors->ndims-1), \%less));
265265
}
266266
if ($shading == 0 or $options->{Lines}) {
267267
my $lcolors = $shading ? $this->cdummies(PDL::float(0,0,0),$points) : $colors;
268-
my $counts = (PDL->ones(PDL::long, $y, @extradims) * $x)->flat;
269-
my $starts = (PDL->sequence(PDL::ulong, $y, @extradims) * $x)->flat;
270-
my $indices = PDL->sequence(PDL::ulong, $x, $y, @extradims)->flat;
271-
$counts = $counts->append((PDL->ones(PDL::long, $x, @extradims) * $y)->flat);
272-
$starts = $starts->append((PDL->sequence(PDL::ulong, $x, @extradims) * $y)->flat + $indices->nelem);
273-
$indices = $indices->append(PDL->sequence(PDL::ulong, $x, $y, @extradims)->t->flat);
274-
$this->add_object(PDL::Graphics::TriD::DrawMulti->new($points->clump(1..2+@extradims), $lcolors->clump(1..2+@extradims), 'linestrip', $counts, $starts, $indices));
268+
my $counts = (PDL->ones(PDL::long, $y) * $x)->flat;
269+
my $starts = (PDL->sequence(PDL::ulong, $y) * $x)->flat;
270+
my $indices = PDL->sequence(PDL::ulong, $x, $y)->flat;
271+
$counts = $counts->append((PDL->ones(PDL::long, $x) * $y)->flat);
272+
$starts = $starts->append((PDL->sequence(PDL::ulong, $x) * $y)->flat + $indices->nelem);
273+
$indices = $indices->append(PDL->sequence(PDL::ulong, $x, $y)->t->flat);
274+
$this->add_object(PDL::Graphics::TriD::DrawMulti->new($points->clump(1..2), $lcolors->clump(1..2), 'linestrip', $counts, $starts, $indices));
275275
}
276276
$this;
277277
}

0 commit comments

Comments
 (0)