1
0
Fork 0

no more TGPolygon or TGTriNodes

This commit is contained in:
Peter Sadrozinski 2012-12-15 11:14:04 -05:00
parent 1e62b55664
commit 91b28879d4
10 changed files with 103 additions and 1716 deletions

View file

@ -284,10 +284,6 @@ int main(int argc, char **argv)
std::string lastaptfile = work_dir+"/last_apt"; std::string lastaptfile = work_dir+"/last_apt";
// initialize persistant polygon counter
std::string counter_file = airportareadir+"/poly_counter";
tgPolygon::ChopIdxInit( counter_file );
tg::Rectangle boundingBox(min, max); tg::Rectangle boundingBox(min, max);
boundingBox.sanify(); boundingBox.sanify();

View file

@ -125,8 +125,9 @@ private:
// Clip Data // Clip Data
bool ClipLandclassPolys( void ); bool ClipLandclassPolys( void );
// Clip Helpers // Clip Helpers
void move_slivers( TGPolygon& in, TGPolygon& out ); // void move_slivers( TGPolygon& in, TGPolygon& out );
void merge_slivers( TGLandclass& clipped, tgcontour_list& sliver_list ); void merge_slivers( TGLandclass& clipped, tgcontour_list& sliver_list );
// Shared edge Matching // Shared edge Matching
@ -192,11 +193,11 @@ public:
void ConstructBucketStage3(); void ConstructBucketStage3();
int load_landcover (); int load_landcover ();
double measure_roughness( TGPolygon &poly ); // double measure_roughness( TGPolygon &poly );
AreaType get_landcover_type (const LandCover &cover, double xpos, double ypos, double dx, double dy); AreaType get_landcover_type (const LandCover &cover, double xpos, double ypos, double dx, double dy);
void make_area( const LandCover &cover, TGPolygon *polys, // void make_area( const LandCover &cover, TGPolygon *polys,
double x1, double y1, double x2, double y2, // double x1, double y1, double x2, double y2,
double half_dx, double half_dy ); // double half_dx, double half_dy );
// land cover file // land cover file
inline std::string get_cover () const { return cover; } inline std::string get_cover () const { return cover; }

View file

@ -46,6 +46,7 @@ static const double quarter_cover_size = cover_size * 0.25;
// make the area specified area, look up the land cover type, and add // make the area specified area, look up the land cover type, and add
// it to polys // it to polys
#if 0
void TGConstruct::make_area( const LandCover &cover, TGPolygon *polys, void TGConstruct::make_area( const LandCover &cover, TGPolygon *polys,
double x1, double y1, double x2, double y2, double x1, double y1, double x2, double y2,
double half_dx, double half_dy ) double half_dx, double half_dy )
@ -75,9 +76,11 @@ void TGConstruct::make_area( const LandCover &cover, TGPolygon *polys,
} }
} }
} }
#endif
// Come up with a "rough" metric for the roughness of the terrain // Come up with a "rough" metric for the roughness of the terrain
// coverted by a polygon // coverted by a polygon
#if 0
double TGConstruct::measure_roughness( TGPolygon &poly ) { double TGConstruct::measure_roughness( TGPolygon &poly ) {
int i; int i;
unsigned int j; unsigned int j;
@ -116,6 +119,7 @@ double TGConstruct::measure_roughness( TGPolygon &poly ) {
return diff / 50.0; return diff / 50.0;
} }
#endif
AreaType TGConstruct::get_landcover_type (const LandCover &cover, double xpos, double ypos, double dx, double dy) AreaType TGConstruct::get_landcover_type (const LandCover &cover, double xpos, double ypos, double dx, double dy)
{ {

View file

@ -16,7 +16,5 @@ add_library(Polygon STATIC
tg_unique_vec2f.hxx tg_unique_vec2f.hxx
tg_unique_vec3d.hxx tg_unique_vec3d.hxx
tg_unique_vec3f.hxx tg_unique_vec3f.hxx
trinodes.cxx
trinodes.hxx
point3d.hxx point3d.hxx
) )

File diff suppressed because it is too large Load diff

View file

@ -33,266 +33,12 @@
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include <zlib.h>
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/math/sg_types.hxx> #include <simgear/math/sg_types.hxx>
#include <Polygon/point3d.hxx>
// forward declaration
class TGPolygon;
#include "clipper.hpp" #include "clipper.hpp"
#define FG_MAX_VERTICES 1500000
typedef std::vector < point_list > polytype;
typedef polytype::iterator polytype_iterator;
typedef polytype::const_iterator const_polytype_iterator;
class TGPolygon {
private:
polytype poly; // polygons
point_list inside_list; // point inside list
int_list hole_list; // hole flag list
public:
// Constructor and destructor
TGPolygon( void );
~TGPolygon( void );
// Add a contour
inline void add_contour( const point_list contour, const int hole_flag )
{
poly.push_back( contour );
inside_list.push_back( Point3D( 0.0 ) );
hole_list.push_back( hole_flag );
}
// Get a contour
inline point_list get_contour( const int i ) const
{
return poly[i];
}
// Delete a contour
inline void delete_contour( const int i )
{
polytype_iterator start_poly = poly.begin();
poly.erase( start_poly + i );
point_list_iterator start_inside = inside_list.begin();
inside_list.erase( start_inside + i );
int_list_iterator start_hole = hole_list.begin();
hole_list.erase( start_hole + i );
}
// Add the specified node (index) to the polygon
inline void add_node( int contour, Point3D p )
{
if ( contour >= (int)poly.size() ) {
// extend polygon
point_list empty_contour;
empty_contour.clear();
for ( int i = 0; i < contour - (int)poly.size() + 1; ++i ) {
poly.push_back( empty_contour );
inside_list.push_back( Point3D(0.0) );
hole_list.push_back( 0 );
}
}
poly[contour].push_back( p );
}
// return size
inline int contours() const
{
return poly.size();
}
inline int contour_size( int contour ) const
{
return poly[contour].size();
}
inline int total_size() const
{
int size = 0;
for ( int i = 0; i < contours(); ++i )
size += poly[i].size();
return size;
}
// return the ith point from the specified contour
inline Point3D get_pt( int contour, int i ) const
{
return poly[contour][i];
}
// update the value of a point
inline void set_pt( int contour, int i, const Point3D& p )
{
poly[contour][i] = p;
}
void get_bounding_box( SGGeod& min, SGGeod& max ) const;
// get and set an arbitrary point inside the specified polygon contour
inline Point3D get_point_inside( const int contour ) const
{
return inside_list[contour];
}
inline void set_point_inside( int contour, const Point3D& p )
{
inside_list[contour] = p;
}
// get and set hole flag
inline int get_hole_flag( const int contour ) const
{
return hole_list[contour];
}
inline void set_hole_flag( const int contour, const int flag )
{
hole_list[contour] = flag;
}
inline bool has_holes() const
{
for (int i = 0; i < contours(); i++)
if (get_hole_flag(i))
return true;
return false;
}
// Set the elevations of points in the current polgyon based on
// the elevations of points in source. For points that are not
// found in source, propogate the value from the nearest matching
// point.
void inherit_elevations( const TGPolygon &source );
// Set the elevations of all points to the specified values
void set_elevations( double elev );
// shift every point in the polygon by lon, lat
void shift( double lon, double lat );
// erase
inline void erase()
{
poly.clear();
}
// informational
// return the area of a contour (assumes simple polygons,
// i.e. non-self intersecting.)
//
// negative areas indicate counter clockwise winding
// positive areas indicate clockwise winding.
double area_contour( const int contour ) const;
// return the smallest interior angle of the contour
double minangle_contour( const int contour );
// return true if contour B is inside countour A
bool is_inside( int a, int b ) const;
// output
void write( const std::string& file ) const;
// output
void write_contour( const int contour, const std::string& file ) const;
void SaveToGzFile( gzFile& fp ) const;
void LoadFromGzFile( gzFile& fp );
// Friends for serialization
friend std::istream& operator>> ( std::istream&, TGPolygon& );
friend std::ostream& operator<< ( std::ostream&, const TGPolygon& );
};
typedef std::vector < TGPolygon > poly_list;
typedef poly_list::iterator poly_list_iterator;
typedef poly_list::const_iterator const_poly_list_iterator;
// Calculate theta of angle (a, b, c)
double tgPolygonCalcAngle(SGVec2d a, SGVec2d b, SGVec2d c);
// canonify the polygon winding, outer contour must be anti-clockwise,
// all inner contours must be clockwise.
TGPolygon tgPolygonCanonify( const TGPolygon& in_poly );
// Traverse a polygon and split edges until they are less than max_len
// (specified in meters)
TGPolygon tgPolygonSplitLongEdges( const TGPolygon &poly, double max_len );
// Traverse a polygon and toss all the internal holes
TGPolygon tgPolygonStripHoles( const TGPolygon &poly );
// Wrapper for the fast Polygon Triangulation based on Seidel's
// Algorithm by Atul Narkhede and Dinesh Manocha
// http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html
TGPolygon tgPolygon2tristrip( const TGPolygon& poly );
void tgPolygonFindSlivers( TGPolygon& in, poly_list& slivers );
// Difference
TGPolygon tgPolygonDiff( const TGPolygon& subject, const TGPolygon& clip );
// Intersection
TGPolygon tgPolygonInt( const TGPolygon& subject, const TGPolygon& clip );
// Exclusive or
TGPolygon tgPolygonXor( const TGPolygon& subject, const TGPolygon& clip );
// Union
TGPolygon tgPolygonUnion( const TGPolygon& subject, const TGPolygon& clip );
TGPolygon tgPolygonUnion( const poly_list& clips );
// wrapper for clipper clip routines
void tgPolygonInitClipperAccumulator( void );
void tgPolygonFreeClipperAccumulator( void );
void tgPolygonDumpAccumulator( char* ds, char* layer, char*name );
void tgPolygonAddToClipperAccumulator( const TGPolygon& subject, bool dump );
TGPolygon tgPolygonDiffClipperWithAccumulator( const TGPolygon& subject );
// Save clipper to shapefile
void clipper_to_shapefile( ClipperLib::Polygons polys, char* datasource );
// Difference
TGPolygon tgPolygonDiffClipper( const TGPolygon& subject, const TGPolygon& clip );
// Intersection
TGPolygon tgPolygonIntClipper( const TGPolygon& subject, const TGPolygon& clip );
// Union
TGPolygon tgPolygonUnionClipper( const TGPolygon& subject, const TGPolygon& clip );
// Expand / Shrink
TGPolygon tgPolygonExpand(const TGPolygon &poly, double delta);
// Simplify
TGPolygon tgPolygonSimplify(const TGPolygon &poly);
void tgPolygonDumpClipper(const TGPolygon &poly);
// Output
std::ostream &operator<<(std::ostream &output, const TGPolygon &poly);
// WORK IN PROGRESS BEGIN ****************************************************** // WORK IN PROGRESS BEGIN ******************************************************
// Looking ato TGPolygon and TGSuperPoly, I think it would be best if we could // Looking ato TGPolygon and TGSuperPoly, I think it would be best if we could
@ -316,7 +62,6 @@ std::ostream &operator<<(std::ostream &output, const TGPolygon &poly);
#include <simgear/bucket/newbucket.hxx> #include <simgear/bucket/newbucket.hxx>
#include <simgear/threads/SGThread.hxx> #include <simgear/threads/SGThread.hxx>
#include <Polygon/trinodes.hxx>
#include <Polygon/rectangle.hxx> #include <Polygon/rectangle.hxx>
#include "tg_unique_geod.hxx" #include "tg_unique_geod.hxx"
@ -329,6 +74,12 @@ SGGeod OffsetPointMiddle( const SGGeod& gPrev, const SGGeod& gCur, const SGGeod&
SGGeod OffsetPointFirst( const SGGeod& cur, const SGGeod& next, double offset_by ); SGGeod OffsetPointFirst( const SGGeod& cur, const SGGeod& next, double offset_by );
SGGeod OffsetPointLast( const SGGeod& prev, const SGGeod& cur, double offset_by ); SGGeod OffsetPointLast( const SGGeod& prev, const SGGeod& cur, double offset_by );
// what abount this?
// Save clipper to shapefile
void clipper_to_shapefile( ClipperLib::Polygons polys, char* datasource );
// forward declaration // forward declaration
// Forward Declaration: // Forward Declaration:
class tgPolygon; class tgPolygon;
@ -401,7 +152,7 @@ public:
static tgPolygon Diff( const tgContour& subject, tgPolygon& clip ); static tgPolygon Diff( const tgContour& subject, tgPolygon& clip );
static tgContour AddColinearNodes( const tgContour& subject, TGTriNodes nodes ); static tgContour AddColinearNodes( const tgContour& subject, UniqueSGGeodSet& nodes );
static tgContour AddColinearNodes( const tgContour& subject, std::vector<SGGeod>& nodes ); static tgContour AddColinearNodes( const tgContour& subject, std::vector<SGGeod>& nodes );
static bool FindColinearLine( const tgContour& subject, const SGGeod& node, SGGeod& start, SGGeod& end ); static bool FindColinearLine( const tgContour& subject, const SGGeod& node, SGGeod& start, SGGeod& end );
@ -748,7 +499,7 @@ public:
static void Tesselate( const tgPolygon& subject ); static void Tesselate( const tgPolygon& subject );
static tgPolygon AddColinearNodes( const tgPolygon& subject, TGTriNodes& nodes ); static tgPolygon AddColinearNodes( const tgPolygon& subject, UniqueSGGeodSet& nodes );
static tgPolygon AddColinearNodes( const tgPolygon& subject, std::vector<SGGeod>& nodes ); static tgPolygon AddColinearNodes( const tgPolygon& subject, std::vector<SGGeod>& nodes );
static bool FindColinearLine( const tgPolygon& subject, SGGeod& node, SGGeod& start, SGGeod& end ); static bool FindColinearLine( const tgPolygon& subject, SGGeod& node, SGGeod& start, SGGeod& end );
@ -851,17 +602,6 @@ public:
type = t; type = t;
} }
// TEMP TEMP TEMP : need to redo Airport.cxx methods
point_list TempGetPosListAsPoint3D( void ) {
point_list p3dlist;
for (unsigned int i=0; i<lights.size(); i++) {
p3dlist.push_back( Point3D::fromSGGeod( lights[i].pos ) );
}
return p3dlist;
}
std::vector<SGGeod> GetPositionList( void ) { std::vector<SGGeod> GetPositionList( void ) {
std::vector<SGGeod> positions; std::vector<SGGeod> positions;
@ -872,16 +612,6 @@ public:
return positions; return positions;
} }
point_list TempGetNormalListAsPoint3D( void ) {
point_list p3dlist;
for (unsigned int i=0; i<lights.size(); i++) {
p3dlist.push_back( Point3D::fromSGVec3( lights[i].norm ) );
}
return p3dlist;
}
std::vector<SGVec3f> GetNormalList( void ) { std::vector<SGVec3f> GetNormalList( void ) {
std::vector<SGVec3f> normals; std::vector<SGVec3f> normals;
@ -892,8 +622,6 @@ public:
return normals; return normals;
} }
// END TEMP TEMP TEMP
// Friend for output // Friend for output
friend std::ostream& operator<< ( std::ostream&, const tgLightContour& ); friend std::ostream& operator<< ( std::ostream&, const tgLightContour& );
@ -929,12 +657,9 @@ public:
static void Init( void ); static void Init( void );
static void* OpenDatasource( const char* datasource_name ); static void* OpenDatasource( const char* datasource_name );
static void* OpenLayer( void* ds_id, const char* layer_name ); static void* OpenLayer( void* ds_id, const char* layer_name );
static void CreateFeature( void* ds_id, void* l_id, const TGPolygon &poly, const char* description ); // static void CreateFeature( void* ds_id, void* l_id, const TGPolygon &poly, const char* description );
static void CloseLayer( void* l_id ); static void CloseLayer( void* l_id );
static void* CloseDatasource( void* ds_id ); static void* CloseDatasource( void* ds_id );
}; };
#endif // _POLYGON_HXX #endif // _POLYGON_HXX

View file

@ -8,9 +8,6 @@
#include <cstdlib> #include <cstdlib>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
//#include <CGAL/Cartesian.h>
//#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Kd_tree.h> #include <CGAL/Kd_tree.h>
#include <CGAL/algorithm.h> #include <CGAL/algorithm.h>
#include <CGAL/Fuzzy_iso_box.h> #include <CGAL/Fuzzy_iso_box.h>
@ -144,6 +141,7 @@ private:
Tree tg_kd_tree; Tree tg_kd_tree;
bool kd_tree_valid; bool kd_tree_valid;
#if 0
// return true of the two points are "close enough" as defined by // return true of the two points are "close enough" as defined by
// FG_PROXIMITY_EPSILON // FG_PROXIMITY_EPSILON
bool close_enough_2d( const SGGeod& p1, const SGGeod& p2 ) const; bool close_enough_2d( const SGGeod& p1, const SGGeod& p2 ) const;
@ -155,9 +153,10 @@ private:
// return true of the two points are "close enough" as defined by // return true of the two points are "close enough" as defined by
// FG_COURSE_EPSILON // FG_COURSE_EPSILON
bool course_close_enough( const SGGeod& p1, const SGGeod& p2 ); bool course_close_enough( const SGGeod& p1, const SGGeod& p2 );
#endif
}; };
#if 0
// return true of the two points are "close enough" as defined by // return true of the two points are "close enough" as defined by
// FG_PROXIMITY_EPSILON checking just x and y dimensions // FG_PROXIMITY_EPSILON checking just x and y dimensions
inline bool TGNodes::close_enough_2d( const SGGeod& p1, const SGGeod& p2 ) inline bool TGNodes::close_enough_2d( const SGGeod& p1, const SGGeod& p2 )
@ -196,5 +195,6 @@ inline bool TGNodes::course_close_enough( const SGGeod& p1, const SGGeod& p2 )
return false; return false;
} }
} }
#endif
#endif // _TG_NODES_HXX #endif // _TG_NODES_HXX

View file

@ -1,163 +0,0 @@
// trinodes.cxx -- "Triangle" nodes management class
//
// Written by Curtis Olson, started March 1999.
//
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id: trinodes.cxx,v 1.7 2004-11-19 22:25:50 curt Exp $
#include "trinodes.hxx"
// Constructor
TGTriNodes::TGTriNodes( void ) {
}
// Destructor
TGTriNodes::~TGTriNodes( void ) {
}
// Add a point to the point list if it doesn't already exist. Returns
// the index (starting at zero) of the point in the list.
int TGTriNodes::unique_add( const Point3D& p ) {
point_list_iterator current, last;
int counter = 0;
// cout << "unique add = " << p << endl;
// see if point already exists
current = node_list.begin();
last = node_list.end();
for ( ; current != last; ++current ) {
if ( close_enough_2d(p, *current) ) {
// cout << "found an existing match!" << endl;
// update elevation if new point has better info
if ( current->z() < -9000 ) {
current->setz( p.z() );
}
return counter;
}
++counter;
}
// add to list
node_list.push_back( p );
return counter;
}
// Add a point to the point list if it doesn't already exist (checking
// all three dimensions.) Returns the index (starting at zero) of the
// point in the list.
int TGTriNodes::unique_add_3d( const Point3D& p ) {
point_list_iterator current, last;
int counter = 0;
// cout << p.x() << "," << p.y() << endl;
// see if point already exists
current = node_list.begin();
last = node_list.end();
for ( ; current != last; ++current ) {
if ( close_enough_3d(p, *current) ) {
// cout << "found an existing match!" << endl;
return counter;
}
++counter;
}
// add to list
node_list.push_back( p );
return counter;
}
// Add the point with no uniqueness checking
int TGTriNodes::simple_add( const Point3D& p ) {
node_list.push_back( p );
return node_list.size() - 1;
}
// Add a point to the point list if it doesn't already exist. Returns
// the index (starting at zero) of the point in the list. Use a
// course proximity check
int TGTriNodes::course_add( const Point3D& p ) {
point_list_iterator current, last;
int counter = 0;
// cout << p.x() << "," << p.y() << endl;
// see if point already exists
current = node_list.begin();
last = node_list.end();
for ( ; current != last; ++current ) {
if ( course_close_enough(p, *current) ) {
// cout << "found an existing match!" << endl;
// update elevation if new point has better info
if ( current->z() < -9000 ) {
current->setz( p.z() );
}
return counter;
}
++counter;
}
// add to list
node_list.push_back( p );
return counter;
}
// Find the index of the specified point (compair to the same
// tolerance as unique_add(). Returns -1 if not found.
int TGTriNodes::find( const Point3D& p ) const {
const_point_list_iterator current, last;
int counter = 0;
// cout << p.x() << "," << p.y() << endl;
// see if point already exists
current = node_list.begin();
last = node_list.end();
for ( ; current != last; ++current ) {
if ( close_enough_2d(p, *current) ) {
// cout << "found an existing match!" << endl;
return counter;
}
++counter;
}
return -1;
}

View file

@ -1,148 +0,0 @@
// trinodes.hxx -- "Triangle" nodes management class
//
// Written by Curtis Olson, started March 1999.
//
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id: trinodes.hxx,v 1.7 2004/11/19 22:25:50 curt Exp $
#ifndef _TRINODES_HXX
#define _TRINODES_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#include <simgear/compiler.h>
#include <simgear/math/sg_types.hxx>
#include <Polygon/point3d.hxx>
#define FG_PROXIMITY_EPSILON 0.000001
//#define FG_COURSE_EPSILON 0.0003
#define FG_COURSE_EPSILON 0.0001
class TGTriNodes {
private:
point_list node_list;
// return true of the two points are "close enough" as defined by
// FG_PROXIMITY_EPSILON
bool close_enough_2d( const Point3D& p1, const Point3D& p2 ) const;
// return true of the two points are "close enough" as defined by
// FG_PROXIMITY_EPSILON
bool close_enough_3d( const Point3D& p1, const Point3D& p2 ) const;
// return true of the two points are "close enough" as defined by
// FG_COURSE_EPSILON
bool course_close_enough( const Point3D& p1, const Point3D& p2 );
public:
// Constructor and destructor
TGTriNodes( void );
~TGTriNodes( void );
// delete all the data out of node_list
inline void clear() { node_list.clear(); }
// Add a point to the point list if it doesn't already exist.
// Returns the index (starting at zero) of the point in the list.
int unique_add( const Point3D& p );
// Add a point to the point list if it doesn't already exist
// (checking all three dimensions.) Returns the index (starting
// at zero) of the point in the list.
int unique_add_3d( const Point3D& p );
// Add the point with no uniqueness checking
int simple_add( const Point3D& p );
// Add a point to the point list if it doesn't already exist.
// Returns the index (starting at zero) of the point in the list.
// Use a course proximity check
int course_add( const Point3D& p );
// Find the index of the specified point (compair to the same
// tolerance as unique_add(). Returns -1 if not found.
int find( const Point3D& p ) const;
// return the master node list
inline point_list& get_node_list() { return node_list; }
inline const point_list& get_node_list() const { return node_list; }
inline void set_node_list( point_list pl ) { node_list = pl; }
// return the ith point
inline Point3D get_node( int i ) const { return node_list[i]; }
// return the size of the node list
inline size_t size() const { return node_list.size(); }
};
// return true of the two points are "close enough" as defined by
// FG_PROXIMITY_EPSILON checking just x and y dimensions
inline bool TGTriNodes::close_enough_2d( const Point3D& p1, const Point3D& p2 )
const
{
if ( ( fabs(p1.x() - p2.x()) < FG_PROXIMITY_EPSILON ) &&
( fabs(p1.y() - p2.y()) < FG_PROXIMITY_EPSILON ) ) {
return true;
} else {
return false;
}
}
// return true of the two points are "close enough" as defined by
// FG_PROXIMITY_EPSILON check all three dimensions
inline bool TGTriNodes::close_enough_3d( const Point3D& p1, const Point3D& p2 )
const
{
if ( ( fabs(p1.x() - p2.x()) < FG_PROXIMITY_EPSILON ) &&
( fabs(p1.y() - p2.y()) < FG_PROXIMITY_EPSILON ) &&
( fabs(p1.z() - p2.z()) < FG_PROXIMITY_EPSILON ) ) {
return true;
} else {
return false;
}
}
// return true of the two points are "close enough" as defined by
// FG_COURSE_EPSILON
inline bool TGTriNodes::course_close_enough( const Point3D& p1,
const Point3D& p2 )
{
if ( ( fabs(p1.x() - p2.x()) < FG_COURSE_EPSILON ) &&
( fabs(p1.y() - p2.y()) < FG_COURSE_EPSILON ) ) {
return true;
} else {
return false;
}
}
#endif // _TRINODES_HXX

View file

@ -45,6 +45,7 @@
#include <simgear/misc/sg_dir.hxx> #include <simgear/misc/sg_dir.hxx>
#include <Polygon/polygon.hxx> #include <Polygon/polygon.hxx>
#include <Polygon/point3d.hxx>
#include <ogrsf_frmts.h> #include <ogrsf_frmts.h>