Changeset 4417 for trunk


Ignore:
Timestamp:
Jun 23, 2014 3:42:45 PM (10 years ago)
Author:
ldelgass
Message:

Add flag to test DX->VTK conversion in nanovis. By default, only convert for
VTK viewers and send DX to nanovis. Also, remove old Tcl-based DICOM reader.

File:
1 edited

Legend:

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

    r4394 r4417  
    8282                                        # valid data.
    8383    private variable _isValidComponent; #  Array of valid components found
     84    private variable _alwaysConvertDX 0;
     85
    8486    constructor {xmlobj path} {
    8587        # defined below
     
    152154    private method AvsToVtk { cname contents }
    153155    private method DicomToVtk { cname contents }
    154     private method DicomToVtk.old { cname contents }
    155156    private method BuildPointsOnMesh { cname }
    156157    protected method GetAssociation { cname }
     
    930931                close $f
    931932            }
    932             if { $_viewer != "nanovis" && $_viewer != "flowvis" } {
     933            if { $_alwaysConvertDX ||
     934                 ($_viewer != "nanovis" && $_viewer != "flowvis") } {
    933935                set _type "vtk"
    934936                set _comp2vtk($cname) $vtkdata
     
    17191721}
    17201722
    1721 itcl::body Rappture::Field::DicomToVtk.old { cname path } {
    1722     package require vtk
    1723 
    1724     if { ![file exists $path] } {
    1725         puts stderr "path \"$path\" doesn't exist."
    1726         return 0
    1727     }
    1728     set reader $this-datasetreader
    1729     vtkDICOMImageReader $reader
    1730     if { [file isdir $path] } {
    1731         set files [glob -nocomplain $path/*.dcm]
    1732         if { [llength $files] == 0 } {
    1733             puts stderr "no dicom files found in \"$path\""
    1734             #return 0
    1735         }       
    1736         $reader SetDirectoryName $path
    1737     } else {
    1738         $reader SetFileName $path
    1739     }
    1740     $reader Update
    1741    
    1742     set dataset [$reader GetOutput]
    1743     set limits {}
    1744     foreach {xmin xmax ymin ymax zmin zmax} [$dataset GetBounds] break
    1745     set _dim 0
    1746     if { $xmax > $xmin } {
    1747         incr _dim
    1748     }
    1749     if { $ymax > $ymin } {
    1750         incr _dim
    1751     }
    1752     if { $zmax > $zmin } {
    1753         incr _dim
    1754     }
    1755 
    1756     set _comp2dims($cname) "${_dim}D"
    1757 
    1758     lappend limits x [list $xmin $xmax]
    1759     lappend limits y [list $ymin $ymax]
    1760     lappend limits z [list $zmin $zmax]
    1761     set dataAttrs [$dataset GetPointData]
    1762     if { $dataAttrs == ""} {
    1763         puts stderr "WARNING: No point data found in \"$_path\""
    1764         rename $reader ""
    1765         return 0
    1766     }
    1767     set vmin 0
    1768     set vmax 1
    1769     set numArrays [$dataAttrs GetNumberOfArrays]
    1770     if { $numArrays > 0 } {
    1771         for {set i 0} {$i < [$dataAttrs GetNumberOfArrays] } {incr i} {
    1772             set array [$dataAttrs GetArray $i]
    1773             set fname  [$dataAttrs GetArrayName $i]
    1774             foreach {min max} [$array GetRange -1] break
    1775             if {$i == 0} {
    1776                 set vmin $min
    1777                 set vmax $max
    1778             }
    1779             lappend limits $fname [list $min $max]
    1780             set _fld2Units($fname) ""
    1781             set _fld2Label($fname) $fname
    1782             # Let the VTK file override the <type> designated.
    1783             set _fld2Components($fname) [$array GetNumberOfComponents]
    1784             lappend _comp2fldName($cname) $fname
    1785         }
    1786     }
    1787     lappend limits v [list $vmin $vmax]
    1788     set _comp2limits($cname) $limits
    1789 
    1790     set tmpfile $this-$cname.vtk
    1791     set writer $this-datasetwriter
    1792     vtkDataSetWriter $writer
    1793     $writer SetInputConnection [$reader GetOutputPort]
    1794     $writer SetFileName $tmpfile
    1795     $writer SetFileTypeToBinary
    1796     $writer Write
    1797     rename $reader ""
    1798     rename $writer ""
    1799 
    1800     set f [open "$tmpfile" "r"]
    1801     fconfigure $f -translation binary -encoding binary
    1802     set vtkdata [read $f]
    1803     close $f
    1804     file delete $tmpfile
    1805     return $vtkdata
    1806 }
    1807 
    18081723itcl::body Rappture::Field::GetTypeAndSize { cname } {
    18091724    array set type2components {
Note: See TracChangeset for help on using the changeset viewer.