Changeset 5635 for trunk/gui


Ignore:
Timestamp:
May 29, 2015 7:24:15 PM (9 years ago)
Author:
ldelgass
Message:

Structured grid fixes for Rappture::Mesh

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/mesh.tcl

    r5633 r5635  
    540540        set numCoords [$all length]
    541541        if { [info exists zNum] } {
     542            if { ![info exists yNum] || ![info exists xNum] } {
     543                puts stderr "WARNING: bad grid \"$path\": missing grid dimension"
     544                blt::vector destroy $all $xv $yv $zv
     545                return 0
     546            }
    542547            set _dim 3
    543548            set _numPoints [expr $xNum * $yNum * $zNum]
     
    545550            if { ($_numPoints*3) != $numCoords } {
    546551                puts stderr "WARNING: bad grid \"$path\": invalid grid: \# of points does not match dimensions <xdim> * <ydim> * <zdim>"
     552                blt::vector destroy $all $xv $yv $zv
    547553                return 0
    548554            }
    549555            if { ($numCoords % 3) != 0 } {
    550556                puts stderr "WARNING: bad grid \"$path\": wrong \# of coordinates for 3D grid"
     557                blt::vector destroy $all $xv $yv $zv
    551558                return 0
    552559            }
     
    559566            append out "DIMENSIONS $xNum $yNum $zNum\n"
    560567            append out "POINTS $_numPoints double\n"
    561             append out [$all range 0 end]
    562             append out "\n"
     568            foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     569                append out "$x $y $z\n"
     570            }
    563571            set _vtkdata $out
    564572        } elseif { [info exists yNum] } {
     573            if { ![info exists xNum] } {
     574                puts stderr "WARNING: bad grid \"$path\": missing grid dimension"
     575                blt::vector destroy $all $xv $yv $zv
     576                return 0
     577            }
    565578            set _dim 2
    566579            set _numPoints [expr $xNum * $yNum]
     
    568581            if { ($_numPoints*2) != $numCoords } {
    569582                puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions <xdim> * <ydim>"
     583                blt::vector destroy $all $xv $yv $zv
    570584                return 0
    571585            }
    572586            if { ($numCoords % 2) != 0 } {
    573587                puts stderr "WARNING: bad grid \"$path\": wrong \# of coordinates for 2D grid"
     588                blt::vector destroy $all $xv $yv $zv
    574589                return 0
    575590            }
     591            $all split $xv $yv
    576592            foreach axis {x y} {
    577593                set vector [set ${axis}v]
     
    584600            append out "DIMENSIONS $xNum $yNum 1\n"
    585601            append out "POINTS $_numPoints double\n"
    586             append out [$all range 0 end]
    587             append out "\n"
     602            foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     603                append out "$x $y $z\n"
     604            }
    588605            set _vtkdata $out
    589606        } else {
     
    593610            if { $_numPoints != $numCoords } {
    594611                puts stderr "WARNING: bad grid \"$path\": \# of points does not match <xdim>"
     612                blt::vector destroy $all $xv $yv $zv
    595613                return 0
    596614            }
     615            $all dup $xv
    597616            set _limits(x) [$xv limits]
    598617            set _limits(y) [list 0 0]
     
    604623            append out "DIMENSIONS $xNum 1 1\n"
    605624            append out "POINTS $_numPoints double\n"
    606             append out [$all range 0 end]
    607             append out "\n"
     625            foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     626                append out "$x $y $z\n"
     627            }
    608628            set _vtkdata $out
    609629        }
Note: See TracChangeset for help on using the changeset viewer.