File: vtkbase.tcl.in

package info (click to toggle)
vtk7 7.1.1%2Bdfsg2-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 127,396 kB
  • sloc: cpp: 1,539,584; ansic: 124,382; python: 78,038; tcl: 47,013; xml: 8,142; yacc: 5,040; java: 4,439; perl: 3,132; lex: 1,926; sh: 1,500; makefile: 126; objc: 83
file content (106 lines) | stat: -rw-r--r-- 3,472 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package provide vtkbase @VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@

namespace eval ::vtk {

    namespace export *

    # load_component: load a VTK component
    #        Example: ::vtk::load_component vtkFilteringTCL

    # Windows: the 'load' command looks for DLL in the Tcl/Tk dir,
    #          the current dir, c:\window\system[32], c:\windows and the dirs
    #          listed in the PATH environment var.
    #    Unix: the 'load' command looks for shared libs in dirs listed in the
    #          LD_LIBRARY_PATH environment var.

    variable complain_on_loading 1

    proc load_component {name {optional_paths {}}} {

        global tcl_platform auto_path env

        # First dir is empty, to let Tcl try in the current dir

        set dirs $optional_paths
        set dirs [concat $dirs {""}]
        set ext [info sharedlibextension]
        if {$tcl_platform(platform) == "unix"} {
            set prefix "lib"
            # Help Unix a bit by browsing into $auto_path and /usr/lib...
            set dirs [concat $dirs /usr/local/lib /usr/local/lib/vtk $auto_path]
            if {[info exists env(LD_LIBRARY_PATH)]} {
                set dirs [concat $dirs [split $env(LD_LIBRARY_PATH) ":"]]
            }
            if {[info exists env(PATH)]} {
                set dirs [concat $dirs [split $env(PATH) ":"]]
            }
        } else {
            set prefix ""
            if {$tcl_platform(platform) == "windows"} {
                if {[info exists env(PATH)]} {
                    set dirs [concat $dirs [split $env(PATH) ";"]]
                }
            }
        }

        foreach dir $dirs {
            set libname [file join $dir ${prefix}${name}-@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@${ext}]
            if {[file exists $libname]} {
                if {![catch {load $libname} errormsg]} {
                    # WARNING: it HAS to be "" so that pkg_mkIndex work (since
                    # while evaluating a package ::vtk::load_component won't
                    # exist and will default to the unknown() proc that
                    # returns ""
                    return ""
                } elseif {$::vtk::complain_on_loading} {
                    # If not loaded but file was found, oops
                    puts stderr $errormsg
                }
            }
        }

        if {$::vtk::complain_on_loading} {
            puts stderr "::vtk::load_component: $name could not be found."
        }

        return 1
    }

    # Function returning either a command line argument, an environment
    # variable or a default value.

    proc get_arg_or_env_or_default {arg envvar def} {

        # Look at command line args

        global argc argv
        if {[info exists argc]} {
            set argcm1 [expr $argc - 1]
            for {set i 0} {$i < $argcm1} {incr i} {
                if {[lindex $argv $i] == $arg && $i < $argcm1} {
                    return [lindex $argv [expr $i + 1]]
                }
            }
        }

        # Look at environment vars

        global env
        if {[info exists env($envvar)]} {
            return $env($envvar)
        }

        # Return default

        return $def
    }

    # Get VTK_DATA_ROOT if we can

    variable VTK_DATA_ROOT [::vtk::get_arg_or_env_or_default \
            "-D" \
            "VTK_DATA_ROOT" \
            [file nativename [file join [file dirname [info script]] "../../../../VTKData"]]]
}

set VTK_DATA_ROOT $::vtk::VTK_DATA_ROOT