Changeset 4459 for branches/1.3


Ignore:
Timestamp:
Jul 3, 2014, 9:56:50 AM (10 years ago)
Author:
ldelgass
Message:

merge mostly cosmetic changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3/gui/scripts/field.tcl

    r4387 r4459  
    1616
    1717# TODO:
    18 #
    19 #  o How to describe vector values in a field? 
    20 #       <components>3</components>
    21 #       <values></values>
    22 #
    23 #    Does anything need to know the limits for each component of the vector?
    24 #
     18#    Vector field limits are wrong: need to compute magnitude limits and
     19#    component-wise limits.
    2520
    2621#
     
    2924# 2D Datasets
    3025#       vtk             (range of z-axis is zero).
    31 #       unirect2d       (deprecated except where extents > 1)
     26#       unirect2d       (deprecated)
    3227#       cloud           (x,y point coordinates) (deprecated)
    3328#       mesh
    3429# 3D Datasets
    3530#       vtk
    36 #       unirect3d
     31#       unirect3d       (deprecated)
    3732#       cloud           (x,y,z coordinates) (deprecated)
    3833#       mesh
     
    5045#       unirect3d   3   unirect2d + extents > 1 flow    flow            nanovis
    5146#       
    52 # With <views>, can specify which viewer for a specific datasets.  So it's OK
    53 # to if the same dataset can be viewed in more than one way.
     47# With <views>, can specify which viewer for specific datasets.  So it's OK
     48# for the same dataset to be viewed in more than one way.
    5449#  o Any 2D dataset can be viewed as a contour/heightmap.
    5550#  o Any 3D dataset can be viewed as a isosurface.
    56 #  o Any 2D dataset with vector data can be streamlines
     51#  o Any 2D dataset with vector data can be streamlines or flow
    5752#  o Any 3D uniform rectilinear dataset can be viewed as a volume.
    5853#  o Any 3D dataset with vector data can be streamlines or flow.
    59 #   
    60 #  Vector data 2/3 streamlines
    61 #  Scalar data 1/
    6254#
    6355# Need <views> to properly do things like qdot: volume with a polydata
     
    159151    private method AvsToVtk { cname contents }
    160152    private method BuildPointsOnMesh { cname }
    161     private method ConvertToVtkData { cname }
    162153    protected method GetAssociation { cname }
    163154    protected method GetTypeAndSize { cname }
     
    441432
    442433                set vname [lindex $_comp2xy($cname) $pos]
     434
    443435                if {$log} {
    444436                    # on a log scale, use abs value and ignore 0's
     
    540532    foreach cname [array names _comp2limits] {
    541533        array set limits $_comp2limits($cname)
    542         foreach fname $_comp2fldName($cname) {
     534        foreach fname [fieldnames $cname] {
    543535            if { ![info exists limits($fname)] } {
    544536                puts stderr "ERROR: field \"$fname\" unknown in \"$cname\""
     
    779771        set _comp2style($cname) ""
    780772        if { $type == "" } {
    781             puts stderr "WARNING: ignoring field component \"$_path.$cname\": no data found."
     773            puts stderr "WARNING: Ignoring field component \"$_path.$cname\": no data found."
    782774            continue
    783775        }
     
    855847            set contents [$_field get $cname.vtk]
    856848            if { $contents == "" } {
    857                 puts stderr "WARNING: no data fo \"$_path.$cname.vtk\""
     849                puts stderr "WARNING: No data for \"$_path.$cname.vtk\""
    858850                continue;               # Ignore this component
    859851            }
     
    880872                set vtkdata  [$_field get -decode yes $cname.$type]
    881873                if { $vtkdata == "" } {
    882                     puts stderr "WARNING: no data for \"$_path.$cname.$type\""
     874                    puts stderr "WARNING: No data for \"$_path.$cname.$type\""
    883875                    continue;               # Ignore this component
    884876                }
     
    900892                set contents [$_field get -decode no $cname.$type]
    901893                if { $contents == "" } {
    902                     puts stderr "WARNING: no data for \"$_path.$cname.$type\""
     894                    puts stderr "WARNING: No data for \"$_path.$cname.$type\""
    903895                    continue;               # Ignore this component
    904896                }
     
    915907            set contents [$_field get $cname.ucd]
    916908            if { $contents == "" } {
    917                 continue;               # Ignore this compoennt
     909                continue;               # Ignore this component
    918910            }
    919911            set vtkdata [AvsToVtk $cname $contents]
     
    926918    }
    927919    if { [array size _isValidComponent] == 0 } {
    928         puts stderr "WARNING: no valid components for field \"$_path\""
     920        puts stderr "ERROR: All components of field \"$_path\" are invalid."
    929921        return 0
    930922    }
     
    938930        }
    939931        if { $dim != $_comp2dims($cname) } {
    940             puts stderr "WARNING: field can't have components of different dimensions: [join [array get _comp2dims] ,]"
     932            puts stderr "WARNING: A field can't have components of different dimensions: [join [array get _comp2dims] ,]"
    941933            return 0
    942934        }
    943935    }
     936
    944937    # FIXME: about.scalars and about.vectors are temporary.  With views
    945938    #        the label and units for each field will be specified there.
     
    10591052# type  --
    10601053#
    1061 # Returns the style associated with a component of the field. 
     1054# Returns the data storage type of the field.
     1055#
     1056# FIXME: What are the valid types?
    10621057#
    10631058itcl::body Rappture::Field::type {} {
     
    11031098    }
    11041099    return $_comp2extents($cname)
    1105 }
    1106 
    1107 itcl::body Rappture::Field::ConvertToVtkData { cname } {
    1108     set ds ""
    1109     switch -- [typeof $cname] {
    1110         "unirect2d" {
    1111             foreach { x1 x2 xN y1 y2 yN } [$dataobj mesh $cname] break
    1112             set spacingX [expr {double($x2 - $x1)/double($xN - 1)}]
    1113             set spacingY [expr {double($y2 - $y1)/double($yN - 1)}]
    1114            
    1115             set ds [vtkImageData $this-grdataTemp]
    1116             $ds SetDimensions $xN $yN 1
    1117             $ds SetOrigin $x1 $y1 0
    1118             $ds SetSpacing $spacingX $spacingY 0
    1119             set arr [vtkDoubleArray $this-arrTemp]
    1120             foreach {val} [$dataobj values $cname] {
    1121                 $arr InsertNextValue $val
    1122             }
    1123             [$ds GetPointData] SetScalars $arr
    1124         }
    1125         "unirect3d" {
    1126             foreach { x1 x2 xN y1 y2 yN z1 z2 zN } [$dataobj mesh $cname] break
    1127             set spacingX [expr {double($x2 - $x1)/double($xN - 1)}]
    1128             set spacingY [expr {double($y2 - $y1)/double($yN - 1)}]
    1129             set spacingZ [expr {double($z2 - $z1)/double($zN - 1)}]
    1130            
    1131             set ds [vtkImageData $this-grdataTemp]
    1132             $ds SetDimensions $xN $yN $zN
    1133             $ds SetOrigin $x1 $y1 $z1
    1134             $ds SetSpacing $spacingX $spacingY $spacingZ
    1135             set arr [vtkDoubleArray $this-arrTemp]
    1136             foreach {val} [$dataobj values $cname] {
    1137                 $arr InsertNextValue $val
    1138             }
    1139             [$ds GetPointData] SetScalars $val
    1140         }
    1141         "contour" {
    1142             return [$dataobj blob $cname]
    1143         }
    1144         "dx" {
    1145             return [Rappture::DxToVtk $_comp2dx($cname)]
    1146         }
    1147         default {
    1148             set mesh [$dataobj mesh $cname]
    1149             switch -- [$mesh GetClassName] {
    1150                 vtkPoints {
    1151                     # handle cloud of points
    1152                     set ds [vtkPolyData $this-polydataTemp]
    1153                     $ds SetPoints $mesh
    1154                     [$ds GetPointData] SetScalars [$dataobj values $cname]
    1155                 }
    1156                 vtkPolyData {
    1157                     set ds [vtkPolyData $this-polydataTemp]
    1158                     $ds ShallowCopy $mesh
    1159                     [$ds GetPointData] SetScalars [$dataobj values $cname]
    1160                 }
    1161                 vtkUnstructuredGrid {
    1162                     # handle 3D grid with connectivity
    1163                     set ds [vtkUnstructuredGrid $this-grdataTemp]
    1164                     $ds ShallowCopy $mesh
    1165                     [$ds GetPointData] SetScalars [$dataobj values $cname]
    1166                 }
    1167                 vtkRectilinearGrid {
    1168                     # handle 3D grid with connectivity
    1169                     set ds [vtkRectilinearGrid $this-grdataTemp]
    1170                     $ds ShallowCopy $mesh
    1171                     [$ds GetPointData] SetScalars [$dataobj values $cname]
    1172                 }
    1173                 default {
    1174                     error "don't know how to handle [$mesh GetClassName] data"
    1175                 }
    1176             }
    1177         }
    1178     }
    1179 
    1180     if {"" != $ds} {
    1181         set writer [vtkDataSetWriter $this-dsWriterTmp]
    1182         $writer SetInput $ds
    1183         $writer SetFileTypeToASCII
    1184         $writer WriteToOutputStringOn
    1185         $writer Write
    1186         set out [$writer GetOutputString]
    1187         $ds Delete
    1188         $writer Delete
    1189     } else {
    1190         set out ""
    1191         error "No DataSet to write"
    1192     }
    1193 
    1194     append out "\n"
    1195     return $out
    11961100}
    11971101
     
    12231127    set dataAttrs [$dataset GetPointData]
    12241128    if { $dataAttrs == ""} {
    1225         puts stderr "WARNING: no point data found in \"$_path\""
     1129        puts stderr "WARNING: No point data found in \"$_path\""
    12261130        rename $reader ""
    12271131        return 0
     
    12861190        set dataAttrs [$dataset GetPointData]
    12871191        if { $dataAttrs == ""} {
    1288             puts stderr "WARNING: no point data found in \"$_path\""
     1192            puts stderr "WARNING: No point data found in \"$_path\""
    12891193            rename $reader ""
    12901194            return 0
     
    12921196        set array [$dataAttrs GetScalars]
    12931197        if { $array == ""} {
    1294             puts stderr "WARNING: no scalar point data found in \"$_path\""
     1198            puts stderr "WARNING: No scalar point data found in \"$_path\""
    12951199            rename $reader ""
    12961200            return 0
     
    13081212    set dataAttrs [$dataset GetPointData]
    13091213    if { $dataAttrs == ""} {
    1310         puts stderr "WARNING: no point data found in \"$_path\""
     1214        puts stderr "WARNING: No point data found in \"$_path\""
    13111215        rename $reader ""
    13121216        return 0
     
    15431447        }
    15441448    }
    1545        
     1449
    15461450    if {$_dim == 1} {
    15471451        # 1D data: Create vectors for graph widget.
     
    16481552    file delete $tmpfile
    16491553
    1650     set tmpfile $this-$cname[pid].vtk
     1554    set tmpfile $cname[pid].vtk
    16511555    set writer $this-datasetwriter
    16521556    vtkDataSetWriter $writer
Note: See TracChangeset for help on using the changeset viewer.