int main( int argc, char* argv[] )
{
	clock_t		t0 = StartTiming();

/* ------------------ */
/* Parse command line */
/* ------------------ */

	gArgs.SetCmdLine( argc, argv );

	TS.SetLogFile( flog );

	if( !ReadScriptParams( scr, gArgs.script, flog ) )
		goto exit;

	inv_scl = 1.0 / scr.crossscale;

/* ---------------- */
/* Read source data */
/* ---------------- */

	if( gArgs.zb >= 0 && gArgs.za < 0 )
		gArgs.za = gArgs.zb;

	TS.FillFromRgns( gArgs.srcmons, gArgs.idb, gArgs.zb, gArgs.za );

	fprintf( flog, "Got %d images.\n", (int)TS.vtil.size() );

	if( !TS.vtil.size() )
		goto exit;

	TS.SetTileDimsFromImageFile();
	TS.GetTileDims( gW, gH );

	t0 = StopTiming( flog, "ReadFile", t0 );

/* ------------- */
/* Sort by layer */
/* ------------- */

	TS.SortAll_z();

/* ----- */
/* Stuff */
/* ----- */

	ScapeStuff();

/* ---- */
/* Done */
/* ---- */

exit:
	fprintf( flog, "\n" );
	VMStats( flog );
	fclose( flog );

	return 0;
}
int main( int argc, char* argv[] )
{
	clock_t		t0 = StartTiming();

/* ------------------ */
/* Parse command line */
/* ------------------ */

	gArgs.SetCmdLine( argc, argv );

	TS.SetLogFile( flog );

	if( !ReadScriptParams( scr, gArgs.script, flog ) )
		exit( 42 );

	if( scr.blockreqdz < 1 )
		scr.blockreqdz == 1;
	else if( scr.blockreqdz > scr.blockmaxdz )
		scr.blockreqdz = scr.blockmaxdz;

	inv_scl = 1.0 / scr.crossscale;

/* --------------- */
/* Read block data */
/* --------------- */

	gDat.ReadFile();

	if( gArgs.abdbg ) {

		if( gArgs.dbgz == -1 )
			gArgs.dbgz = gDat.za - 1;

		gDat.zmin = gArgs.dbgz;
	}

/* ---------------- */
/* Read source data */
/* ---------------- */

	string	idb;

	IDBFromTemp( idb, "../..", flog );

	if( idb.empty() )
		exit( 42 );

	TS.FillFromRgns( gDat.scaf, idb, gDat.zmin, gDat.za );

	fprintf( flog, "Got %d images.\n", (int)TS.vtil.size() );

	if( !TS.vtil.size() )
		goto exit;

	TS.SetTileDimsFromImageFile();
	TS.GetTileDims( gW, gH );

	t0 = StopTiming( flog, "ReadFile", t0 );

/* ------------- */
/* Sort by layer */
/* ------------- */

	TS.SortAll_z();

/* ----- */
/* Stuff */
/* ----- */

	LayerLoop();

/* ---- */
/* Done */
/* ---- */

exit:
	fprintf( flog, "\n" );
	VMStats( flog );
	fclose( flog );

	return 0;
}