#! /usr/bin/perl
#
# Copyright Alan C. Evans
# Professor of Neurology
# McGill University
#

sub  get_self_intersect( $$$$ )
{
    my( $self_weight, $n_selfs, $self_dist, $self_dist2 ) = @_;
    my( $self, $weight, $s, $dist );

    if( $self_weight > 0.0 )
    {
        $self = "";
        $weight = $self_weight;

        for( $s = 0;  $s < $n_selfs;  ++$s )
        {
            $dist = $self_dist + ($self_dist2 - $self_dist) *
                    $s / $n_selfs;

            $self = $self . " -self_intersect $weight $dist ";
            $weight *= 10.0;
        }
        $self = $self . " -self_intersect 1e8 $self_dist2 ";
    }
    else
        { $self = ""; }

    $self;
}

sub  get_surf_surf( $$$$$$ )
{
    my( $index1, $index2, $surf_surf_weight, $n_surf_surfs,
        $surf_surf_dist1, $surf_surf_dist2 ) = @_;
    my( $surf_surf, $weight, $s, $dist );

    if( $surf_surf_weight > 0.0 )
    {
        $surf_surf = "";
        $weight = $surf_surf_weight;

        for( $s = 0;  $s < $n_surf_surfs;  ++$s )
        {
            $dist = $surf_surf_dist1 + ($surf_surf_dist2 - $surf_surf_dist1) *
                    $s / $n_surf_surfs;

            $surf_surf = $surf_surf .
                         " -surf_surf $index1 $index2 $weight $dist ";
            $weight *= 10.0;
        }

        $surf_surf = $surf_surf . 
                     " -surf_surf $index1 $index2 1e8 $surf_surf_dist2 ";
    }
    else
        { $surf_surf = ""; }

    $surf_surf;
}

1;
