@@ -148,16 +148,14 @@ sub new {
148148 if (!defined $options and ref $colors eq " HASH" ) {
149149 $options = $colors ;undef $colors ; }
150150 $points = PDL::Graphics::TriD::realcoords($type -> r_type,$points );
151- my $faces = $points -> dice_axis(1,$faceidx -> flat)-> splitdim(1,3);
152- # faces is 3D pdl slices of points, giving cart coords of face verts
153151 if (!defined $colors ) { $colors = PDL-> pdl(PDL::float(),0.8,0.8,0.8);
154- $colors = $type -> cdummies($colors ,$faces );
152+ $colors = $type -> cdummies($colors ,$points );
155153 $options -> { UseDefcols } = 1; } # for VRML efficiency
156154 else { $colors = PDL::Graphics::TriD::realcoords(" COLOR" ,$colors ); }
157155 my $this = bless { Points => $points , Faceidx => $faceidx ,
158156 Colors => $colors , Options => $options },$type ;
159157 $this -> check_options;
160- $this -> {Normals } = $this -> smoothn($faces ) if $this -> {Options }{Smooth };
158+ $this -> {Normals } = $this -> smoothn($points -> dice_axis(1, $faceidx -> flat) -> splitdim(1,3) ) if $this -> {Options }{Smooth };
161159 $this ;
162160}
163161sub get_valid_options { +{
@@ -168,10 +166,11 @@ sub get_valid_options { +{
168166 ShowNormals => 0,
169167 Lighting => 1,
170168}}
171- sub cdummies { # called with (type,colors,faces )
172- return $_ [1]-> dummy(1,$_ [2]-> getdim(2 ))-> dummy(1,$_ [2] -> getdim(1) ); }
169+ sub cdummies { # called with (type,colors,points )
170+ return $_ [1]-> dummy(1,$_ [2]-> getdim(1 ))-> dummy(1,3 ); }
173171sub smoothn { my ($this , $faces ) = @_ ;
174172 my ($points , $faceidx ) = @$this {qw( Points Faceidx) };
173+ # faces is 3D pdl slices of points, giving cart coords of face verts
175174 my @p = $faces -> mv(1,-1)-> dog;
176175 my $fn = ($p [1]-$p [0])-> crossp($p [2]-$p [1])-> norm; # flat faces, >= 3 points
177176 $this -> {FaceNormals } = $fn if $this -> {Options }{ShowNormals };
0 commit comments