Ignore:
Timestamp:
Oct 18, 2005, 8:58:02 PM (19 years ago)
Author:
mmc
Message:

Fixed 3D volume rendering to work for prisms, pyramids,
and tetrahedra, in addition to the boxes (voxels) originally
implemented.

File:
1 edited

Legend:

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

    r95 r113  
    3232    public proc release {obj}
    3333
     34    private method _getVtkElement {npts}
     35
    3436    private variable _xmlobj ""  ;# ref to XML obj with device data
    3537    private variable _mesh ""    ;# lib obj representing this mesh
     38    private variable _pts2elem   ;# maps # points => vtk element
    3639
    3740    private variable _units "m m m" ;# system of units for x, y, z
     
    109112    # create the vtk objects containing points and connectivity
    110113    vtkPoints $this-points
    111     vtkVoxel $this-vox
    112114    vtkUnstructuredGrid $this-grid
    113115
     
    152154    foreach comp [$xmlobj children -type element $path] {
    153155        set nlist [$_mesh get $comp.nodes]
     156        set elem [_getVtkElement [llength $nlist]]
     157
    154158        set i 0
    155159        foreach n $nlist {
    156             [$this-vox GetPointIds] SetId $i $n
     160            [$elem GetPointIds] SetId $i $n
    157161            incr i
    158162        }
    159         $this-grid InsertNextCell [$this-vox GetCellType] \
    160             [$this-vox GetPointIds]
     163        $this-grid InsertNextCell [$elem GetCellType] [$elem GetPointIds]
    161164    }
    162165}
     
    170173
    171174    rename $this-points ""
    172     rename $this-vox ""
    173175    rename $this-grid ""
     176
     177    foreach type [array names _pts2elem] {
     178        rename $_pts2elem($type) ""
     179    }
    174180}
    175181
     
    304310    return [array get hints]
    305311}
     312
     313# ----------------------------------------------------------------------
     314# USAGE: _getVtkElement <npts>
     315#
     316# Used internally to find (or allocate, if necessary) a vtk element
     317# that can be used to build up a mesh.  The element depends on the
     318# number of points passed in.  4 points is a tetrahedron, 5 points
     319# is a pyramid, etc.
     320# ----------------------------------------------------------------------
     321itcl::body Rappture::Mesh::_getVtkElement {npts} {
     322    if {![info exists _pts2elem($npts)]} {
     323        switch -- $npts {
     324            4 {
     325                set _pts2elem($npts) $this-elem4
     326                vtkTetra $_pts2elem($npts)
     327            }
     328            5 {
     329                set _pts2elem($npts) $this-elem5
     330                vtkPyramid $_pts2elem($npts)
     331            }
     332            6 {
     333                set _pts2elem($npts) $this-elem6
     334                vtkWedge $_pts2elem($npts)
     335            }
     336            8 {
     337                set _pts2elem($npts) $this-elem8
     338                vtkVoxel $_pts2elem($npts)
     339            }
     340        }
     341    }
     342    return $_pts2elem($npts)
     343}
Note: See TracChangeset for help on using the changeset viewer.