www.pudn.com > terra-0_7.zip > cmdline.cc


#include 
#include 
#include 
#include "terra.h"

GreedySubdivision *mesh;
Map *DEM;

static ImportMask default_mask;
ImportMask *MASK;


real error_threshold = 0.0;
int  point_limit     = -1;
real height_scale    = 1.0;
FileFormat output_format;
char *output_filename = NULL;
char *mask_filename   = NULL;
char *script_filename = NULL;

static char *options = "e:p:h:o:m:s:";

static char *usage_string =
"-e       Sets the tolerable error threshold\n"
"-p        Sets the maximum number of allowable points\n"
"-h       Sets the height scaling factor.  For example,\n"
"                 if grid points are 25m apart, use a factor of 0.04\n"
"-o   When finished, output the approximation to .\n"
"                 Valid types:  tin, eps, dem, obj\n"
"-m         Load the importance mask from \n"
"-s         Execute preinsertion script from \n"
"\n";

static void usage_error(char *msg = NULL)
{
    if( msg )
	cerr << msg << endl;

    cerr << "usage: terra  filename" << endl;
    cerr << "       where  is some combination of: " << endl;
    cerr << usage_string << endl;

    exit(1);
}

void process_cmdline(int argc, char **argv)
{
    int c;

    while( (c = getopt(argc, argv, options)) != EOF )
    {
	int errflg = False;
	char *name;

	switch( c )
	{
	case 'e':
	    error_threshold = atof(optarg);
	    cerr << "    Setting error threshold to " <width != DEM->width  || MASK->height != DEM->height )
	{
	    cerr << "Mask resolution does not match DEM resolution." << endl;
	    cerr << "     ... reverting to identity mask." << endl;
	    MASK = &default_mask;
	}
    }
    

    mesh = new GreedySubdivision(DEM);


    ////////////////////////////////////////////////////////////////

    if( point_limit < 0 )
	point_limit = DEM->width * DEM->height;


    if( script_filename )
    {
	cerr << "Executing preinsertion script:" << endl;
	ifstream in(script_filename);
	scripted_preinsertion(in);
	in.close();
    }
}