# Visualization Toolkit (VTK) Tcl package configuration.

package ifneeded vtkinit {5.0} {
  namespace eval ::vtk::init {
    proc load_library_package {libName libPath {libPrefix {lib}}} {
      set libExt [info sharedlibextension]
      set currentDirectory [pwd]
      set libFile [file join $libPath "$libPrefix$libName$libExt"]
      if {[catch "cd {$libPath}; load {$libFile}" errorMessage]} {
        puts $errorMessage
      }
      cd $currentDirectory
    }
    proc require_package {name {version {5.0}}} {
      if {[catch "package require -exact $name $version" errorMessage]} {
        puts $errorMessage
        return 0
      } else {
        return 1
      }
    }
    set version {5.0}
    set kits {}
    foreach kit { base Common Filtering IO Imaging Graphics
                  Rendering VolumeRendering
                  Hybrid Widgets
                  Parallel } {
      lappend kits [string tolower "${kit}"]
    }
  }
  package provide vtkinit {5.0}
}

foreach kit { Common Filtering IO Imaging Graphics
              Rendering VolumeRendering
              Hybrid Widgets
              Parallel } {
  package ifneeded "vtk${kit}TCL" {5.0} "
    package require -exact vtkinit {5.0}
    ::vtk::init::load_library_package {vtk${kit}TCL} {/home/juju/VTK5.0/VTK/bin}
  "
  package ifneeded "vtk[string tolower ${kit}]" {5.0} "
    package require -exact vtkinit {5.0}
    if {\[catch {source \[file join {/home/juju/VTK5.0/VTK/Wrapping/Tcl} {vtk[string tolower ${kit}]} {vtk[string tolower ${kit}].tcl}\]} errorMessage\]} {
      puts \$errorMessage
    }
  "
}

foreach src {vtk vtkbase vtkinteraction vtktesting} {
  package ifneeded ${src} {5.0} "
    package require -exact vtkinit {5.0}
    if {\[catch {source \[file join {/home/juju/VTK5.0/VTK/Wrapping/Tcl} {$src} {$src.tcl}\]} errorMessage\]} {
      puts \$errorMessage
    }
  "
}
