@@ -13,6 +13,7 @@ This provides the following class hierarchy:
1313 PDL::Graphics::TriD::Object base class for containers
1414 ├ PDL::Graphics::TriD::Arrows lines with arrowheads
1515 ├ PDL::Graphics::TriD::Trigrid polygons
16+ ├ PDL::Graphics::TriD::Lattice colored lattice, maybe filled/shaded
1617 └ PDL::Graphics::TriD::GObject (abstract) base class for drawables
1718
1819 PDL::Graphics::TriD::GObject (abstract) base class for drawables
@@ -21,7 +22,6 @@ This provides the following class hierarchy:
2122 ├ PDL::Graphics::TriD::Lines separate lines
2223 ├ PDL::Graphics::TriD::LineStrip continuous paths
2324 ├ PDL::Graphics::TriD::Triangles just polygons
24- ├ PDL::Graphics::TriD::Lattice colored lattice, maybe filled/shaded
2525 └ PDL::Graphics::TriD::Labels text labels
2626
2727=head1 DESCRIPTION
@@ -195,11 +195,10 @@ sub cdummies { $_[1]->dummy(1,$_[2]->getdim(1)); }
195195# 0 1 2 3 4,0,1,1,5,4 5,1,2,2,6,5 6,2,3,3,7,6
196196package PDL::Graphics::TriD::Lattice ;
197197use PDL::Graphics::OpenGLQ;
198- use base qw/ PDL::Graphics::TriD::GObject / ;
198+ use base qw/ PDL::Graphics::TriD::Object / ;
199199sub cdummies {
200200 my $shading = $_ [0]{Options }{Shading };
201201 !$shading ? $_ [1]-> dummy(1)-> dummy(1) :
202- $shading == 1 ? $_ [1]-> dummy(1,$_ [2]-> getdim(2)-1)-> dummy(1,$_ [2]-> getdim(1)-1) :
203202 $_ [1]-> slice(" :," . join ' ,' , map " *$_ " , ($_ [2]-> dims)[1,2])
204203}
205204sub r_type {return " SURF2D" ;}
@@ -212,10 +211,14 @@ sub get_valid_options { +{
212211 ShowNormals => 0,
213212}}
214213sub new {
215- my ($class ,$points ,$colors ,$options ) = @_ ;
216- my $this = $class -> SUPER::new($points ,$colors ,$options );
217- ($points , $options ) = @$this {qw( Points Options) };
218- if ($options -> {Shading } or $options -> {ShowNormals }) {
214+ my $options = ref ($_ [-1]) eq ' HASH' ? pop : {};
215+ my ($class ,$points ,$colors ) = @_ ;
216+ my $this = $class -> SUPER::new($options );
217+ $points = $this -> normalise_as($class -> r_type,$points );
218+ $colors = $this -> normalise_as(" COLOR" ,$colors ,$points );
219+ $options = $this -> {Options };
220+ my $shading = $options -> {Shading };
221+ if ($shading ) {
219222 my (undef , $x , $y , @extradims ) = $points -> dims;
220223 my $inds = PDL::ulong(0,1,$x ,$x +1,$x ,1)-> slice(' ,*' .($x -1).' ,*' .($y -1));
221224 $inds = $inds -> dupN(1,1,@extradims ) if @extradims ;
@@ -224,6 +227,11 @@ sub new {
224227 my %less = %$options ; delete @less {qw( Lines) };
225228 $this -> add_object(PDL::Graphics::TriD::Triangles-> new($points -> clump(1..2+@extradims ), $faceidx , $colors , \%less ));
226229 }
230+ if ($shading == 0 or $options -> {Lines }) {
231+ my $lcolors = $shading ? $this -> cdummies(PDL::float(0,0,0),$points ) : $colors ;
232+ $this -> add_object(PDL::Graphics::TriD::LineStrip-> new($points , $lcolors ));
233+ $this -> add_object(PDL::Graphics::TriD::LineStrip-> new($points -> xchg(1,2), $lcolors -> xchg(1,2)));
234+ }
227235 $this ;
228236}
229237
0 commit comments