"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Graphics/TriD/TriD/GL.pm" between
PDL-2.078.tar.gz and PDL-2.079.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

GL.pm  (PDL-2.078):GL.pm  (PDL-2.079)
skipping to change at line 380 skipping to change at line 380
push @pdls, $this->{Colors}; push @pdls, $this->{Colors};
_lattice_slice($f, @pdls); _lattice_slice($f, @pdls);
$this->_lattice_lines($points) if $this->{Options}{Lines}; $this->_lattice_lines($points) if $this->{Options}{Lines};
}; };
{ local $@; glPopAttrib(); } { local $@; glPopAttrib(); }
die if $@; die if $@;
} }
sub PDL::Graphics::TriD::STrigrid_S::gdraw { sub PDL::Graphics::TriD::STrigrid_S::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
my $faces = $points->dice_axis(1,$this->{Faceidx}->clump(-1))->splitdim(1,3);
glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT); glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
$this->glOptions; $this->glOptions;
eval { eval {
# For some reason, we need to set this here as well. # For some reason, we need to set this here as well.
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
# By-vertex doesn't make sense otherwise. # By-vertex doesn't make sense otherwise.
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
my @sls = (":,(0)",":,(1)",":,(2)"); my @sls = (":,(0)",":,(1)",":,(2)");
my $idx = [0,1,2,0]; # for lines, below my $idx = [0,1,2,0]; # for lines, below
if ($this->{Options}{Smooth}) { if ($this->{Options}{Smooth}) {
my $f=\&PDL::gl_triangles_wn_mat;
my $tmpn=$this->{Normals}->dice_axis(1,$this->{Faceidx}->clump(-1)) my $tmpn=$this->{Normals}->dice_axis(1,$this->{Faceidx}->clump(-1))
->splitdim(1,$this->{Faceidx}->dim(0)); ->splitdim(1,$this->{Faceidx}->dim(0));
my @args=((map {$this->{Faces}->slice($_)} @sls), # faces is a slice of PDL::gl_triangles_wn_mat(map $_->mv(1,-1)->dog, $faces, $tmpn, $this->{Col
points ors});
(map {$tmpn->slice($_)} @sls), if ($this->{Options}{ShowNormals}) {
(map {$this->{Colors}->slice($_)} @sls) );&$f(@args); my $arrows = $points->append($points + $this->{Normals}*0.1)->splitdim(0,
3);
glDisable(GL_LIGHTING);
glColor3d(1,1,1);
PDL::Graphics::OpenGLQ::gl_arrows($arrows, 0, 1, 0.5, 0.02);
my $facecentres = $faces->transpose->avgover;
my $facearrows = $facecentres->append($facecentres + $this->{FaceNormals}
*0.1)->splitdim(0,3);
glColor3d(0.5,0.5,0.5);
PDL::Graphics::OpenGLQ::gl_arrows($facearrows, 0, 1, 0.5, 0.02);
}
} else { } else {
my $f=\&PDL::gl_triangles_n_mat; PDL::gl_triangles_n_mat(map $_->mv(1,-1)->dog, $faces, $this->{Colors});
&$f( (map {$this->{Faces}->slice($_)} @sls), # faces is a slice of point
s
(map {$this->{Colors}->slice($_)} @sls) );
} }
if ($this->{Options}{Lines}) { if ($this->{Options}{Lines}) {
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glColor3f(0,0,0); glColor3f(0,0,0);
PDL::gl_lines_nc($this->{Faces}->dice_axis(1,$idx)); PDL::gl_lines_nc($this->{Faces}->dice_axis(1,$idx));
} }
}; };
{ local $@; glPopAttrib(); } { local $@; glPopAttrib(); }
die if $@; die if $@;
} }
sub PDL::Graphics::TriD::STrigrid::gdraw { sub PDL::Graphics::TriD::STrigrid::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
my $faces = $points->dice_axis(1,$this->{Faceidx}->clump(-1))->splitdim(1,3);
# faces is 3D pdl slices of points, giving cart coords of face verts
glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT); glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
$this->glOptions; $this->glOptions;
eval { eval {
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
# By-vertex doesn't make sense otherwise. # By-vertex doesn't make sense otherwise.
glShadeModel (GL_SMOOTH); glShadeModel(GL_SMOOTH);
my @sls = (":,(0)",":,(1)",":,(2)"); PDL::gl_triangles(map $_->mv(1,-1)->dog, $faces, $this->{Colors});
my $idx = [0,1,2,0];
PDL::gl_triangles(
(map {$this->{Faces}->slice($_)} @sls), # faces is a slice of points
(map {$this->{Colors}->slice($_)} @sls));
if ($this->{Options}{Lines}) { if ($this->{Options}{Lines}) {
glColor3f(0,0,0); glColor3f(0,0,0);
PDL::gl_lines_nc($this->{Faces}->dice_axis(1,$idx)); PDL::gl_lines_nc($faces->dice_axis(1, [0,1,2,0]));
} }
}; };
{ local $@; glPopAttrib(); } { local $@; glPopAttrib(); }
die if $@; die if $@;
} }
################################## ##################################
# PDL::Graphics::TriD::Image # PDL::Graphics::TriD::Image
sub PDL::Graphics::TriD::Image::togl { sub PDL::Graphics::TriD::Image::togl {
# A special construct which always faces the display and takes the entire window # A special construct which always faces the display and takes the entire window
 End of changes. 7 change blocks. 
17 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)