Initial revision.
This commit is contained in:
parent
78368f7c38
commit
77ef53bd83
3 changed files with 194 additions and 0 deletions
6
src/Lib/Output/Makefile.am
Normal file
6
src/Lib/Output/Makefile.am
Normal file
|
@ -0,0 +1,6 @@
|
|||
noinst_LIBRARIES = libOutput.a
|
||||
|
||||
libOutput_a_SOURCES = \
|
||||
output.cxx output.hxx
|
||||
|
||||
INCLUDES += -I$(top_srcdir)/src -I$(top_srcdir)/src/Lib
|
135
src/Lib/Output/output.cxx
Normal file
135
src/Lib/Output/output.cxx
Normal file
|
@ -0,0 +1,135 @@
|
|||
// output.cxx -- routines to output a polygon model of an airport
|
||||
//
|
||||
// Written by Curtis Olson, started September 1999.
|
||||
//
|
||||
// Copyright (C) 1999 - 2000 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include <list>
|
||||
#include STL_STRING
|
||||
|
||||
#include <simgear/bucket/newbucket.hxx>
|
||||
|
||||
#include <Include/scenery_version.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
|
||||
#include "output.hxx"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <Win32/mkdir.hpp>
|
||||
#endif
|
||||
|
||||
FG_USING_STD( cout );
|
||||
FG_USING_STD( endl );
|
||||
|
||||
|
||||
void write_polygon( const FGPolygon& poly, const string& base ) {
|
||||
for ( int i = 0; i < poly.contours(); ++i ) {
|
||||
char name[256];
|
||||
sprintf(name, "%s%d", base.c_str(), i );
|
||||
FILE *fp = fopen( name, "w" );
|
||||
|
||||
for ( int j = 0; j < poly.contour_size( i ); ++j ) {
|
||||
Point3D p0 = poly.get_pt(i, j);
|
||||
fprintf(fp, "%.8f %.8f\n", p0.x(), p0.y());
|
||||
}
|
||||
Point3D p0 = poly.get_pt(i, 0);
|
||||
fprintf(fp, "%.8f %.8f\n", p0.x(), p0.y());
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// update index
|
||||
void write_index(const string& base, const SGBucket& b, const string& name) {
|
||||
string dir = base + "/" + b.gen_base_path();
|
||||
#ifdef _MSC_VER
|
||||
fg_mkdir( dir.c_str() );
|
||||
#else
|
||||
string command = "mkdir -p " + dir;
|
||||
system(command.c_str());
|
||||
#endif
|
||||
|
||||
string file = dir + "/" + b.gen_index_str() + ".ind";
|
||||
// string file = dir + "/" + name;
|
||||
cout << "Output file = " << file << endl;
|
||||
|
||||
FILE *fp;
|
||||
if ( (fp = fopen( file.c_str(), "a" )) == NULL ) {
|
||||
cout << "ERROR: opening " << file << " for writing!" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fprintf( fp, "OBJECT %s\n", name.c_str() );
|
||||
fclose( fp );
|
||||
}
|
||||
|
||||
|
||||
void write_boundary( const string& base, const SGBucket& b,
|
||||
const FGPolygon& bounds, long int p_index )
|
||||
{
|
||||
Point3D p;
|
||||
|
||||
string dir = base + "/" + b.gen_base_path();
|
||||
#ifdef _MSC_VER
|
||||
fg_mkdir( dir.c_str() );
|
||||
#else
|
||||
string command = "mkdir -p " + dir;
|
||||
system(command.c_str());
|
||||
#endif
|
||||
|
||||
string file = dir + "/" + b.gen_index_str();
|
||||
|
||||
char poly_index[256];
|
||||
sprintf( poly_index, "%ld", p_index );
|
||||
file += ".";
|
||||
file += poly_index;
|
||||
|
||||
cout << "Output file = " << file << endl;
|
||||
|
||||
FILE *fp;
|
||||
if ( (fp = fopen( file.c_str(), "w" )) == NULL ) {
|
||||
cout << "ERROR: opening " << file << " for writing!" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fprintf( fp, "Hole\n" );
|
||||
|
||||
fprintf( fp, "%d\n", bounds.contours() );
|
||||
for ( int i = 0; i < bounds.contours(); ++i ) {
|
||||
fprintf( fp, "%d\n", bounds.contour_size(i) );
|
||||
fprintf( fp, "%d\n", bounds.get_hole_flag(i) );
|
||||
for ( int j = 0; j < bounds.contour_size(i); ++j ) {
|
||||
p = bounds.get_pt( i, j );
|
||||
fprintf( fp, "%.15f %.15f\n", p.x(), p.y() );
|
||||
}
|
||||
}
|
||||
fclose( fp );
|
||||
}
|
53
src/Lib/Output/output.hxx
Normal file
53
src/Lib/Output/output.hxx
Normal file
|
@ -0,0 +1,53 @@
|
|||
// output.hxx -- routines to output a polygon model of an airport
|
||||
//
|
||||
// Written by Curtis Olson, started September 1999.
|
||||
//
|
||||
// Copyright (C) 1999 - 2000 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
|
||||
#ifndef _TG_OUTPUT_HXX
|
||||
#define _TG_OUTPUT_HXX
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <list>
|
||||
#include STL_STRING
|
||||
|
||||
#include <simgear/math/sg_types.hxx>
|
||||
|
||||
|
||||
void write_polygon( const FGPolygon& poly, const string& base );
|
||||
|
||||
// update index
|
||||
void write_index(const string& base, const SGBucket& b, const string& name);
|
||||
|
||||
void write_boundary( const string& base, const SGBucket& b,
|
||||
const FGPolygon& bounds, long int p_index );
|
||||
|
||||
#endif // _TG_OUTPUT_HXX
|
Loading…
Add table
Reference in a new issue