1
0
Fork 0

Use SGGeod as reference point in TGTexParams

This commit is contained in:
Peter Sadrozinski 2012-10-19 17:55:01 -04:00
parent d629fa8215
commit 8698ab4e69
16 changed files with 40 additions and 107 deletions

View file

@ -175,7 +175,7 @@ static TGPolygon rwy_section_tex_coords( const TGPolygon& in_poly, const TGTexPa
TGPolygon result; TGPolygon result;
result.erase(); result.erase();
Point3D ref = tp.get_ref(); SGGeod ref = tp.get_ref();
double width = tp.get_width(); double width = tp.get_width();
double length = tp.get_length(); double length = tp.get_length();
double heading = tp.get_heading(); double heading = tp.get_heading();
@ -204,7 +204,7 @@ static TGPolygon rwy_section_tex_coords( const TGPolygon& in_poly, const TGTexPa
// and ending az1, az2 and distance (s). Lat, lon, and // and ending az1, az2 and distance (s). Lat, lon, and
// azimuth are in degrees. distance in meters // azimuth are in degrees. distance in meters
double az1, az2, dist; double az1, az2, dist;
geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(), geo_inverse_wgs_84( 0, ref.getLatitudeDeg(), ref.getLongitudeDeg(), p.y(), p.x(),
&az1, &az2, &dist ); &az1, &az2, &dist );
SG_LOG(SG_GENERAL, SG_DEBUG, "basic course = " << az2); SG_LOG(SG_GENERAL, SG_DEBUG, "basic course = " << az2);
@ -267,7 +267,7 @@ static TGPolygon shoulder_tex_coords( const TGPolygon& in_poly, const TGTexParam
TGPolygon result; TGPolygon result;
result.erase(); result.erase();
Point3D ref = tp.get_ref(); SGGeod ref = tp.get_ref();
double width = tp.get_width(); double width = tp.get_width();
double length = tp.get_length(); double length = tp.get_length();
double heading = tp.get_heading(); double heading = tp.get_heading();
@ -302,7 +302,7 @@ static TGPolygon shoulder_tex_coords( const TGPolygon& in_poly, const TGTexParam
// and ending az1, az2 and distance (s). Lat, lon, and // and ending az1, az2 and distance (s). Lat, lon, and
// azimuth are in degrees. distance in meters // azimuth are in degrees. distance in meters
double az1, az2, dist; double az1, az2, dist;
geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(), geo_inverse_wgs_84( 0, ref.getLatitudeDeg(), ref.getLongitudeDeg(), p.y(), p.x(),
&az1, &az2, &dist ); &az1, &az2, &dist );
SG_LOG(SG_GENERAL, SG_DEBUG, "basic course from ref = " << az2); SG_LOG(SG_GENERAL, SG_DEBUG, "basic course from ref = " << az2);
@ -358,7 +358,7 @@ static TGPolygon linear_feature_tex_coords( const TGPolygon& in_poly, const TGTe
TGPolygon result; TGPolygon result;
result.erase(); result.erase();
Point3D ref = tp.get_ref(); SGGeod ref = tp.get_ref();
double width = tp.get_width(); double width = tp.get_width();
double length = tp.get_length(); double length = tp.get_length();
double heading = tp.get_heading(); double heading = tp.get_heading();
@ -393,7 +393,7 @@ static TGPolygon linear_feature_tex_coords( const TGPolygon& in_poly, const TGTe
// and ending az1, az2 and distance (s). Lat, lon, and // and ending az1, az2 and distance (s). Lat, lon, and
// azimuth are in degrees. distance in meters // azimuth are in degrees. distance in meters
double az1, az2, dist; double az1, az2, dist;
geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(), geo_inverse_wgs_84( 0, ref.getLatitudeDeg(), ref.getLongitudeDeg(), p.y(), p.x(),
&az1, &az2, &dist ); &az1, &az2, &dist );
SG_LOG(SG_GENERAL, SG_DEBUG, "basic course from ref = " << az2); SG_LOG(SG_GENERAL, SG_DEBUG, "basic course from ref = " << az2);

View file

@ -492,7 +492,7 @@ int ClosedPoly::BuildBtg( superpoly_list* rwy_polys, texparams_list* texparams,
SG_LOG(SG_GENERAL, SG_DEBUG, "tp construct"); SG_LOG(SG_GENERAL, SG_DEBUG, "tp construct");
tp = TGTexParams( pre_tess.get_pt(0,0), 5.0, 5.0, texture_heading ); tp = TGTexParams( pre_tess.get_pt(0,0).toSGGeod(), 5.0, 5.0, texture_heading );
texparams->push_back( tp ); texparams->push_back( tp );
if ( apt_base ) if ( apt_base )

View file

@ -146,7 +146,7 @@ void Helipad::BuildBtg( superpoly_list *rwy_polys,
WriteGeom( helipad, material + "heli", rwy_polys, accum, slivers); WriteGeom( helipad, material + "heli", rwy_polys, accum, slivers);
TGTexParams tp; TGTexParams tp;
tp = TGTexParams( helipad.get_pt(0,0), maxsize, maxsize, heli.heading ); tp = TGTexParams( helipad.get_pt(0,0).toSGGeod(), maxsize, maxsize, heli.heading );
tp.set_minu( 1 ); tp.set_minu( 1 );
tp.set_maxu( 0 ); tp.set_maxu( 0 );
tp.set_minv( 1 ); tp.set_minv( 1 );
@ -187,7 +187,7 @@ void Helipad::BuildBtg( superpoly_list *rwy_polys,
area_geom.add_contour(area_poly.get_contour(i), false); area_geom.add_contour(area_poly.get_contour(i), false);
WriteGeom( area_geom, material + "tiedown", rwy_polys, accum, slivers); WriteGeom( area_geom, material + "tiedown", rwy_polys, accum, slivers);
tp = TGTexParams( area_poly.get_pt(i,0), maxsize, areahight, heading ); tp = TGTexParams( area_poly.get_pt(i,0).toSGGeod(), maxsize, areahight, heading );
tp.set_minu( 1 ); tp.set_minu( 1 );
tp.set_maxu( 0 ); tp.set_maxu( 0 );
tp.set_minv( 1 ); tp.set_minv( 1 );
@ -239,7 +239,7 @@ void Helipad::BuildBtg( superpoly_list *rwy_polys,
sp.set_flag( "heli-shoulder" ); sp.set_flag( "heli-shoulder" );
shoulder_polys.push_back( sp ); shoulder_polys.push_back( sp );
tp = TGTexParams( area_poly.get_pt(0,1), areahight, shoulder_width, heading ); tp = TGTexParams( area_poly.get_pt(0,1).toSGGeod(), areahight, shoulder_width, heading );
tp.set_minu( 1 ); tp.set_minu( 1 );
tp.set_maxu( 0 ); tp.set_maxu( 0 );
tp.set_minv( 1 ); tp.set_minv( 1 );

View file

@ -741,7 +741,7 @@ int LinearFeature::Finish( bool closed, unsigned int idx )
sp.set_flag("lf"); sp.set_flag("lf");
marking_polys.push_back(sp); marking_polys.push_back(sp);
tp = TGTexParams( prev_inner, width, 1.0f, heading ); tp = TGTexParams( prev_inner.toSGGeod(), width, 1.0f, heading );
tp.set_minv(last_end_v); tp.set_minv(last_end_v);
marking_tps.push_back(tp); marking_tps.push_back(tp);

View file

@ -132,11 +132,11 @@ void Runway::gen_shoulder_section( Point3D p0, Point3D p1, Point3D t0, Point3D t
sp.set_flag( "shoulder" ); sp.set_flag( "shoulder" );
if (side == 0) { if (side == 0) {
tp = TGTexParams( poly.get_pt(0,2), width, dist, heading ); tp = TGTexParams( poly.get_pt(0,2).toSGGeod(), width, dist, heading );
tp.set_minu(0); tp.set_minu(0);
tp.set_maxu(1); tp.set_maxu(1);
} else { } else {
tp = TGTexParams( poly.get_pt(0,1), width, dist, heading ); tp = TGTexParams( poly.get_pt(0,1).toSGGeod(), width, dist, heading );
tp.set_minu(1); tp.set_minu(1);
tp.set_maxu(0); tp.set_maxu(0);
} }
@ -391,7 +391,7 @@ void Runway::gen_runway_section( const TGPolygon& runway,
double sect_wid = width * ( endw_pct - startw_pct ); double sect_wid = width * ( endw_pct - startw_pct );
TGTexParams tp; TGTexParams tp;
tp = TGTexParams( p0, tp = TGTexParams( p0.toSGGeod(),
sect_wid, sect_wid,
sect_len, sect_len,
heading ); heading );

View file

@ -174,7 +174,7 @@ int Taxiway::BuildBtg( superpoly_list* rwy_polys, texparams_list* texparams, sup
SG_LOG(SG_GENERAL, SG_DEBUG, "tp construct"); SG_LOG(SG_GENERAL, SG_DEBUG, "tp construct");
tp = TGTexParams( taxi.get_pt(0,0), width, 250*SG_FEET_TO_METER, heading ); tp = TGTexParams( taxi.get_pt(0,0).toSGGeod(), width, 250*SG_FEET_TO_METER, heading );
texparams->push_back( tp ); texparams->push_back( tp );
if ( apt_base ) if ( apt_base )

View file

@ -140,7 +140,7 @@ bool TGConstruct::load_poly(const string& path) {
in >> minv; in >> minv;
in >> maxv; in >> maxv;
tp.set_ref( Point3D(x, y, 0.0f) ); tp.set_ref( SGGeod::fromDeg(x,y) );
tp.set_width( width ); tp.set_width( width );
tp.set_length( length ); tp.set_length( length );
tp.set_heading( heading ); tp.set_heading( heading );

View file

@ -77,7 +77,7 @@ TGPolygon TGConstruct::linear_tex_coords( const TGPolygon& tri, const TGTexParam
result.erase(); result.erase();
Point3D ref = tp.get_ref(); SGGeod ref = tp.get_ref();
double width = tp.get_width(); double width = tp.get_width();
double length = tp.get_length(); double length = tp.get_length();
double heading = tp.get_heading(); double heading = tp.get_heading();
@ -112,7 +112,7 @@ TGPolygon TGConstruct::linear_tex_coords( const TGPolygon& tri, const TGTexParam
// and ending az1, az2 and distance (s). Lat, lon, and // and ending az1, az2 and distance (s). Lat, lon, and
// azimuth are in degrees. distance in meters // azimuth are in degrees. distance in meters
double az1, az2, dist; double az1, az2, dist;
geo_inverse_wgs_84( 0, ref.y(), ref.x(), p.y(), p.x(), geo_inverse_wgs_84( 0, ref.getLatitudeDeg(), ref.getLongitudeDeg(), p.y(), p.x(),
&az1, &az2, &dist ); &az1, &az2, &dist );
SG_LOG(SG_GENERAL, SG_DEBUG, "basic course from ref = " << az2); SG_LOG(SG_GENERAL, SG_DEBUG, "basic course from ref = " << az2);

View file

@ -42,26 +42,6 @@ void TGLandclass::clear(void)
} }
} }
// input from stream
std::istream& operator >> ( std::istream& in, TGLandclass& lc)
{
int i, j, count;
// Load all landclass shapes
for (i=0; i<TG_MAX_AREA_TYPES; i++) {
in >> count;
for (j=0; j<count; j++) {
TGShape shape;
in >> shape;
lc.shapes[i].push_back( shape );
}
}
return in;
}
void TGLandclass::LoadFromGzFile(gzFile& fp) void TGLandclass::LoadFromGzFile(gzFile& fp)
{ {
int i, j, count; int i, j, count;

View file

@ -152,8 +152,7 @@ public:
void SaveToGzFile( gzFile& fp ); void SaveToGzFile( gzFile& fp );
void LoadFromGzFile( gzFile& fp ); void LoadFromGzFile( gzFile& fp );
// Friends for serialization // Friend for output to stream
friend std::istream& operator>> ( std::istream&, TGLandclass& );
friend std::ostream& operator<< ( std::ostream&, const TGLandclass& ); friend std::ostream& operator<< ( std::ostream&, const TGLandclass& );
private: private:

View file

@ -70,39 +70,6 @@ void TGShape::IntersectPolys( void )
} }
} }
// Serialization
// input from stream
std::istream& operator >> ( std::istream& in, TGShape& p)
{
int i, count;
// First, load the clipmask
in >> p.clip_mask;
// Then load superpolys
in >> count;
for (i=0; i<count; i++) {
TGSuperPoly sp;
in >> sp;
p.sps.push_back( sp );
}
// Then load texparams
in >> count;
for (i=0; i<count; i++) {
TGTexParams tp;
in >> tp;
p.tps.push_back( tp );
}
// Load the id, area type and textured flag
in >> p.id;
in >> p.area;
in >> p.textured;
return in;
}
void TGShape::LoadFromGzFile(gzFile& fp) void TGShape::LoadFromGzFile(gzFile& fp)
{ {
int i, count; int i, count;

View file

@ -59,8 +59,7 @@ public:
void SaveToGzFile( gzFile& fp ); void SaveToGzFile( gzFile& fp );
void LoadFromGzFile( gzFile& fp ); void LoadFromGzFile( gzFile& fp );
// Friends for serialization // Friend for output to stream
friend std::istream& operator>> ( std::istream&, TGShape& );
friend std::ostream& operator<< ( std::ostream&, const TGShape& ); friend std::ostream& operator<< ( std::ostream&, const TGShape& );
}; };

View file

@ -767,7 +767,7 @@ makePolygonsTP (const Line &line, double width, poly_list& polys, texparams_list
polys.push_back(poly); polys.push_back(poly);
tp = TGTexParams( prev_inner, width, 20.0f, heading ); tp = TGTexParams( prev_inner.Point3D::toSGGeod(), width, 20.0f, heading );
tp.set_minv(last_end_v); tp.set_minv(last_end_v);
tps.push_back(tp); tps.push_back(tp);

View file

@ -371,7 +371,8 @@ static void clip_and_write_polys_with_tps( string root, long int p_index,
tp = clipped_tps[s]; tp = clipped_tps[s];
fprintf( rfp, "%.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f\n", fprintf( rfp, "%.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f\n",
tp.get_ref().x(), tp.get_ref().y(), tp.get_width(), tp.get_length(), tp.get_ref().getLongitudeDeg(), tp.get_ref().getLatitudeDeg(),
tp.get_width(), tp.get_length(),
tp.get_heading(), tp.get_heading(),
tp.get_minu(), tp.get_maxu(), tp.get_minu(), tp.get_maxu()); tp.get_minu(), tp.get_maxu(), tp.get_minu(), tp.get_maxu());
@ -474,7 +475,8 @@ static void clip_and_write_poly_tp( string root, long int p_index,
fprintf( rfp, "%s\n", poly_type.c_str() ); fprintf( rfp, "%s\n", poly_type.c_str() );
fprintf( rfp, "%.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f\n", fprintf( rfp, "%.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f %.15f\n",
tp.get_ref().x(), tp.get_ref().y(), tp.get_width(), tp.get_length(), tp.get_ref().getLongitudeDeg(), tp.get_ref().getLatitudeDeg(),
tp.get_width(), tp.get_length(),
tp.get_heading(), tp.get_heading(),
tp.get_minu(), tp.get_maxu(), tp.get_minu(), tp.get_maxu()); tp.get_minu(), tp.get_maxu(), tp.get_minu(), tp.get_maxu());

View file

@ -1,3 +1,5 @@
#include <simgear/io/lowlevel.hxx>
#include "texparams.hxx" #include "texparams.hxx"
// Send a TexParam to standard output. // Send a TexParam to standard output.
@ -19,7 +21,7 @@ std::ostream& operator << (std::ostream &output, const TGTexParams &tp)
void TGTexParams::SaveToGzFile(gzFile& fp) void TGTexParams::SaveToGzFile(gzFile& fp)
{ {
sgWritePoint3D( fp, ref ); sgWriteSGGeod( fp, ref );
sgWriteDouble( fp, width ); sgWriteDouble( fp, width );
sgWriteDouble( fp, length ); sgWriteDouble( fp, length );
sgWriteDouble( fp, heading ); sgWriteDouble( fp, heading );
@ -30,26 +32,9 @@ void TGTexParams::SaveToGzFile(gzFile& fp)
sgWriteDouble( fp, maxv ); sgWriteDouble( fp, maxv );
} }
// Read a polygon from input buffer.
std::istream& operator >> (std::istream &input, TGTexParams &tp)
{
// Load the data
input >> tp.ref;
input >> tp.width;
input >> tp.length;
input >> tp.heading;
input >> tp.minu;
input >> tp.maxu;
input >> tp.minv;
input >> tp.maxv;
return input;
}
void TGTexParams::LoadFromGzFile(gzFile& fp) void TGTexParams::LoadFromGzFile(gzFile& fp)
{ {
sgReadPoint3D( fp, ref ); sgReadSGGeod( fp, ref );
sgReadDouble( fp, &width ); sgReadDouble( fp, &width );
sgReadDouble( fp, &length ); sgReadDouble( fp, &length );
sgReadDouble( fp, &heading ); sgReadDouble( fp, &heading );

View file

@ -30,19 +30,21 @@
# error This library requires C++ # error This library requires C++
#endif #endif
#include <istream>
#include <ostream>
#include <vector>
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/math/sg_types.hxx> #include <simgear/math/SGMath.hxx>
#include <Geometry/point3d.hxx> #include <zlib.h> /* for gzFile */
#include <vector>
class TGTexParams { class TGTexParams {
private: private:
Point3D ref; SGGeod ref;
double width; double width;
double length; double length;
double heading; double heading;
@ -58,7 +60,7 @@ public:
inline TGTexParams( void ) inline TGTexParams( void )
{ {
} }
inline TGTexParams( const Point3D &r, const double w, const double l, const double h ) inline TGTexParams( const SGGeod &r, const double w, const double l, const double h )
{ {
ref = r; ref = r;
width = w; width = w;
@ -72,11 +74,11 @@ public:
{ {
} }
inline Point3D get_ref() const inline SGGeod get_ref() const
{ {
return ref; return ref;
} }
inline void set_ref( const Point3D &r ) inline void set_ref( const SGGeod &r )
{ {
ref = r; ref = r;
} }
@ -147,8 +149,7 @@ public:
void SaveToGzFile( gzFile& fp ); void SaveToGzFile( gzFile& fp );
void LoadFromGzFile( gzFile& fp ); void LoadFromGzFile( gzFile& fp );
// Friends for serialization // Friend for output
friend std::istream& operator>> ( std::istream&, TGTexParams& );
friend std::ostream& operator<< ( std::ostream&, const TGTexParams& ); friend std::ostream& operator<< ( std::ostream&, const TGTexParams& );
}; };