3. Orthogonal Polyhedra

We start with a list of raw 3D 'symbol' data stored in a file. The symbols used are '*' and '-', where '*' represents a cube and '-' an empty space. The first line in the file is in the form of 'x, y, z', for each coordinate depth. For example,
4 3 2
****
----
----
---*
---*
---*
represents a polyhedron composed of two levels (z depth), an x depth of 4 and a y depth of 3. The first level is composed of 1 row of cubes and the second level, of 1 column of cubes.

Lets say the above data is stored in a file called poly. Running the Unix shell script

% ortho.sh poly

will produce these files:

(The latter two files are produced when DOUTPUT is #defined in sp.cpp.) In addition, Geomview is invoked immediately to display the results. In order to make the script run from raw coordinates directly to graphics without user intervention, the source is always fixed to the the 0th vertex of the 0th face. Of course the user can select any particular source vertex of the polyhedron as previously described.

Ortho.c runs twice. First it creates the .geom and .in files. After sp.cpp uses the .in info to create a .out file, ortho.c uses the .out file to create .vect file for viewing the shortest paths on GeomView.
Here is the full script of the ortho.sh:


#! /local/bin/bash
#
#Shell script ortho.sh for finding shortest paths on the surface of an orthogonal polyhedron.
#
#Written by Biliana Kaneva, Joseph O'Rourke and Veronica Morales.
#
#The input FNAME is assumed to be a raw list of 'symbol' data.  The script first reads the data, 
#triangulates the cubes and counts the faces, vertices and edges.  It creates the input, '.in', file
#for use by sp.cpp.
#
#sp.cpp runs and produces the a '.out' file with data on the shortest paths.
#
#Then, ortho.c uses the sp.cpp output to create a '.vect' file for viewing the paths in GeomView.

    if [ "$#" -eq "0" ]
        then
            echo "Syntax: convex.sh datafile"
            exit 1
            
    fi

    FNAME=$1
    echo "Working on raw symbol data file $FNAME"
    
    #1.Read data and compute faces and vertices.
    ortho -i "$FNAME"
    echo "Finished .geom and .in files"
    
    #2.Pass to sp.cpp
    echo "Starting sp..."
    sp < "$FNAME".in > "$FNAME".out
    echo "Finished sp.  '.out' file completed"
    
    #3.Run ortho with .out and produce a .vect file for GeomView
    echo "Running ortho again..."
    ortho -o "$FNAME"
    echo ".vect file written"
    
    #4.Open GeomView
    echo "Opening GeomView and viewing results"
    geomview "$FNAME".geom "$FNAME".vect&