TABLE OF CONTENTS


::pwtk::xsf::getDim

SYNOPSIS

proc ::pwtk::xsf::getDim {xsfFile} {

PURPOSE

Return the dimension of structure in the XSF file.

ARGUMENTS

xsfFile -- name of XSF file

SOURCE

    ::pwtk::fileMustExist $xsfFile XSF
    
    set fid [open $xsfFile r]
    set dim -1

    while { ! [eof $fid] } {
        #
        gets $fid line
        #
        switch -glob -- $line {
            *DIM-GROUP* {
                gets $fid line          
                set dim [lindex $line 0]
            }
            *CRYSTAL* {
                set dim 3
            }
            *SLAB* {
                set dim 2
            }
            *POLYMER* {
                set dim 1
            }
            *MOLECULE* - *ATOMS* {
                set dim 0
            }
            default {
                # do nothing
            }
        }
        
        if { $dim > -1 } {
            close $fid
            return $dim
        }
    }
    
    # if we come that far, the file is not XSF file

    ::pwtk::error "$xsfFile is not an XSF file" 1
    close $fid
    return 0
}