# Visualization Toolkit (VTK) Tcl package configuration.

package ifneeded vtkinit {4.2} {
  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 {4.2}}} {
      if {[catch "package require -exact $name $version" errorMessage]} {
        puts $errorMessage
        return 0
      } else {
        return 1
      }
    }
  }
  package provide vtkinit {4.2}
}

foreach kit { Common Filtering IO Imaging Graphics
              Rendering Hybrid 
              Patented Parallel } {
  package ifneeded "vtk${kit}TCL" {4.2} "
    package require -exact vtkinit {4.2}
    ::vtk::init::load_library_package {vtk${kit}TCL} {/usr/local/VTK-4.2.1/bin}
  "
  package ifneeded "vtk[string tolower ${kit}]" {4.2} "
    package require -exact vtkinit {4.2}
    if {\[catch {source \[file join {/usr/local/VTK-4.2.1/Wrapping/Tcl} {vtk[string tolower ${kit}]} {vtk[string tolower ${kit}].tcl}\]} errorMessage\]} {
      puts \$errorMessage
    }
  "
}

foreach src {vtk vtkbase vtkinteraction vtktesting} {
  package ifneeded ${src} {4.2} "
    package require -exact vtkinit {4.2}
    if {\[catch {source \[file join {/usr/local/VTK-4.2.1/Wrapping/Tcl} {$src} {$src.tcl}\]} errorMessage\]} {
      puts \$errorMessage
    }
  "
}
