# Visualization Toolkit (VTK) Tcl package configuration.

package ifneeded vtkinit {6.1} {
  namespace eval ::vtk::init {
    proc load_library_package {libName libPath {libPrefix {lib}}} {
      #first try to load a static package, then try the shared package.
      if {[catch "load {} $libName"]} {
        set libExt [info sharedlibextension]
        set currentDirectory [pwd]
        set libFile [file join $libPath "$libPrefix$libName-6.1$libExt"]
        if {[catch "cd {$libPath}; load {$libFile}" errorMessage]} {
          puts $errorMessage
        }
        cd $currentDirectory
      }
    }
    proc require_package {name {version {6.1}}} {
      if {[catch "package require -exact $name $version" errorMessage]} {
        puts $errorMessage
        return 0
      } else {
        return 1
      }
    }
    set version {6.1}
    set kits {}
    foreach kit { base  CommonCore CommonMath CommonMisc CommonSystem CommonTransforms CommonDataModel CommonColor CommonExecutionModel FiltersCore CommonComputationalGeometry FiltersGeneral ImagingCore ImagingFourier FiltersStatistics FiltersExtraction InfovisCore FiltersGeometry FiltersSources RenderingCore RenderingFreeType IOCore IOImage ImagingHybrid RenderingOpenGL RenderingContextIID ChartsCore ImagingColor RenderingAnnotation RenderingGLtoPS RenderingLabel IOExport IOLegacy IOInfovis TestingRendering ImagingSources FiltersHybrid FiltersModeling ImagingGeneral InteractionStyle RenderingVolume InteractionWidgets ViewsCore ViewsContextIID IOGeometry IOXMLParser IOXML DomainsChemistry ParallelCore FiltersAMR IOAMR FiltersFlowPaths FiltersImaging RenderingFreeTypeOpenGL FiltersGeneric FiltersHyperTree FiltersParallel FiltersParallelImaging FiltersProgrammable FiltersSMP FiltersSelection FiltersTexture FiltersVerdict InfovisLayout GeovisCore ViewsInfovis ViewsGeovis IOEnSight IOExodus InteractionImage RenderingVolumeOpenGL ImagingMath IOImport IOLSDyna IOMINC IOMovie IONetCDF IOPLY IOParallel IOSQL IOVideo ImagingStatistics ImagingStencil RenderingImage ImagingMorphological RenderingLOD RenderingLIC RenderingVolumeAMR } {
      lappend kits [string tolower "${kit}"]
    }
  }
  package provide vtkinit {6.1}
}

foreach kit {  CommonCore CommonMath CommonMisc CommonSystem CommonTransforms CommonDataModel CommonColor CommonExecutionModel FiltersCore CommonComputationalGeometry FiltersGeneral ImagingCore ImagingFourier FiltersStatistics FiltersExtraction InfovisCore FiltersGeometry FiltersSources RenderingCore RenderingFreeType IOCore IOImage ImagingHybrid RenderingOpenGL RenderingContextIID ChartsCore ImagingColor RenderingAnnotation RenderingGLtoPS RenderingLabel IOExport IOLegacy IOInfovis TestingRendering ImagingSources FiltersHybrid FiltersModeling ImagingGeneral InteractionStyle RenderingVolume InteractionWidgets ViewsCore ViewsContextIID IOGeometry IOXMLParser IOXML DomainsChemistry ParallelCore FiltersAMR IOAMR FiltersFlowPaths FiltersImaging RenderingFreeTypeOpenGL FiltersGeneric FiltersHyperTree FiltersParallel FiltersParallelImaging FiltersProgrammable FiltersSMP FiltersSelection FiltersTexture FiltersVerdict InfovisLayout GeovisCore ViewsInfovis ViewsGeovis IOEnSight IOExodus InteractionImage RenderingVolumeOpenGL ImagingMath IOImport IOLSDyna IOMINC IOMovie IONetCDF IOPLY IOParallel IOSQL IOVideo ImagingStatistics ImagingStencil RenderingImage ImagingMorphological RenderingLOD RenderingLIC RenderingVolumeAMR } {
  package ifneeded "vtk${kit}TCL" {6.1} "
    package require -exact vtkinit {6.1}
    ::vtk::init::load_library_package {vtk${kit}TCL} {[file dirname [file dirname [file dirname [info script]]]]}
  "
  package ifneeded "vtk[string tolower ${kit}]" {6.1} "
    package require -exact vtkinit {6.1}
    if {\[catch {source \[file join {[file dirname [info script]]} {vtk[string tolower ${kit}]} {vtk[string tolower ${kit}].tcl}\]} errorMessage\]} {
      puts \$errorMessage
    }
  "
}

foreach src {vtk vtkbase vtkinteraction vtktesting} {
  package ifneeded ${src} {6.1} "
    package require -exact vtkinit {6.1}
    if {\[catch {source \[file join {[file dirname [info script]]} {$src} {$src.tcl}\]} errorMessage\]} {
      puts \$errorMessage
    }
  "
}
