Did a bit of code restructuring. Hopefully to open things up to add
runway lighting.
This commit is contained in:
parent
90fe08a7c0
commit
af24dc6d24
19 changed files with 2061 additions and 1412 deletions
|
@ -28,9 +28,17 @@ bin_PROGRAMS = genapts
|
|||
genapts_SOURCES = \
|
||||
build.cxx build.hxx \
|
||||
convex_hull.cxx convex_hull.hxx \
|
||||
global.hxx \
|
||||
main.cxx \
|
||||
point2d.cxx point2d.hxx \
|
||||
poly_extra.cxx poly_extra.hxx \
|
||||
runway.cxx runway.hxx \
|
||||
rwy_common.cxx rwy_common.hxx \
|
||||
rwy_nonprec.cxx rwy_nonprec.hxx \
|
||||
rwy_prec.cxx rwy_prec.hxx \
|
||||
rwy_simple.cxx rwy_simple.hxx \
|
||||
rwy_visual.cxx rwy_visual.hxx \
|
||||
taxiway.cxx taxiway.hxx \
|
||||
texparams.hxx
|
||||
|
||||
genapts_LDADD = \
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,12 +29,10 @@
|
|||
|
||||
#include <list>
|
||||
|
||||
#include "global.hxx"
|
||||
#include "point2d.hxx"
|
||||
|
||||
|
||||
extern int nudge;
|
||||
|
||||
|
||||
// build 3d airport
|
||||
void build_airport( string airport, string_list& runways_raw,
|
||||
string_list& taxiways_raw, const string& root );
|
||||
|
|
32
src/Airports/GenAirports/global.hxx
Normal file
32
src/Airports/GenAirports/global.hxx
Normal file
|
@ -0,0 +1,32 @@
|
|||
// global.hxx -- kind of dumb but oh well...
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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 _GEN_AIRPORT_GLOBAL_HXX
|
||||
#define _GEN_AIRPORT_GLOBAL_HXX
|
||||
|
||||
|
||||
extern int nudge;
|
||||
|
||||
|
||||
#endif // _GEN_AIRPORT_GLOBAL_HXX
|
|
@ -54,6 +54,14 @@
|
|||
int nudge = 10;
|
||||
|
||||
|
||||
// Display usage
|
||||
static void usage( int argc, char **argv ) {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||
"Usage " << argv[0] << " --input=<apt_file> "
|
||||
<< "--work=<work_dir> [ --start-id=abcd ] [ --nudge=n ]" );
|
||||
}
|
||||
|
||||
|
||||
// reads the apt_full file and extracts and processes the individual
|
||||
// airport records
|
||||
int main( int argc, char **argv ) {
|
||||
|
@ -82,9 +90,7 @@ int main( int argc, char **argv ) {
|
|||
} else if ( arg.find("--nudge=") == 0 ) {
|
||||
nudge = atoi( arg.substr(8).c_str() );
|
||||
} else {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||
"Usage " << argv[0] << " --input=<apt_file> "
|
||||
<< "--work=<work_dir> [ --start-id=abcd ] [ --nudge=n ]" );
|
||||
usage( argc, argv );
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
@ -96,6 +102,7 @@ int main( int argc, char **argv ) {
|
|||
if ( work_dir == "" ) {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||
"Error: no work directory specified." );
|
||||
usage( argc, argv );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
|
206
src/Airports/GenAirports/poly_extra.cxx
Normal file
206
src/Airports/GenAirports/poly_extra.cxx
Normal file
|
@ -0,0 +1,206 @@
|
|||
// poly_extra.cxx -- Extra polygon manipulation routines
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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$
|
||||
//
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <simgear/math/sg_geodesy.hxx>
|
||||
|
||||
#include <Geometry/poly_support.hxx>
|
||||
|
||||
#include "poly_extra.hxx"
|
||||
|
||||
|
||||
// Divide segment if there are other existing points on it, return the
|
||||
// new polygon
|
||||
void add_intermediate_nodes( int contour, const Point3D& start,
|
||||
const Point3D& end, const FGTriNodes& tmp_nodes,
|
||||
FGPolygon *result )
|
||||
{
|
||||
point_list nodes = tmp_nodes.get_node_list();
|
||||
|
||||
// cout << " add_intermediate_nodes()" << endl;
|
||||
printf(" %.7f %.7f %.7f <=> %.7f %.7f %.7f\n",
|
||||
start.x(), start.y(), start.z(), end.x(), end.y(), end.z() );
|
||||
|
||||
|
||||
Point3D new_pt;
|
||||
bool found_extra = find_intermediate_node( start, end, nodes, &new_pt );
|
||||
|
||||
if ( found_extra ) {
|
||||
// recurse with two sub segments
|
||||
// cout << "dividing " << p0 << " " << nodes[extra_index]
|
||||
// << " " << p1 << endl;
|
||||
add_intermediate_nodes( contour, start, new_pt, tmp_nodes,
|
||||
result );
|
||||
|
||||
result->add_node( contour, new_pt );
|
||||
|
||||
add_intermediate_nodes( contour, new_pt, end, tmp_nodes,
|
||||
result );
|
||||
} else {
|
||||
// this segment does not need to be divided
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Search each segment for additional vertex points that may have been
|
||||
// created elsewhere that lie on the segment and split it there to
|
||||
// avoid "T" intersections.
|
||||
|
||||
FGPolygon add_nodes_to_poly( const FGPolygon& poly,
|
||||
const FGTriNodes& tmp_nodes ) {
|
||||
int i, j;
|
||||
FGPolygon result; result.erase();
|
||||
Point3D p0, p1;
|
||||
|
||||
// cout << "add_nodes_to_poly" << endl;
|
||||
|
||||
for ( i = 0; i < poly.contours(); ++i ) {
|
||||
// cout << "contour = " << i << endl;
|
||||
for ( j = 0; j < poly.contour_size(i) - 1; ++j ) {
|
||||
p0 = poly.get_pt( i, j );
|
||||
p1 = poly.get_pt( i, j + 1 );
|
||||
|
||||
// add start of segment
|
||||
result.add_node( i, p0 );
|
||||
|
||||
// add intermediate points
|
||||
add_intermediate_nodes( i, p0, p1, tmp_nodes, &result );
|
||||
|
||||
// end of segment is beginning of next segment
|
||||
}
|
||||
p0 = poly.get_pt( i, poly.contour_size(i) - 1 );
|
||||
p1 = poly.get_pt( i, 0 );
|
||||
|
||||
// add start of segment
|
||||
result.add_node( i, p0 );
|
||||
|
||||
// add intermediate points
|
||||
add_intermediate_nodes( i, p0, p1, tmp_nodes, &result );
|
||||
|
||||
// end of segment is beginning of next segment
|
||||
// 5/9/2000 CLO - this results in duplicating the last point
|
||||
// of a contour so I have removed this line.
|
||||
// result.add_node( i, p1 );
|
||||
|
||||
// maintain original hole flag setting
|
||||
result.set_hole_flag( i, poly.get_hole_flag( i ) );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Traverse a polygon and split edges until they are less than max_len
|
||||
// (specified in meters)
|
||||
FGPolygon split_long_edges( const FGPolygon &poly, double max_len ) {
|
||||
FGPolygon result;
|
||||
Point3D p0, p1;
|
||||
int i, j, k;
|
||||
|
||||
cout << "split_long_edges()" << endl;
|
||||
|
||||
for ( i = 0; i < poly.contours(); ++i ) {
|
||||
// cout << "contour = " << i << endl;
|
||||
for ( j = 0; j < poly.contour_size(i) - 1; ++j ) {
|
||||
p0 = poly.get_pt( i, j );
|
||||
p1 = poly.get_pt( i, j + 1 );
|
||||
|
||||
double az1, az2, s;
|
||||
geo_inverse_wgs_84( 0.0,
|
||||
p0.y(), p0.x(), p1.y(), p1.x(),
|
||||
&az1, &az2, &s );
|
||||
cout << "distance = " << s << endl;
|
||||
|
||||
if ( s > max_len ) {
|
||||
int segments = (int)(s / max_len) + 1;
|
||||
cout << "segments = " << segments << endl;
|
||||
|
||||
double dx = (p1.x() - p0.x()) / segments;
|
||||
double dy = (p1.y() - p0.y()) / segments;
|
||||
|
||||
for ( k = 0; k < segments; ++k ) {
|
||||
Point3D tmp( p0.x() + dx * k, p0.y() + dy * k, 0.0 );
|
||||
cout << tmp << endl;
|
||||
result.add_node( i, tmp );
|
||||
}
|
||||
} else {
|
||||
cout << p0 << endl;
|
||||
result.add_node( i, p0 );
|
||||
}
|
||||
|
||||
// end of segment is beginning of next segment
|
||||
}
|
||||
p0 = poly.get_pt( i, poly.contour_size(i) - 1 );
|
||||
p1 = poly.get_pt( i, 0 );
|
||||
|
||||
double az1, az2, s;
|
||||
geo_inverse_wgs_84( 0.0,
|
||||
p0.y(), p0.x(), p1.y(), p1.x(),
|
||||
&az1, &az2, &s );
|
||||
cout << "distance = " << s << endl;
|
||||
|
||||
if ( s > max_len ) {
|
||||
int segments = (int)(s / max_len) + 1;
|
||||
cout << "segments = " << segments << endl;
|
||||
|
||||
double dx = (p1.x() - p0.x()) / segments;
|
||||
double dy = (p1.y() - p0.y()) / segments;
|
||||
|
||||
for ( k = 0; k < segments; ++k ) {
|
||||
Point3D tmp( p0.x() + dx * k, p0.y() + dy * k, 0.0 );
|
||||
cout << tmp << endl;
|
||||
result.add_node( i, tmp );
|
||||
}
|
||||
} else {
|
||||
cout << p0 << endl;
|
||||
result.add_node( i, p0 );
|
||||
}
|
||||
|
||||
// maintain original hole flag setting
|
||||
result.set_hole_flag( i, poly.get_hole_flag( i ) );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Traverse a polygon and toss all the internal holes
|
||||
FGPolygon strip_out_holes( const FGPolygon &poly ) {
|
||||
FGPolygon result; result.erase();
|
||||
|
||||
cout << "strip_out_holes()" << endl;
|
||||
|
||||
for ( int i = 0; i < poly.contours(); ++i ) {
|
||||
// cout << "contour = " << i << endl;
|
||||
point_list contour = poly.get_contour( i );
|
||||
if ( ! poly.get_hole_flag(i) ) {
|
||||
result.add_contour( contour, poly.get_hole_flag(i) );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
59
src/Airports/GenAirports/poly_extra.hxx
Normal file
59
src/Airports/GenAirports/poly_extra.hxx
Normal file
|
@ -0,0 +1,59 @@
|
|||
// poly_extra.hxx -- Extra polygon manipulation routines
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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 _POLY_EXTRA_HXX
|
||||
#define _POLY_EXTRA_HXX
|
||||
|
||||
|
||||
#include <simgear/math/point3d.hxx>
|
||||
|
||||
#include <Geometry/trinodes.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
|
||||
|
||||
// Divide segment if there are other existing points on it, return the
|
||||
// new polygon
|
||||
void add_intermediate_nodes( int contour, const Point3D& start,
|
||||
const Point3D& end, const FGTriNodes& tmp_nodes,
|
||||
FGPolygon *result );
|
||||
|
||||
|
||||
// Search each segment for additional vertex points that may have been
|
||||
// created elsewhere that lie on the segment and split it there to
|
||||
// avoid "T" intersections.
|
||||
|
||||
FGPolygon add_nodes_to_poly( const FGPolygon& poly,
|
||||
const FGTriNodes& tmp_nodes );
|
||||
|
||||
|
||||
// Traverse a polygon and split edges until they are less than max_len
|
||||
// (specified in meters)
|
||||
FGPolygon split_long_edges( const FGPolygon &poly, double max_len );
|
||||
|
||||
|
||||
// Traverse a polygon and toss all the internal holes
|
||||
FGPolygon strip_out_holes( const FGPolygon &poly );
|
||||
|
||||
|
||||
#endif // _POLY_EXTRA_HXX
|
230
src/Airports/GenAirports/rwy_common.cxx
Normal file
230
src/Airports/GenAirports/rwy_common.cxx
Normal file
|
@ -0,0 +1,230 @@
|
|||
// rwy_common.cxx -- Common runway generation routines
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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$
|
||||
//
|
||||
|
||||
|
||||
#include <simgear/constants.h>
|
||||
|
||||
#include "global.hxx"
|
||||
#include "poly_extra.hxx"
|
||||
#include "rwy_common.hxx"
|
||||
|
||||
|
||||
void gen_number_block( const FGRunway& rwy_info,
|
||||
const string& material,
|
||||
FGPolygon poly, double heading, int num,
|
||||
double start_pct, double end_pct,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum )
|
||||
{
|
||||
char tex1[32]; tex1[0] = '\0';
|
||||
char tex2[32]; tex2[0] = '\0';
|
||||
|
||||
cout << "Runway num = " << num << endl;
|
||||
|
||||
if ( num == 11 ) {
|
||||
sprintf( tex1, "11" );
|
||||
} else if ( num < 10 ) {
|
||||
sprintf( tex1, "%dc", num );
|
||||
} else {
|
||||
sprintf( tex1, "%dl", num / 10 );
|
||||
sprintf( tex2, "%dr", num - (num / 10 * 10));
|
||||
}
|
||||
|
||||
// printf("tex1 = '%s' tex2 = '%s'\n", tex1, tex2);
|
||||
|
||||
if ( num < 10 ) {
|
||||
gen_runway_section( rwy_info, poly,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
heading,
|
||||
material, tex1,
|
||||
rwy_polys, texparams, accum );
|
||||
} else if ( num == 11 ) {
|
||||
gen_runway_section( rwy_info, poly,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
heading,
|
||||
material, tex1,
|
||||
rwy_polys, texparams, accum );
|
||||
} else {
|
||||
gen_runway_section( rwy_info, poly,
|
||||
start_pct, end_pct,
|
||||
0.0, 0.5,
|
||||
heading,
|
||||
material, tex1,
|
||||
rwy_polys, texparams, accum );
|
||||
gen_runway_section( rwy_info, poly,
|
||||
start_pct, end_pct,
|
||||
0.5, 1.0,
|
||||
heading,
|
||||
material, tex2,
|
||||
rwy_polys, texparams, accum );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// generate a section of runway
|
||||
void gen_runway_section( const FGRunway& rwy_info,
|
||||
const FGPolygon& runway,
|
||||
double startl_pct, double endl_pct,
|
||||
double startw_pct, double endw_pct,
|
||||
double heading,
|
||||
const string& prefix,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum ) {
|
||||
|
||||
int j, k;
|
||||
|
||||
Point3D a0 = runway.get_pt(0, 1);
|
||||
Point3D a1 = runway.get_pt(0, 2);
|
||||
Point3D a2 = runway.get_pt(0, 0);
|
||||
Point3D a3 = runway.get_pt(0, 3);
|
||||
|
||||
if ( startl_pct > 0.0 ) {
|
||||
startl_pct -= nudge * SG_EPSILON;
|
||||
}
|
||||
if ( endl_pct < 1.0 ) {
|
||||
endl_pct += nudge * SG_EPSILON;
|
||||
}
|
||||
|
||||
if ( endl_pct > 1.0 ) {
|
||||
endl_pct = 1.0;
|
||||
}
|
||||
|
||||
// partial "w" percentages could introduce "T" intersections which
|
||||
// we compensate for later, but could still cause problems now
|
||||
// with our polygon clipping code. This attempts to compensate
|
||||
// for that by nudging the areas a bit bigger so we don't end up
|
||||
// with polygon slivers.
|
||||
if ( startw_pct > 0.0 || endw_pct < 1.0 ) {
|
||||
if ( startw_pct > 0.0 ) {
|
||||
startw_pct -= nudge * SG_EPSILON;
|
||||
}
|
||||
if ( endw_pct < 1.0 ) {
|
||||
endw_pct += nudge * SG_EPSILON;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "start len % = " << startl_pct
|
||||
<< " end len % = " << endl_pct << endl;
|
||||
|
||||
double dlx, dly;
|
||||
|
||||
dlx = a1.x() - a0.x();
|
||||
dly = a1.y() - a0.y();
|
||||
|
||||
Point3D t0 = Point3D( a0.x() + dlx * startl_pct,
|
||||
a0.y() + dly * startl_pct, 0);
|
||||
Point3D t1 = Point3D( a0.x() + dlx * endl_pct,
|
||||
a0.y() + dly * endl_pct, 0);
|
||||
|
||||
dlx = a3.x() - a2.x();
|
||||
dly = a3.y() - a2.y();
|
||||
|
||||
Point3D t2 = Point3D( a2.x() + dlx * startl_pct,
|
||||
a2.y() + dly * startl_pct, 0);
|
||||
|
||||
Point3D t3 = Point3D( a2.x() + dlx * endl_pct,
|
||||
a2.y() + dly * endl_pct, 0);
|
||||
|
||||
cout << "start wid % = " << startw_pct
|
||||
<< " end wid % = " << endw_pct << endl;
|
||||
|
||||
double dwx, dwy;
|
||||
|
||||
dwx = t0.x() - t2.x();
|
||||
dwy = t0.y() - t2.y();
|
||||
|
||||
Point3D p0 = Point3D( t2.x() + dwx * startw_pct,
|
||||
t2.y() + dwy * startw_pct, 0);
|
||||
|
||||
Point3D p1 = Point3D( t2.x() + dwx * endw_pct,
|
||||
t2.y() + dwy * endw_pct, 0);
|
||||
|
||||
dwx = t1.x() - t3.x();
|
||||
dwy = t1.y() - t3.y();
|
||||
|
||||
Point3D p2 = Point3D( t3.x() + dwx * startw_pct,
|
||||
t3.y() + dwy * startw_pct, 0);
|
||||
|
||||
Point3D p3 = Point3D( t3.x() + dwx * endw_pct,
|
||||
t3.y() + dwy * endw_pct, 0);
|
||||
|
||||
FGPolygon section;
|
||||
section.erase();
|
||||
|
||||
section.add_node( 0, p2 );
|
||||
section.add_node( 0, p0 );
|
||||
section.add_node( 0, p1 );
|
||||
section.add_node( 0, p3 );
|
||||
|
||||
// print runway points
|
||||
cout << "pre clipped runway pts " << prefix << material << endl;
|
||||
for ( j = 0; j < section.contours(); ++j ) {
|
||||
for ( k = 0; k < section.contour_size( j ); ++k ) {
|
||||
Point3D p = section.get_pt(j, k);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
}
|
||||
|
||||
FGPolygon clipped = polygon_diff( section, *accum );
|
||||
FGPolygon split = split_long_edges( clipped, 400.0 );
|
||||
FGSuperPoly sp;
|
||||
sp.erase();
|
||||
sp.set_poly( split );
|
||||
sp.set_material( prefix + material );
|
||||
rwy_polys->push_back( sp );
|
||||
cout << "section = " << clipped.contours() << endl;
|
||||
*accum = polygon_union( section, *accum );
|
||||
|
||||
double len = rwy_info.length / 2.0;
|
||||
double start_len = len - ( len * startl_pct );
|
||||
double end_len = len - ( len * endl_pct );
|
||||
|
||||
double wid = rwy_info.width;
|
||||
double start_wid = -wid / 2.0 + wid * startw_pct;
|
||||
double end_wid = -wid / 2.0 + wid * endw_pct;
|
||||
|
||||
FGTexParams tp;
|
||||
tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ),
|
||||
Point3D( start_wid * SG_FEET_TO_METER,
|
||||
end_len * SG_FEET_TO_METER,
|
||||
0.0 ),
|
||||
Point3D( end_wid * SG_FEET_TO_METER,
|
||||
start_len * SG_FEET_TO_METER,
|
||||
0.0 ),
|
||||
heading );
|
||||
texparams->push_back( tp );
|
||||
|
||||
// print runway points
|
||||
cout << "clipped runway pts " << prefix + material << endl;
|
||||
for ( j = 0; j < clipped.contours(); ++j ) {
|
||||
for ( k = 0; k < clipped.contour_size( j ); ++k ) {
|
||||
Point3D p = clipped.get_pt(j, k);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
}
|
||||
}
|
57
src/Airports/GenAirports/rwy_common.hxx
Normal file
57
src/Airports/GenAirports/rwy_common.hxx
Normal file
|
@ -0,0 +1,57 @@
|
|||
// rwy_common.hxx -- Common runway generation routines
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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 _RWY_COMMON_HXX
|
||||
#define _RWY_COMMON_HXX
|
||||
|
||||
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <Polygon/superpoly.hxx>
|
||||
|
||||
#include "runway.hxx"
|
||||
#include "texparams.hxx"
|
||||
|
||||
|
||||
void gen_number_block( const FGRunway& rwy_info,
|
||||
const string& material,
|
||||
FGPolygon poly, double heading, int num,
|
||||
double start_pct, double end_pct,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum );
|
||||
|
||||
// generate a section of runway
|
||||
void gen_runway_section( const FGRunway& rwy_info,
|
||||
const FGPolygon& runway,
|
||||
double startl_pct, double endl_pct,
|
||||
double startw_pct, double endw_pct,
|
||||
double heading,
|
||||
const string& prefix,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum );
|
||||
|
||||
|
||||
#endif // _RWY_COMMON_HXX
|
267
src/Airports/GenAirports/rwy_nonprec.cxx
Normal file
267
src/Airports/GenAirports/rwy_nonprec.cxx
Normal file
|
@ -0,0 +1,267 @@
|
|||
// rwy_nonprec.cxx -- Build a non-precision runway
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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$
|
||||
//
|
||||
|
||||
|
||||
#include "rwy_common.hxx"
|
||||
#include "rwy_nonprec.hxx"
|
||||
|
||||
|
||||
// generate a non-precision approach runway. The routine modifies
|
||||
// rwy_polys, texparams, and accum. For specific details and
|
||||
// dimensions of precision runway markings, please refer to FAA
|
||||
// document AC 150/5340-1H
|
||||
|
||||
void gen_non_precision_rwy( const FGRunway& rwy_info,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum )
|
||||
{
|
||||
int i, j;
|
||||
|
||||
//
|
||||
// Generate the basic runway outlines
|
||||
//
|
||||
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info );
|
||||
|
||||
// runway half "a"
|
||||
FGPolygon runway_a;
|
||||
runway_a.erase();
|
||||
runway_a.add_node( 0, runway.get_pt(0, 0) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 1) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 2) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 5) );
|
||||
|
||||
// runway half "b"
|
||||
FGPolygon runway_b;
|
||||
runway_b.erase();
|
||||
runway_b.add_node( 0, runway.get_pt(0, 3) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 4) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 5) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 2) );
|
||||
|
||||
Point3D p;
|
||||
cout << "raw runway pts (a half)" << endl;
|
||||
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
|
||||
p = runway_a.get_pt(0, j);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
cout << "raw runway pts (b half)" << endl;
|
||||
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
|
||||
p = runway_b.get_pt(0, j);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
|
||||
//
|
||||
// Setup some variables and values to help us chop up the runway
|
||||
// into its various sections
|
||||
//
|
||||
|
||||
FGSuperPoly sp;
|
||||
FGTexParams tp;
|
||||
|
||||
double length = rwy_info.length / 2.0;
|
||||
if ( length < 1150 ) {
|
||||
cout << "This runway is not long enough for non-precision markings!"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
double start_pct = 0;
|
||||
double end_pct = 0;
|
||||
|
||||
//
|
||||
// Threshold
|
||||
//
|
||||
|
||||
end_pct = start_pct + ( 190.0 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "threshold",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "threshold",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
//
|
||||
// Runway designation letter
|
||||
//
|
||||
|
||||
int len = rwy_info.rwy_no.length();
|
||||
string letter = "";
|
||||
string rev_letter = "";
|
||||
for ( i = 0; i < len; ++i ) {
|
||||
string tmp = rwy_info.rwy_no.substr(i, 1);
|
||||
if ( tmp == "L" ) {
|
||||
letter = "L";
|
||||
rev_letter = "R";
|
||||
} else if ( tmp == "R" ) {
|
||||
letter = "R";
|
||||
rev_letter = "L";
|
||||
} else if ( tmp == "C" ) {
|
||||
letter == "C";
|
||||
rev_letter = "C";
|
||||
}
|
||||
}
|
||||
|
||||
cout << "Runway designation = " << rwy_info.rwy_no << endl;
|
||||
cout << "Runway designation letter = " << letter << endl;
|
||||
|
||||
if ( letter != "" ) {
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 90.0 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, rev_letter,
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, letter,
|
||||
rwy_polys, texparams, accum );
|
||||
}
|
||||
|
||||
//
|
||||
// Runway designation number(s)
|
||||
//
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 100.0 / length );
|
||||
|
||||
len = rwy_info.rwy_no.length();
|
||||
string snum = rwy_info.rwy_no;
|
||||
for ( i = 0; i < len; ++i ) {
|
||||
string tmp = rwy_info.rwy_no.substr(i, 1);
|
||||
if ( tmp == "L" || tmp == "R" || tmp == "C" || tmp == " " ) {
|
||||
snum = rwy_info.rwy_no.substr(0, i);
|
||||
}
|
||||
}
|
||||
cout << "Runway num = '" << snum << "'" << endl;
|
||||
int num = atoi( snum.c_str() );
|
||||
|
||||
gen_number_block( rwy_info, material, runway_b, rwy_info.heading + 180.0,
|
||||
num, start_pct, end_pct, rwy_polys, texparams, accum );
|
||||
|
||||
num += 18;
|
||||
if ( num > 36 ) {
|
||||
num -= 36;
|
||||
}
|
||||
|
||||
gen_number_block( rwy_info, material, runway_a, rwy_info.heading,
|
||||
num, start_pct, end_pct, rwy_polys, texparams, accum );
|
||||
|
||||
if ( false ) {
|
||||
//
|
||||
// Intermediate area before aiming point ...
|
||||
//
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 360.0 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 360.0 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
//
|
||||
// Aiming point
|
||||
//
|
||||
|
||||
if ( end_pct >= 1.0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 500 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "aim",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "aim",
|
||||
rwy_polys, texparams, accum );
|
||||
}
|
||||
|
||||
//
|
||||
// The rest ...
|
||||
//
|
||||
|
||||
while ( end_pct < 1.0 ) {
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 400.0 / length );
|
||||
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
}
|
||||
}
|
48
src/Airports/GenAirports/rwy_nonprec.hxx
Normal file
48
src/Airports/GenAirports/rwy_nonprec.hxx
Normal file
|
@ -0,0 +1,48 @@
|
|||
// rwy_nonprec.hxx -- Build a non-precision runway
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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 _RWY_NONPREC_HXX
|
||||
#define _RWY_NONPREC_HXX
|
||||
|
||||
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <Polygon/superpoly.hxx>
|
||||
|
||||
#include "runway.hxx"
|
||||
#include "texparams.hxx"
|
||||
|
||||
|
||||
// generate a non-precision approach runway. The routine modifies
|
||||
// rwy_polys, texparams, and accum. For specific details and
|
||||
// dimensions of precision runway markings, please refer to FAA
|
||||
// document AC 150/5340-1H
|
||||
|
||||
void gen_non_precision_rwy( const FGRunway& rwy_info,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum );
|
||||
|
||||
|
||||
#endif // _RWY_NONPREC_HXX
|
343
src/Airports/GenAirports/rwy_prec.cxx
Normal file
343
src/Airports/GenAirports/rwy_prec.cxx
Normal file
|
@ -0,0 +1,343 @@
|
|||
// rwy_prec.cxx -- Build a precision runway
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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$
|
||||
//
|
||||
|
||||
|
||||
#include "rwy_common.hxx"
|
||||
#include "rwy_nonprec.hxx"
|
||||
|
||||
|
||||
// generate a precision approach runway. The routine modifies
|
||||
// rwy_polys, texparams, and accum. For specific details and
|
||||
// dimensions of precision runway markings, please refer to FAA
|
||||
// document AC 150/5340-1H
|
||||
|
||||
void gen_precision_rwy( const FGRunway& rwy_info,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum )
|
||||
{
|
||||
|
||||
//
|
||||
// Generate the basic runway outlines
|
||||
//
|
||||
|
||||
int i, j;
|
||||
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info );
|
||||
|
||||
// runway half "a"
|
||||
FGPolygon runway_a;
|
||||
runway_a.erase();
|
||||
runway_a.add_node( 0, runway.get_pt(0, 0) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 1) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 2) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 5) );
|
||||
|
||||
|
||||
// runway half "b"
|
||||
FGPolygon runway_b;
|
||||
runway_b.erase();
|
||||
runway_b.add_node( 0, runway.get_pt(0, 3) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 4) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 5) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 2) );
|
||||
|
||||
Point3D p;
|
||||
cout << "raw runway pts (a half)" << endl;
|
||||
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
|
||||
p = runway_a.get_pt(0, j);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
cout << "raw runway pts (b half)" << endl;
|
||||
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
|
||||
p = runway_b.get_pt(0, j);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
|
||||
//
|
||||
// Setup some variables and values to help us chop up the runway
|
||||
// into its various sections
|
||||
//
|
||||
|
||||
FGSuperPoly sp;
|
||||
FGTexParams tp;
|
||||
|
||||
double length = rwy_info.length / 2.0;
|
||||
if ( length < 3075 ) {
|
||||
cout << "This runway is not long enough for precision markings!"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
double start_pct = 0;
|
||||
double end_pct = 0;
|
||||
|
||||
//
|
||||
// Threshold
|
||||
//
|
||||
|
||||
end_pct = start_pct + ( 190.0 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "threshold",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "threshold",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
//
|
||||
// Runway designation letter
|
||||
//
|
||||
|
||||
int len = rwy_info.rwy_no.length();
|
||||
string letter = "";
|
||||
string rev_letter = "";
|
||||
for ( i = 0; i < len; ++i ) {
|
||||
string tmp = rwy_info.rwy_no.substr(i, 1);
|
||||
if ( tmp == "L" ) {
|
||||
letter = "L";
|
||||
rev_letter = "R";
|
||||
} else if ( tmp == "R" ) {
|
||||
letter = "R";
|
||||
rev_letter = "L";
|
||||
} else if ( tmp == "C" ) {
|
||||
letter == "C";
|
||||
rev_letter = "C";
|
||||
}
|
||||
}
|
||||
|
||||
cout << "Runway designation = " << rwy_info.rwy_no << endl;
|
||||
cout << "Runway designation letter = " << letter << endl;
|
||||
|
||||
if ( letter != "" ) {
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 90.0 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, rev_letter,
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, letter,
|
||||
rwy_polys, texparams, accum );
|
||||
}
|
||||
|
||||
//
|
||||
// Runway designation number(s)
|
||||
//
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 90.0 / length );
|
||||
|
||||
len = rwy_info.rwy_no.length();
|
||||
string snum = rwy_info.rwy_no;
|
||||
for ( i = 0; i < len; ++i ) {
|
||||
string tmp = rwy_info.rwy_no.substr(i, 1);
|
||||
if ( tmp == "L" || tmp == "R" || tmp == "C" || tmp == " " ) {
|
||||
snum = rwy_info.rwy_no.substr(0, i);
|
||||
}
|
||||
}
|
||||
cout << "Runway num = '" << snum << "'" << endl;
|
||||
int num = atoi( snum.c_str() );
|
||||
|
||||
gen_number_block( rwy_info, material, runway_b, rwy_info.heading + 180.0,
|
||||
num, start_pct, end_pct, rwy_polys, texparams, accum );
|
||||
|
||||
num += 18;
|
||||
if ( num > 36 ) {
|
||||
num -= 36;
|
||||
}
|
||||
|
||||
gen_number_block( rwy_info, material, runway_a, rwy_info.heading,
|
||||
num, start_pct, end_pct, rwy_polys, texparams, accum );
|
||||
|
||||
//
|
||||
// Touch down zone x3
|
||||
//
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 650 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "tz_three",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "tz_three",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
//
|
||||
// Aiming point
|
||||
//
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 500 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "aim",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "aim",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
//
|
||||
// Touch down zone x2 (first)
|
||||
//
|
||||
|
||||
if ( end_pct >= 1.0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 500 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "tz_two_a",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "tz_two_a",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
//
|
||||
// Touch down zone x2 (second)
|
||||
//
|
||||
|
||||
if ( end_pct >= 1.0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 500 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "tz_two_b",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "tz_two_b",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
//
|
||||
// Touch down zone x1 (first)
|
||||
//
|
||||
|
||||
if ( end_pct >= 1.0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 500 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "tz_one_a",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "tz_one_a",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
//
|
||||
// Touch down zone x1 (second)
|
||||
//
|
||||
|
||||
if ( end_pct >= 1.0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 500 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "tz_one_b",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "tz_one_b",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
//
|
||||
// The rest ...
|
||||
//
|
||||
|
||||
while ( end_pct < 1.0 ) {
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 400.0 / length );
|
||||
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
}
|
||||
}
|
48
src/Airports/GenAirports/rwy_prec.hxx
Normal file
48
src/Airports/GenAirports/rwy_prec.hxx
Normal file
|
@ -0,0 +1,48 @@
|
|||
// rwy_prec.hxx -- Build a precision runway
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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 _RWY_PREC_HXX
|
||||
#define _RWY_PREC_HXX
|
||||
|
||||
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <Polygon/superpoly.hxx>
|
||||
|
||||
#include "runway.hxx"
|
||||
#include "texparams.hxx"
|
||||
|
||||
|
||||
// generate a precision approach runway. The routine modifies
|
||||
// rwy_polys, texparams, and accum. For specific details and
|
||||
// dimensions of precision runway markings, please refer to FAA
|
||||
// document AC 150/5340-1H
|
||||
|
||||
void gen_precision_rwy( const FGRunway& rwy_info,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum );
|
||||
|
||||
|
||||
#endif // _RWY_PREC_HXX
|
137
src/Airports/GenAirports/rwy_simple.cxx
Normal file
137
src/Airports/GenAirports/rwy_simple.cxx
Normal file
|
@ -0,0 +1,137 @@
|
|||
// rwy_simple.cxx -- Build a simple (non-marked) runway
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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$
|
||||
//
|
||||
|
||||
|
||||
#include <simgear/constants.h>
|
||||
|
||||
#include "poly_extra.hxx"
|
||||
#include "rwy_common.hxx"
|
||||
#include "rwy_nonprec.hxx"
|
||||
|
||||
|
||||
// generate a simple runway. The routine modifies rwy_polys,
|
||||
// texparams, and accum
|
||||
void gen_simple_rwy( const FGRunway& rwy_info, const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum )
|
||||
{
|
||||
int j, k;
|
||||
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info );
|
||||
|
||||
// runway half "a"
|
||||
FGPolygon runway_a;
|
||||
runway_a.erase();
|
||||
runway_a.add_node( 0, runway.get_pt(0, 0) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 1) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 2) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 5) );
|
||||
|
||||
// runway half "b"
|
||||
FGPolygon runway_b;
|
||||
runway_b.erase();
|
||||
runway_b.add_node( 0, runway.get_pt(0, 5) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 2) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 3) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 4) );
|
||||
|
||||
Point3D p;
|
||||
cout << "raw runway pts (a half)" << endl;
|
||||
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
|
||||
p = runway_a.get_pt(0, j);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
cout << "raw runway pts (b half)" << endl;
|
||||
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
|
||||
p = runway_b.get_pt(0, j);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
|
||||
FGSuperPoly sp;
|
||||
FGTexParams tp;
|
||||
|
||||
FGPolygon clipped_a = polygon_diff( runway_a, *accum );
|
||||
FGPolygon split_a = split_long_edges( clipped_a, 400.0 );
|
||||
sp.erase();
|
||||
sp.set_poly( split_a );
|
||||
sp.set_material( material );
|
||||
rwy_polys->push_back( sp );
|
||||
cout << "clipped_a = " << clipped_a.contours() << endl;
|
||||
*accum = polygon_union( runway_a, *accum );
|
||||
tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ),
|
||||
Point3D( (-rwy_info.width / 2.0) * SG_FEET_TO_METER,
|
||||
0.0,
|
||||
0 ),
|
||||
Point3D( (rwy_info.width / 2.0) * SG_FEET_TO_METER,
|
||||
(rwy_info.length / 2.0) * SG_FEET_TO_METER,
|
||||
0.0 ),
|
||||
rwy_info.heading );
|
||||
texparams->push_back( tp );
|
||||
|
||||
FGPolygon clipped_b = polygon_diff( runway_b, *accum );
|
||||
FGPolygon split_b = split_long_edges( clipped_b, 400.0 );
|
||||
sp.erase();
|
||||
sp.set_poly( split_b );
|
||||
sp.set_material( material );
|
||||
rwy_polys->push_back( sp );
|
||||
cout << "clipped_b = " << clipped_b.contours() << endl;
|
||||
*accum = polygon_union( runway_b, *accum );
|
||||
tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ),
|
||||
Point3D( (-rwy_info.width / 2.0) * SG_FEET_TO_METER,
|
||||
0.0,
|
||||
0 ),
|
||||
Point3D( (rwy_info.width / 2.0) * SG_FEET_TO_METER,
|
||||
(rwy_info.length / 2.0) * SG_FEET_TO_METER,
|
||||
0.0 ),
|
||||
rwy_info.heading + 180.0 );
|
||||
texparams->push_back( tp );
|
||||
|
||||
#if 0
|
||||
// after clip, but before removing T intersections
|
||||
char tmpa[256], tmpb[256];
|
||||
sprintf( tmpa, "a%d", i );
|
||||
sprintf( tmpb, "b%d", i );
|
||||
write_polygon( clipped_a, tmpa );
|
||||
write_polygon( clipped_b, tmpb );
|
||||
#endif
|
||||
|
||||
// print runway points
|
||||
cout << "clipped runway pts (a)" << endl;
|
||||
for ( j = 0; j < clipped_a.contours(); ++j ) {
|
||||
for ( k = 0; k < clipped_a.contour_size( j ); ++k ) {
|
||||
p = clipped_a.get_pt(j, k);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// print runway points
|
||||
cout << "clipped runway pts (b)" << endl;
|
||||
for ( j = 0; j < clipped_b.contours(); ++j ) {
|
||||
for ( k = 0; k < clipped_b.contour_size( j ); ++k ) {
|
||||
p = clipped_b.get_pt(j, k);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
44
src/Airports/GenAirports/rwy_simple.hxx
Normal file
44
src/Airports/GenAirports/rwy_simple.hxx
Normal file
|
@ -0,0 +1,44 @@
|
|||
// rwy_simple.hxx -- Build a simple (non-marked) runway
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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 _RWY_SIMPLE_HXX
|
||||
#define _RWY_SIMPLE_HXX
|
||||
|
||||
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <Polygon/superpoly.hxx>
|
||||
|
||||
#include "runway.hxx"
|
||||
#include "texparams.hxx"
|
||||
|
||||
|
||||
// generate a simple runway. The routine modifies rwy_polys,
|
||||
// texparams, and accum
|
||||
void gen_simple_rwy( const FGRunway& rwy_info, const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum );
|
||||
|
||||
|
||||
#endif // _RWY_SIMPLE_HXX
|
260
src/Airports/GenAirports/rwy_visual.cxx
Normal file
260
src/Airports/GenAirports/rwy_visual.cxx
Normal file
|
@ -0,0 +1,260 @@
|
|||
// rwy_visual.cxx -- Build a visual approach runway
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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$
|
||||
//
|
||||
|
||||
|
||||
#include "rwy_common.hxx"
|
||||
#include "rwy_visual.hxx"
|
||||
|
||||
|
||||
// generate a visual approach runway. The routine modifies rwy_polys,
|
||||
// texparams, and accum. For specific details and dimensions of
|
||||
// precision runway markings, please refer to FAA document AC
|
||||
// 150/5340-1H
|
||||
|
||||
void gen_visual_rwy( const FGRunway& rwy_info,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum )
|
||||
{
|
||||
int i, j;
|
||||
|
||||
//
|
||||
// Generate the basic runway outlines
|
||||
//
|
||||
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info );
|
||||
|
||||
// runway half "a"
|
||||
FGPolygon runway_a;
|
||||
runway_a.erase();
|
||||
runway_a.add_node( 0, runway.get_pt(0, 0) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 1) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 2) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 5) );
|
||||
|
||||
// runway half "b"
|
||||
FGPolygon runway_b;
|
||||
runway_b.erase();
|
||||
runway_b.add_node( 0, runway.get_pt(0, 3) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 4) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 5) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 2) );
|
||||
|
||||
Point3D p;
|
||||
cout << "raw runway pts (a half)" << endl;
|
||||
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
|
||||
p = runway_a.get_pt(0, j);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
cout << "raw runway pts (b half)" << endl;
|
||||
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
|
||||
p = runway_b.get_pt(0, j);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
|
||||
//
|
||||
// Setup some variables and values to help us chop up the runway
|
||||
// into its various sections
|
||||
//
|
||||
|
||||
FGSuperPoly sp;
|
||||
FGTexParams tp;
|
||||
|
||||
double length = rwy_info.length / 2.0;
|
||||
if ( length < 1150 ) {
|
||||
cout << "This runway is not long enough for visual markings!"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
double start_pct = 0;
|
||||
double end_pct = 0;
|
||||
|
||||
|
||||
//
|
||||
// Runway designation letter
|
||||
//
|
||||
|
||||
int len = rwy_info.rwy_no.length();
|
||||
string letter = "";
|
||||
string rev_letter = "";
|
||||
for ( i = 0; i < len; ++i ) {
|
||||
string tmp = rwy_info.rwy_no.substr(i, 1);
|
||||
if ( tmp == "L" ) {
|
||||
letter = "L";
|
||||
rev_letter = "R";
|
||||
} else if ( tmp == "R" ) {
|
||||
letter = "R";
|
||||
rev_letter = "L";
|
||||
} else if ( tmp == "C" ) {
|
||||
letter == "C";
|
||||
rev_letter = "C";
|
||||
}
|
||||
}
|
||||
|
||||
cout << "Runway designation = " << rwy_info.rwy_no << endl;
|
||||
cout << "Runway designation letter = " << letter << endl;
|
||||
|
||||
if ( letter != "" ) {
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 90.0 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, rev_letter,
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, letter,
|
||||
rwy_polys, texparams, accum );
|
||||
}
|
||||
|
||||
//
|
||||
// Runway designation number(s)
|
||||
//
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 100.0 / length );
|
||||
|
||||
len = rwy_info.rwy_no.length();
|
||||
string snum = rwy_info.rwy_no;
|
||||
for ( i = 0; i < len; ++i ) {
|
||||
string tmp = rwy_info.rwy_no.substr(i, 1);
|
||||
if ( tmp == "L" || tmp == "R" || tmp == "C" || tmp == " " ) {
|
||||
snum = rwy_info.rwy_no.substr(0, i);
|
||||
}
|
||||
}
|
||||
cout << "Runway num = '" << snum << "'" << endl;
|
||||
int num = atoi( snum.c_str() );
|
||||
|
||||
gen_number_block( rwy_info, material, runway_b, rwy_info.heading + 180.0,
|
||||
num, start_pct, end_pct, rwy_polys, texparams, accum );
|
||||
|
||||
num += 18;
|
||||
if ( num > 36 ) {
|
||||
num -= 36;
|
||||
}
|
||||
|
||||
gen_number_block( rwy_info, material, runway_a, rwy_info.heading,
|
||||
num, start_pct, end_pct, rwy_polys, texparams, accum );
|
||||
|
||||
if ( false ) {
|
||||
//
|
||||
// Intermediate area before aiming point ...
|
||||
//
|
||||
|
||||
if ( end_pct >= 1.0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 450.0 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
if ( end_pct >= 1.0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 450.0 / length );
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
//
|
||||
// Aiming point
|
||||
//
|
||||
|
||||
if ( end_pct >= 1.0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 500 / length );
|
||||
if ( end_pct > 1.0 ) { end_pct = 1.0; }
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "aim",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "aim",
|
||||
rwy_polys, texparams, accum );
|
||||
}
|
||||
|
||||
//
|
||||
// The rest ...
|
||||
//
|
||||
|
||||
while ( end_pct < 1.0 ) {
|
||||
start_pct = end_pct;
|
||||
end_pct = start_pct + ( 400.0 / length );
|
||||
|
||||
gen_runway_section( rwy_info, runway_a,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
|
||||
gen_runway_section( rwy_info, runway_b,
|
||||
start_pct, end_pct,
|
||||
0.0, 1.0,
|
||||
rwy_info.heading + 180.0,
|
||||
material, "rest",
|
||||
rwy_polys, texparams, accum );
|
||||
}
|
||||
}
|
||||
|
||||
|
48
src/Airports/GenAirports/rwy_visual.hxx
Normal file
48
src/Airports/GenAirports/rwy_visual.hxx
Normal file
|
@ -0,0 +1,48 @@
|
|||
// rwy_visual.hxx -- Build a visual approach runway
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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 _RWY_VISUAL_HXX
|
||||
#define _RWY_VISUAL_HXX
|
||||
|
||||
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <Polygon/superpoly.hxx>
|
||||
|
||||
#include "runway.hxx"
|
||||
#include "texparams.hxx"
|
||||
|
||||
|
||||
// generate a visual approach runway. The routine modifies rwy_polys,
|
||||
// texparams, and accum. For specific details and dimensions of
|
||||
// precision runway markings, please refer to FAA document AC
|
||||
// 150/5340-1H
|
||||
|
||||
void gen_visual_rwy( const FGRunway& rwy_info,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum );
|
||||
|
||||
|
||||
#endif // _RWY_VISUAL_HXX
|
152
src/Airports/GenAirports/taxiway.cxx
Normal file
152
src/Airports/GenAirports/taxiway.cxx
Normal file
|
@ -0,0 +1,152 @@
|
|||
// taxiway.cxx -- Build a taxiway
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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$
|
||||
//
|
||||
|
||||
|
||||
#include <simgear/constants.h>
|
||||
|
||||
#include "poly_extra.hxx"
|
||||
#include "rwy_common.hxx"
|
||||
#include "taxiway.hxx"
|
||||
|
||||
|
||||
// generate a taxiway. The routine modifies rwy_polys, texparams, and
|
||||
// accum
|
||||
void gen_taxiway( const FGRunway& rwy_info, const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum )
|
||||
{
|
||||
int j, k;
|
||||
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info );
|
||||
|
||||
// runway half "a"
|
||||
FGPolygon runway_a;
|
||||
runway_a.erase();
|
||||
runway_a.add_node( 0, runway.get_pt(0, 0) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 1) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 2) );
|
||||
runway_a.add_node( 0, runway.get_pt(0, 5) );
|
||||
|
||||
// runway half "b"
|
||||
FGPolygon runway_b;
|
||||
runway_b.erase();
|
||||
runway_b.add_node( 0, runway.get_pt(0, 5) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 2) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 3) );
|
||||
runway_b.add_node( 0, runway.get_pt(0, 4) );
|
||||
|
||||
Point3D p;
|
||||
cout << "raw runway pts (a half)" << endl;
|
||||
for ( j = 0; j < runway_a.contour_size( 0 ); ++j ) {
|
||||
p = runway_a.get_pt(0, j);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
cout << "raw runway pts (b half)" << endl;
|
||||
for ( j = 0; j < runway_b.contour_size( 0 ); ++j ) {
|
||||
p = runway_b.get_pt(0, j);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
|
||||
FGSuperPoly sp;
|
||||
FGTexParams tp;
|
||||
|
||||
double xfactor = 1.0;
|
||||
double yfactor = 1.0;
|
||||
if ( fabs(rwy_info.width) > SG_EPSILON ) {
|
||||
xfactor = 150.0 / rwy_info.width;
|
||||
cout << "xfactor = " << xfactor << endl;
|
||||
}
|
||||
if ( fabs(rwy_info.length) > SG_EPSILON ) {
|
||||
yfactor = 150.0 / rwy_info.length;
|
||||
cout << "yfactor = " << yfactor << endl;
|
||||
}
|
||||
|
||||
cout << "len = " << rwy_info.length << endl;
|
||||
cout << "width = " << rwy_info.width << endl;
|
||||
|
||||
FGPolygon clipped_a = polygon_diff( runway_a, *accum );
|
||||
FGPolygon split_a = split_long_edges( clipped_a, 400.0 );
|
||||
sp.erase();
|
||||
sp.set_poly( split_a );
|
||||
sp.set_material( material );
|
||||
sp.set_flag( 1 ); // mark as a taxiway
|
||||
rwy_polys->push_back( sp );
|
||||
cout << "clipped_a = " << clipped_a.contours() << endl;
|
||||
*accum = polygon_union( runway_a, *accum );
|
||||
tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ),
|
||||
Point3D( (-250 / 2.0) * SG_FEET_TO_METER,
|
||||
0.0,
|
||||
0 ),
|
||||
Point3D( (250 / 2.0) * SG_FEET_TO_METER,
|
||||
(250 / 2.0) * SG_FEET_TO_METER,
|
||||
0.0 ),
|
||||
rwy_info.heading );
|
||||
texparams->push_back( tp );
|
||||
|
||||
FGPolygon clipped_b = polygon_diff( runway_b, *accum );
|
||||
FGPolygon split_b = split_long_edges( clipped_b, 400.0 );
|
||||
sp.erase();
|
||||
sp.set_poly( split_b );
|
||||
sp.set_material( material );
|
||||
rwy_polys->push_back( sp );
|
||||
cout << "clipped_b = " << clipped_b.contours() << endl;
|
||||
*accum = polygon_union( runway_b, *accum );
|
||||
tp = FGTexParams( Point3D( rwy_info.lon, rwy_info.lat, 0 ),
|
||||
Point3D( (-250 / 2.0) * SG_FEET_TO_METER,
|
||||
0.0,
|
||||
0 ),
|
||||
Point3D( (250 / 2.0) * SG_FEET_TO_METER,
|
||||
(250 / 2.0) * SG_FEET_TO_METER,
|
||||
0.0 ),
|
||||
rwy_info.heading + 180.0 );
|
||||
texparams->push_back( tp );
|
||||
|
||||
#if 0
|
||||
// after clip, but before removing T intersections
|
||||
char tmpa[256], tmpb[256];
|
||||
sprintf( tmpa, "a%d", i );
|
||||
sprintf( tmpb, "b%d", i );
|
||||
write_polygon( clipped_a, tmpa );
|
||||
write_polygon( clipped_b, tmpb );
|
||||
#endif
|
||||
|
||||
// print runway points
|
||||
cout << "clipped runway pts (a)" << endl;
|
||||
for ( j = 0; j < clipped_a.contours(); ++j ) {
|
||||
for ( k = 0; k < clipped_a.contour_size( j ); ++k ) {
|
||||
p = clipped_a.get_pt(j, k);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// print runway points
|
||||
cout << "clipped runway pts (b)" << endl;
|
||||
for ( j = 0; j < clipped_b.contours(); ++j ) {
|
||||
for ( k = 0; k < clipped_b.contour_size( j ); ++k ) {
|
||||
p = clipped_b.get_pt(j, k);
|
||||
cout << " point = " << p << endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
44
src/Airports/GenAirports/taxiway.hxx
Normal file
44
src/Airports/GenAirports/taxiway.hxx
Normal file
|
@ -0,0 +1,44 @@
|
|||
// taxiway.hxx -- Build a taxiway
|
||||
//
|
||||
// Written by Curtis Olson, started February 2002.
|
||||
//
|
||||
// Copyright (C) 2002 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 _TAXIWAY_HXX
|
||||
#define _TAXIWAY_HXX
|
||||
|
||||
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <Polygon/superpoly.hxx>
|
||||
|
||||
#include "runway.hxx"
|
||||
#include "texparams.hxx"
|
||||
|
||||
|
||||
// generate a taxiway. The routine modifies rwy_polys, texparams, and
|
||||
// accum
|
||||
void gen_taxiway( const FGRunway& rwy_info, const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum );
|
||||
|
||||
|
||||
#endif // _TAXIWAY_HXX
|
Loading…
Add table
Reference in a new issue