@@ -55,20 +55,16 @@ sub new {
5555 my $options = ref ($_ [-1]) eq ' HASH' ? pop : {};
5656 my ($type ,$points ,$colors ) = @_ ;
5757 my $this = $type -> SUPER::new($options );
58- $this -> {Points } = $points = PDL::Graphics::TriD::realcoords ($type -> r_type,$points );
58+ $this -> {Points } = $points = $this -> normalise_as ($type -> r_type,$points );
5959 $this -> {Options }{UseDefcols } = 1 if !defined $colors ; # for VRML efficiency
60- $this -> {Colors } = defined $colors
61- ? PDL::Graphics::TriD::realcoords(" COLOR" ,$colors )
62- : $this -> cdummies(PDL-> pdl(PDL::float(),1,1,1),$points );
60+ $this -> {Colors } = $this -> normalise_as(" COLOR" ,$colors ,$points );
6361 $this ;
6462}
6563
6664sub set_colors {
6765 my ($this ,$colors ) = @_ ;
68- if (ref ($colors ) eq " ARRAY" ){
69- $colors = PDL::Graphics::TriD::realcoords(" COLOR" ,$colors );
70- }
71- $this -> {Colors }=$colors ;
66+ $colors = $this -> normalise_as(" COLOR" ,$colors ) if ref ($colors ) eq " ARRAY" ;
67+ $this -> {Colors } = $colors ;
7268 $this -> data_changed;
7369}
7470
@@ -132,7 +128,7 @@ sub new {
132128 $less {Shading } = 3 if $options -> {Shading };
133129 $this -> add_object(PDL::Graphics::TriD::Triangles-> new($points , $faceidx -> clump(1..$faceidx -> ndims-1), $colors , \%less ));
134130 if ($options -> {Lines }) {
135- $points = PDL::Graphics::TriD::realcoords ($type -> r_type,$points );
131+ $points = $this -> normalise_as ($type -> r_type,$points );
136132 my $faces = $points -> dice_axis(1,$faceidx -> flat)-> splitdim(1,3);
137133 $this -> add_object(PDL::Graphics::TriD::Lines-> new($faces -> dice_axis(1,[0,1,2,0]), PDL::float(0,0,0)));
138134 }
@@ -166,7 +162,7 @@ sub new {
166162 $this -> {FaceNormals } = $fn if !$options -> {Smooth };
167163 }
168164 if ($options -> {ShowNormals }) {
169- $points = PDL::Graphics::TriD::realcoords ($type -> r_type,$points );
165+ $points = $this -> normalise_as ($type -> r_type,$points );
170166 my $faces = $points -> dice_axis(1,$faceidx -> flat)-> splitdim(1,3);
171167 my $facecentres = $faces -> transpose-> avgover;
172168 my $facearrows = $facecentres -> append($facecentres + $fn *0.1)-> splitdim(0,3)-> clump(1,2);
@@ -260,7 +256,7 @@ sub new {
260256 my $this = $class -> SUPER::new($options );
261257 $options = $this -> {Options };
262258 my ($from , $to , $w , $hl ) = delete @$options {qw( From To ArrowWidth ArrowLen) };
263- $points = PDL::Graphics::TriD::realcoords ($class -> r_type,$points );
259+ $points = $this -> normalise_as ($class -> r_type,$points );
264260 $this -> add_object(PDL::Graphics::TriD::Lines-> new(
265261 $points -> dice_axis(1,$from )-> flowing-> append($points -> dice_axis(1,$to ))-> splitdim(0,3),
266262 $colors , $options
0 commit comments