TABLE OF CONTENTS


::pwtk::nebi::deleteImage_

SYNOPSIS

proc ::pwtk::nebi::deleteImage_ {index} {

PURPOSE

Delete the index-th image from the POSITIONS card.

ARGUMENT

REMARK

::pwtk::nebi::deleteImage is not related to the "num_of_images" variable, but to FIRST_IMAGE, INTERMEDIATE_IMAGE..., LAST_IMAGE specs in the POSITIONS card (aka BEGIN_POSITIONS / END_POSITIONS).

SOURCE

    set nimages [::pwtk::nebi::getNImages]    
    set index [image_in_range_ $index $nimages]    
    
    # store POSITIONS to data array
    ::pwtk::nebi::positions2data_ data

    # delete image

    for {set im $index} {$im < $nimages} {incr im} {
        set im1 [expr $im + 1]
        set data(unit,$im) $data(unit,$im1)
        if { [info exist data(charge,$im1)] } {
            set data(charge,$im) $data(charge,$im1)
        } elseif { [info exist data(charge,$im)] } {
            unset data(charge,$im)
        }
        for {set ia 1} {$ia <= $data(nat)} {incr ia} {
            # BEWARE: only the first image has the if_pos() ix iy iz
            # fields hence these fields should not be copied (this way
            # the if_pos() fields always remain on the image 1, even
            # if original image 1 is deleted)
            foreach e {sy x y z} {
                set data($e,$im,$ia) $data($e,$im1,$ia)
            }
        }
    }
    incr data(nimages) -1
    
    # load POSITIONS from data
    POSITIONS [::pwtk::nebi::data2positions_ data]
}