Ignore:
Timestamp:
May 20, 2015 2:09:58 PM (9 years ago)
Author:
ldelgass
Message:

Add validation checks on valid <elemesize> values for given <elemtype>.

File:
1 edited

Legend:

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

    r5579 r5582  
    158158    private variable _comp2style;       # cname => style settings
    159159    private variable _comp2cntls;       # cname => x,y control points (1D only)
    160     private variable _comp2limits;      # Array of limits per component
    161     private variable _comp2flowhints
     160    private variable _comp2limits;      # cname => List of axis, min/max list
     161    private variable _comp2flowhints;   # cname => Rappture::FlowHints obj
    162162    private variable _comp2mesh;        # list: mesh obj, BLT vector of values
    163 
     163                                        # valid for cloud,mesh,unirect2d
    164164    private variable _values "";        # Only for unirect2d - list of values
    165165
     
    802802        GetAssociation $cname
    803803
     804        if { $_comp2size($cname) < 1 ||
     805             $_comp2size($cname) > 9 } {
     806            puts stderr "ERROR: Invalid <elemsize>: $_comp2size($cname)"
     807            continue
     808        }
     809        # Some types have restrictions on number of components
     810        if { $_comp2type($cname) == "vectors" &&
     811             $_comp2size($cname) != 3 } {
     812            puts stderr "ERROR: vectors <elemtype> must have <elemsize> of 3"
     813            continue
     814        }
     815        if { $_comp2type($cname) == "normals" &&
     816             $_comp2size($cname) != 3 } {
     817            puts stderr "ERROR: normals <elemtype> must have <elemsize> of 3"
     818            continue
     819        }
     820        if { $_comp2type($cname) == "tcoords" &&
     821             $_comp2size($cname) > 3 } {
     822            puts stderr "ERROR: tcoords <elemtype> must have <elemsize> <= 3"
     823            continue
     824        }
     825        if { $_comp2type($cname) == "scalars" &&
     826             $_comp2size($cname) > 4 } {
     827            puts stderr "ERROR: scalars <elemtype> must have <elemsize> <= 4"
     828            continue
     829        }
     830        if { $_comp2type($cname) == "colorscalars" &&
     831             $_comp2size($cname) > 4 } {
     832            puts stderr "ERROR: colorscalars <elemtype> must have <elemsize> <= 4"
     833            continue
     834        }
     835        if { $_comp2type($cname) == "tensors" &&
     836             $_comp2size($cname) != 9 } {
     837            puts stderr "ERROR: tensors <elemtype> must have <elemsize> of 9"
     838            continue
     839        }
     840
    804841        if { [$_field element $cname.flow] != "" } {
    805842            set haveFlow 1
     
    13051342        set data [Rappture::encoding::decode -as zb64 $data]
    13061343        return [Rappture::DxToVtk $data]
     1344    }
     1345    # unirect2d (deprecated)
     1346    # This can be removed when the nanovis server with support for loading VTK
     1347    # vector data is released
     1348    if {[info exists _comp2unirect2d($cname)]} {
     1349        set label $cname
     1350        regsub -all { } $label {_} label
     1351        set elemSize [numComponents $cname]
     1352        set numValues [$_comp2unirect2d($cname) numpoints]
     1353        append out "# vtk DataFile Version 3.0\n"
     1354        append out "[hints label]\n"
     1355        append out "ASCII\n"
     1356        append out [$_comp2unirect2d($cname) vtkdata]
     1357        append out "POINT_DATA $numValues\n"
     1358        if {$elemSize == 3} {
     1359            append out "VECTORS $label double\n"
     1360        } else {
     1361            append out "SCALARS $label double $elemSize\n"
     1362            append out "LOOKUP_TABLE default\n"
     1363        }
     1364        # values for VTK are x-fastest
     1365        append out $_values
     1366        append out "\n"
     1367        return $out
    13071368    }
    13081369    # unirect3d (deprecated)
Note: See TracChangeset for help on using the changeset viewer.