whitespace only
This commit is contained in:
parent
631bc02111
commit
d021c32840
12 changed files with 385 additions and 354 deletions
|
@ -178,8 +178,6 @@ bool Airport::isDebugFeature( int feat )
|
||||||
return dbg;
|
return dbg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Airport::BuildBtg(const std::string& root, const string_list& elev_src )
|
void Airport::BuildBtg(const std::string& root, const string_list& elev_src )
|
||||||
{
|
{
|
||||||
tgcontour_list slivers;
|
tgcontour_list slivers;
|
||||||
|
|
|
@ -158,7 +158,7 @@ private:
|
||||||
SGTimeStamp triangulation_time;
|
SGTimeStamp triangulation_time;
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
std::string debug_path;
|
std::string debug_path;
|
||||||
debug_map debug_runways;
|
debug_map debug_runways;
|
||||||
debug_map debug_pavements;
|
debug_map debug_pavements;
|
||||||
debug_map debug_taxiways;
|
debug_map debug_taxiways;
|
||||||
|
|
|
@ -611,7 +611,6 @@ void Runway::gen_rwy( tgpolygon_list& rwy_polys,
|
||||||
runway_half.AddNode( 0, runway.GetNode(5) );
|
runway_half.AddNode( 0, runway.GetNode(5) );
|
||||||
runway_half.AddNode( 0, runway.GetNode(2) );
|
runway_half.AddNode( 0, runway.GetNode(2) );
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
heading = rwy.heading;
|
heading = rwy.heading;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
//
|
||||||
// $Id: names.hxx,v 1.14 2005-09-28 16:43:18 curt Exp $
|
// $Id: names.hxx,v 1.14 2005-09-28 16:43:18 curt Exp $
|
||||||
|
|
||||||
|
|
||||||
#ifndef _PRIORITIES_HXX
|
#ifndef _PRIORITIES_HXX
|
||||||
#define _PRIORITIES_HXX
|
#define _PRIORITIES_HXX
|
||||||
|
@ -31,11 +31,11 @@
|
||||||
|
|
||||||
#include <terragear/tg_polygon.hxx>
|
#include <terragear/tg_polygon.hxx>
|
||||||
|
|
||||||
class TGAreaDefinition {
|
class TGAreaDefinition
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
TGAreaDefinition( const std::string& n, const std::string& c, unsigned int p ) :
|
TGAreaDefinition(const std::string& n, const std::string& c, unsigned int p) : name(n),
|
||||||
name(n),
|
category(c)
|
||||||
category(c)
|
|
||||||
{
|
{
|
||||||
priority = p;
|
priority = p;
|
||||||
smooth_method = 0;
|
smooth_method = 0;
|
||||||
|
@ -43,128 +43,143 @@ public:
|
||||||
default_layer = 0;
|
default_layer = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string const& GetName() const {
|
std::string const& GetName() const
|
||||||
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GetPriority() const {
|
unsigned int GetPriority() const
|
||||||
|
{
|
||||||
return priority;
|
return priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const& GetCategory() const {
|
std::string const& GetCategory() const
|
||||||
|
{
|
||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string name;
|
std::string name;
|
||||||
unsigned int priority;
|
unsigned int priority;
|
||||||
std::string category;
|
std::string category;
|
||||||
|
|
||||||
// future improvements
|
// future improvements
|
||||||
unsigned int smooth_method;
|
unsigned int smooth_method;
|
||||||
tgTexMethod texture_method;
|
tgTexMethod texture_method;
|
||||||
bool layered;
|
bool layered;
|
||||||
unsigned int default_layer;
|
unsigned int default_layer;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<TGAreaDefinition> area_definition_list;
|
typedef std::vector<TGAreaDefinition> area_definition_list;
|
||||||
typedef area_definition_list::const_iterator area_definition_iterator;
|
typedef area_definition_list::const_iterator area_definition_iterator;
|
||||||
|
|
||||||
class TGAreaDefinitions {
|
class TGAreaDefinitions
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
TGAreaDefinitions() :
|
TGAreaDefinitions() : sliver_area_name("<unnamed>")
|
||||||
sliver_area_name("<unnamed>")
|
|
||||||
{
|
{
|
||||||
sliver_area_priority = 0;
|
sliver_area_priority = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
int init( const std::string& filename );
|
int init(const std::string& filename);
|
||||||
unsigned int size() const {
|
unsigned int size() const
|
||||||
|
{
|
||||||
return area_defs.size();
|
return area_defs.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_hole_area( unsigned int p ) const {
|
bool is_hole_area(unsigned int p) const
|
||||||
if ( area_defs[p].GetCategory() == "hole" ) {
|
{
|
||||||
|
if (area_defs[p].GetCategory() == "hole") {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_landmass_area( unsigned int p ) const {
|
bool is_landmass_area(unsigned int p) const
|
||||||
if (( area_defs[p].GetCategory() == "landmass" ) ||
|
{
|
||||||
( area_defs[p].GetCategory() == "other" ) ||
|
if ((area_defs[p].GetCategory() == "landmass") ||
|
||||||
( area_defs[p].GetCategory() == "cliff" )) {
|
(area_defs[p].GetCategory() == "other") ||
|
||||||
|
(area_defs[p].GetCategory() == "cliff")) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_island_area( unsigned int p ) const {
|
bool is_island_area(unsigned int p) const
|
||||||
if ( area_defs[p].GetCategory() == "island" ) {
|
{
|
||||||
|
if (area_defs[p].GetCategory() == "island") {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_road_area( unsigned int p ) const {
|
bool is_road_area(unsigned int p) const
|
||||||
if ( area_defs[p].GetCategory() == "road" ) {
|
{
|
||||||
|
if (area_defs[p].GetCategory() == "road") {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_water_area( unsigned int p ) const {
|
bool is_water_area(unsigned int p) const
|
||||||
if ( ( area_defs[p].GetCategory() == "ocean" ) ||
|
{
|
||||||
( area_defs[p].GetCategory() == "lake" ) ){
|
if ((area_defs[p].GetCategory() == "ocean") ||
|
||||||
|
(area_defs[p].GetCategory() == "lake")) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_lake_area( unsigned int p ) const {
|
bool is_lake_area(unsigned int p) const
|
||||||
if ( area_defs[p].GetCategory() == "lake" ) {
|
{
|
||||||
|
if (area_defs[p].GetCategory() == "lake") {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_stream_area( unsigned int p ) const {
|
bool is_stream_area(unsigned int p) const
|
||||||
if ( area_defs[p].GetCategory() == "stream" ) {
|
{
|
||||||
|
if (area_defs[p].GetCategory() == "stream") {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_ocean_area( unsigned int p ) const {
|
bool is_ocean_area(unsigned int p) const
|
||||||
if ( area_defs[p].GetCategory() == "ocean" ) {
|
{
|
||||||
|
if (area_defs[p].GetCategory() == "ocean") {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_cliff_area( unsigned int p ) const {
|
bool is_cliff_area(unsigned int p) const
|
||||||
if (area_defs[p].GetCategory() == "cliff" ) {
|
{
|
||||||
return true;
|
if (area_defs[p].GetCategory() == "cliff") {
|
||||||
} else {
|
return true;
|
||||||
return false;
|
} else {
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string const& get_area_name( unsigned int p ) const {
|
std::string const& get_area_name(unsigned int p) const
|
||||||
|
{
|
||||||
return area_defs[p].GetName();
|
return area_defs[p].GetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int get_area_priority( const std::string& name ) const {
|
unsigned int get_area_priority(const std::string& name) const
|
||||||
for (unsigned int i=0; i < area_defs.size(); i++) {
|
{
|
||||||
if ( area_defs[i].GetName() == name ) {
|
for (unsigned int i = 0; i < area_defs.size(); i++) {
|
||||||
|
if (area_defs[i].GetName() == name) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,18 +190,20 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string const& get_sliver_area_name( void ) const {
|
std::string const& get_sliver_area_name(void) const
|
||||||
|
{
|
||||||
return sliver_area_name;
|
return sliver_area_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int get_sliver_area_priority( void ) const {
|
unsigned int get_sliver_area_priority(void) const
|
||||||
|
{
|
||||||
return sliver_area_priority;
|
return sliver_area_priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
area_definition_list area_defs;
|
area_definition_list area_defs;
|
||||||
std::string sliver_area_name;
|
std::string sliver_area_name;
|
||||||
unsigned int sliver_area_priority;
|
unsigned int sliver_area_priority;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,33 +26,33 @@
|
||||||
#define _CONSTRUCT_HXX
|
#define _CONSTRUCT_HXX
|
||||||
|
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
# error This library requires C++
|
#error This library requires C++
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <simgear/threads/SGThread.hxx>
|
|
||||||
#include <simgear/threads/SGQueue.hxx>
|
#include <simgear/threads/SGQueue.hxx>
|
||||||
|
#include <simgear/threads/SGThread.hxx>
|
||||||
|
|
||||||
#include <Array/array.hxx>
|
#include <Array/array.hxx>
|
||||||
#include <terragear/tg_nodes.hxx>
|
|
||||||
#include <landcover/landcover.hxx>
|
#include <landcover/landcover.hxx>
|
||||||
|
#include <terragear/tg_nodes.hxx>
|
||||||
|
|
||||||
#include "tglandclass.hxx"
|
#include "tglandclass.hxx"
|
||||||
#include "priorities.hxx"
|
#include "priorities.hxx"
|
||||||
|
|
||||||
#define FIND_SLIVERS (0)
|
#define FIND_SLIVERS (0)
|
||||||
|
|
||||||
// Stage2 shared edge data
|
// Stage2 shared edge data
|
||||||
struct TGNeighborFaces {
|
struct TGNeighborFaces {
|
||||||
public:
|
public:
|
||||||
SGGeod node;
|
SGGeod node;
|
||||||
|
|
||||||
double_list elevations; // we'll take the average
|
double_list elevations; // we'll take the average
|
||||||
double_list face_areas;
|
double_list face_areas;
|
||||||
std::vector<SGVec3f> face_normals;
|
std::vector<SGVec3f> face_normals;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector < TGNeighborFaces > neighbor_face_list;
|
typedef std::vector<TGNeighborFaces> neighbor_face_list;
|
||||||
typedef neighbor_face_list::iterator neighbor_face_list_iterator;
|
typedef neighbor_face_list::iterator neighbor_face_list_iterator;
|
||||||
typedef neighbor_face_list::const_iterator const_neighbor_face_list_iterator;
|
typedef neighbor_face_list::const_iterator const_neighbor_face_list_iterator;
|
||||||
|
|
||||||
|
@ -60,14 +60,14 @@ class TGConstruct : public SGThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
TGConstruct( const TGAreaDefinitions& areas, unsigned int s, SGLockedQueue<SGBucket>& q, SGMutex* l );
|
TGConstruct(const TGAreaDefinitions& areas, unsigned int s, SGLockedQueue<SGBucket>& q, SGMutex* l);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~TGConstruct();
|
~TGConstruct();
|
||||||
|
|
||||||
// New shared edge matching
|
// New shared edge matching
|
||||||
void SaveToIntermediateFiles( int stage );
|
void SaveToIntermediateFiles(int stage);
|
||||||
void LoadFromIntermediateFiles( int stage );
|
void LoadFromIntermediateFiles(int stage);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int load_landcover ();
|
int load_landcover ();
|
||||||
|
@ -83,93 +83,96 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// paths
|
// paths
|
||||||
void set_paths( const std::string& work, const std::string& share, const std::string& match,
|
void set_paths(const std::string& work, const std::string& share, const std::string& match,
|
||||||
const std::string& output, const std::vector<std::string>& load_dirs );
|
const std::string& output, const std::vector<std::string>& load_dirs);
|
||||||
void set_options( bool ignore_lm, double n );
|
void set_options(bool ignore_lm, double n);
|
||||||
|
|
||||||
// TODO : REMOVE
|
// TODO : REMOVE
|
||||||
inline TGNodes* get_nodes() { return &nodes; }
|
inline TGNodes* get_nodes() { return &nodes; }
|
||||||
|
|
||||||
// node list in geodetic coords (with fixed elevation)
|
// node list in geodetic coords (with fixed elevation)
|
||||||
inline void get_geod_nodes( std::vector<SGGeod>& points ) const { nodes.get_geod_nodes( points ); }
|
inline void get_geod_nodes(std::vector<SGGeod>& points) const { nodes.get_geod_nodes(points); }
|
||||||
|
|
||||||
// normal list (for each point) in cart coords (for smooth shading)
|
// normal list (for each point) in cart coords (for smooth shading)
|
||||||
inline void get_point_normals( std::vector<SGVec3f>& normals ) const { nodes.get_normals( normals ); }
|
inline void get_point_normals(std::vector<SGVec3f>& normals) const { nodes.get_normals(normals); }
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
void set_debug( std::string path, std::vector<std::string> area_defs, std::vector<std::string> shape_defs );
|
void set_debug(std::string path, std::vector<std::string> area_defs, std::vector<std::string> shape_defs);
|
||||||
|
|
||||||
|
void CreateMatchedEdgeFiles(std::vector<SGBucket>& bucketList);
|
||||||
|
|
||||||
void CreateMatchedEdgeFiles( std::vector<SGBucket>& bucketList );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void run();
|
virtual void run();
|
||||||
|
|
||||||
// Ocean tile or not
|
// Ocean tile or not
|
||||||
bool IsOceanTile() { return isOcean; }
|
bool IsOceanTile() { return isOcean; }
|
||||||
|
|
||||||
// Load Data
|
// Load Data
|
||||||
void LoadElevationArray( bool add_nodes );
|
void LoadElevationArray(bool add_nodes);
|
||||||
int LoadLandclassPolys( void );
|
int LoadLandclassPolys(void);
|
||||||
bool CheckMatchingNode( SGGeod& node, bool road, bool fixed );
|
bool CheckMatchingNode(SGGeod& node, bool road, bool fixed);
|
||||||
|
|
||||||
SGGeod GetNearestNodeLatitude( const SGGeod& node, const std::vector<SGGeod>& selection );
|
SGGeod GetNearestNodeLatitude(const SGGeod& node, const std::vector<SGGeod>& selection);
|
||||||
SGGeod GetNearestNodeLongitude( const SGGeod& node, const std::vector<SGGeod>& selection );
|
SGGeod GetNearestNodeLongitude(const SGGeod& node, const std::vector<SGGeod>& selection);
|
||||||
|
|
||||||
// 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
|
||||||
void SaveSharedEdgeData( int stage );
|
void writeGeodCollection(std::vector<SGGeod>&, gzFile&);
|
||||||
void LoadSharedEdgeData( int stage );
|
void writeFaceCollection(std::string&&, std::vector<SGGeod>&);
|
||||||
|
void SaveSharedEdgeData(int stage);
|
||||||
|
void LoadSharedEdgeData(int stage);
|
||||||
|
void LoadMatchedEdge(int, int);
|
||||||
void LoadMatchedEdgeFiles();
|
void LoadMatchedEdgeFiles();
|
||||||
|
|
||||||
void LoadNeighboorEdgeDataStage1( SGBucket& b, std::vector<SGGeod>& north, std::vector<SGGeod>& south, std::vector<SGGeod>& east, std::vector<SGGeod>& west );
|
void LoadNeighborEdgeDataStage1(SGBucket& b, std::vector<SGGeod>& north, std::vector<SGGeod>& south, std::vector<SGGeod>& east, std::vector<SGGeod>& west);
|
||||||
void LoadNeighboorMatchDataStage1( SGBucket& b, std::vector<SGGeod>& north, std::vector<SGGeod>& south, std::vector<SGGeod>& east, std::vector<SGGeod>& west );
|
void LoadNeighborMatchDataStage1(SGBucket& b, std::vector<SGGeod>& north, std::vector<SGGeod>& south, std::vector<SGGeod>& east, std::vector<SGGeod>& west);
|
||||||
|
|
||||||
void ReadNeighborFaces( gzFile& fp );
|
void ReadNeighborFaces(gzFile& fp);
|
||||||
void WriteNeighborFaces( gzFile& fp, const SGGeod& pt ) const;
|
void WriteNeighborFaces(gzFile& fp, const SGGeod& pt) const;
|
||||||
TGNeighborFaces* AddNeighborFaces( const SGGeod& node );
|
TGNeighborFaces* AddNeighborFaces(const SGGeod& node);
|
||||||
TGNeighborFaces* FindNeighborFaces( const SGGeod& node );
|
TGNeighborFaces* FindNeighborFaces(const SGGeod& node);
|
||||||
|
|
||||||
// Polygon Cleaning
|
// Polygon Cleaning
|
||||||
void CleanClippedPolys( void );
|
void CleanClippedPolys(void);
|
||||||
void FixTJunctions( void );
|
void FixTJunctions(void);
|
||||||
|
|
||||||
// Tesselation
|
// Tesselation
|
||||||
void TesselatePolys( void );
|
void TesselatePolys(void);
|
||||||
|
|
||||||
// Elevation and Flattening
|
// Elevation and Flattening
|
||||||
void CalcElevations( void );
|
void CalcElevations(void);
|
||||||
void AverageEdgeElevations( void );
|
void AverageEdgeElevations(void);
|
||||||
|
|
||||||
// Normals and texture coords
|
// Normals and texture coords
|
||||||
void LookupNodesPerVertex( void );
|
void LookupNodesPerVertex(void);
|
||||||
void LookupFacesPerNode( void );
|
void LookupFacesPerNode(void);
|
||||||
void CalcFaceNormals( void );
|
void CalcFaceNormals(void);
|
||||||
void CalcPointNormals( void );
|
void CalcPointNormals(void);
|
||||||
void CalcTextureCoordinates( void );
|
void CalcTextureCoordinates(void);
|
||||||
// Helpers
|
// Helpers
|
||||||
SGVec3f calc_normal( double area, const SGVec3d& p1, const SGVec3d& p2, const SGVec3d& p3 ) const;
|
SGVec3f calc_normal(double area, const SGVec3d& p1, const SGVec3d& p2, const SGVec3d& p3) const;
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
void WriteBtgFile( void );
|
void WriteBtgFile(void);
|
||||||
void AddCustomObjects( void );
|
void AddCustomObjects(void);
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
void calc_normals( std::vector<SGGeod>& geod_nodes, std::vector<SGVec3d>& wgs84_nodes, tgPolygon& sp );
|
void calc_normals(std::vector<SGGeod>& geod_nodes, std::vector<SGVec3d>& wgs84_nodes, tgPolygon& sp);
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
void get_debug( void );
|
void get_debug(void);
|
||||||
bool IsDebugShape( unsigned int id );
|
bool IsDebugShape(unsigned int id);
|
||||||
bool IsDebugArea( unsigned int area );
|
bool IsDebugArea(unsigned int area);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TGAreaDefinitions const& area_defs;
|
TGAreaDefinitions const& area_defs;
|
||||||
|
|
||||||
// construct stage to perform
|
// construct stage to perform
|
||||||
SGLockedQueue<SGBucket>& workQueue;
|
SGLockedQueue<SGBucket>& workQueue;
|
||||||
unsigned int total_tiles;
|
unsigned int total_tiles;
|
||||||
|
@ -187,7 +190,7 @@ private:
|
||||||
|
|
||||||
std::vector<std::string> load_dirs;
|
std::vector<std::string> load_dirs;
|
||||||
|
|
||||||
const static double gSnap; // approx 1 mm
|
const static double gSnap; // approx 1 mm
|
||||||
|
|
||||||
// flag indicating whether to ignore the landmass
|
// flag indicating whether to ignore the landmass
|
||||||
bool ignoreLandmass;
|
bool ignoreLandmass;
|
||||||
|
@ -209,11 +212,11 @@ private:
|
||||||
std::vector<unsigned int> debug_shapes;
|
std::vector<unsigned int> debug_shapes;
|
||||||
|
|
||||||
// OGR encode variables for debug:
|
// OGR encode variables for debug:
|
||||||
void* ds_id; // If we are going to build shapefiles
|
void* ds_id; // If we are going to build shapefiles
|
||||||
void* l_id; // datasource and layer IDs
|
void* l_id; // datasource and layer IDs
|
||||||
char ds_name[128];
|
char ds_name[128];
|
||||||
char layer_name[128];
|
char layer_name[128];
|
||||||
char feature_name[128];
|
char feature_name[128];
|
||||||
|
|
||||||
// this bucket
|
// this bucket
|
||||||
SGBucket bucket;
|
SGBucket bucket;
|
||||||
|
@ -234,10 +237,10 @@ private:
|
||||||
unsigned int num_areas;
|
unsigned int num_areas;
|
||||||
|
|
||||||
// Neighbor Faces
|
// Neighbor Faces
|
||||||
neighbor_face_list neighbor_faces;
|
neighbor_face_list neighbor_faces;
|
||||||
|
|
||||||
// file lock
|
// file lock
|
||||||
SGMutex* lock;
|
SGMutex* lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _CONSTRUCT_HXX
|
#endif // _CONSTRUCT_HXX
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
// $Id: construct.cxx,v 1.4 2004-11-19 22:25:49 curt Exp $
|
// $Id: construct.cxx,v 1.4 2004-11-19 22:25:49 curt Exp $
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
|
@ -32,28 +32,29 @@
|
||||||
|
|
||||||
#include "tgconstruct.hxx"
|
#include "tgconstruct.hxx"
|
||||||
|
|
||||||
void TGConstruct::FixTJunctions( void ) {
|
void TGConstruct::FixTJunctions(void)
|
||||||
|
{
|
||||||
int before, after;
|
int before, after;
|
||||||
std::vector<TGNode*> points;
|
std::vector<TGNode*> points;
|
||||||
tgRectangle bb;
|
tgRectangle bb;
|
||||||
|
|
||||||
// traverse each poly, and add intermediate nodes
|
// traverse each poly, and add intermediate nodes
|
||||||
for ( unsigned int i = 0; i < area_defs.size(); ++i ) {
|
for (unsigned int i = 0; i < area_defs.size(); ++i) {
|
||||||
for( unsigned int j = 0; j < polys_clipped.area_size(i); ++j ) {
|
for (unsigned int j = 0; j < polys_clipped.area_size(i); ++j) {
|
||||||
tgPolygon current = polys_clipped.get_poly(i, j);
|
tgPolygon current = polys_clipped.get_poly(i, j);
|
||||||
bb = current.GetBoundingBox();
|
bb = current.GetBoundingBox();
|
||||||
nodes.get_nodes_inside( bb.getMin(), bb.getMax(), points );
|
nodes.get_nodes_inside(bb.getMin(), bb.getMax(), points);
|
||||||
|
|
||||||
before = current.TotalNodes();
|
before = current.TotalNodes();
|
||||||
current = tgPolygon::AddColinearNodes( current, points );
|
current = tgPolygon::AddColinearNodes(current, points);
|
||||||
after = current.TotalNodes();
|
after = current.TotalNodes();
|
||||||
|
|
||||||
if (before != after) {
|
if (before != after) {
|
||||||
SG_LOG( SG_CLIPPER, SG_DEBUG, "Fixed T-Junctions in " << area_defs.get_area_name(i) << ":" << j+1 << " of " << (int)polys_clipped.area_size(i) << " nodes increased from " << before << " to " << after );
|
SG_LOG(SG_CLIPPER, SG_DEBUG, "Fixed T-Junctions in " << area_defs.get_area_name(i) << ":" << j + 1 << " of " << (int)polys_clipped.area_size(i) << " nodes increased from " << before << " to " << after);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save it back */
|
/* Save it back */
|
||||||
polys_clipped.set_poly( i, j, current );
|
polys_clipped.set_poly(i, j, current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,33 +82,34 @@ void TGConstruct::merge_slivers( TGLandclass& clipped, tgcontour_list& sliver_l
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void TGConstruct::CleanClippedPolys() {
|
void TGConstruct::CleanClippedPolys()
|
||||||
|
{
|
||||||
// Clean the polys
|
// Clean the polys
|
||||||
for ( unsigned int area = 0; area < area_defs.size(); area++ ) {
|
for (unsigned int area = 0; area < area_defs.size(); area++) {
|
||||||
for( unsigned int p = 0; p < polys_clipped.area_size(area); p++ ) {
|
for (unsigned int p = 0; p < polys_clipped.area_size(area); p++) {
|
||||||
char layer[32];
|
char layer[32];
|
||||||
|
|
||||||
tgPolygon poly = polys_clipped.get_poly(area, p);
|
tgPolygon poly = polys_clipped.get_poly(area, p);
|
||||||
|
|
||||||
// step 1 : snap
|
// step 1 : snap
|
||||||
poly = tgPolygon::Snap(poly, gSnap);
|
poly = tgPolygon::Snap(poly, gSnap);
|
||||||
if ( IsDebugShape( poly.GetId() ) ) {
|
if (IsDebugShape(poly.GetId())) {
|
||||||
sprintf(layer, "snapped_%d", poly.GetId() );
|
sprintf(layer, "snapped_%d", poly.GetId());
|
||||||
tgShapefile::FromPolygon( poly, ds_name, layer, "poly" );
|
tgShapefile::FromPolygon(poly, ds_name, layer, "poly");
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 2 : remove_dups
|
// step 2 : remove_dups
|
||||||
poly = tgPolygon::RemoveDups( poly );
|
poly = tgPolygon::RemoveDups(poly);
|
||||||
if ( IsDebugShape( poly.GetId() ) ) {
|
if (IsDebugShape(poly.GetId())) {
|
||||||
sprintf(layer, "rem_dups_%d", poly.GetId() );
|
sprintf(layer, "rem_dups_%d", poly.GetId());
|
||||||
tgShapefile::FromPolygon( poly, ds_name, layer, "poly" );
|
tgShapefile::FromPolygon(poly, ds_name, layer, "poly");
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 3 : remove cycles
|
// step 3 : remove cycles
|
||||||
poly = tgPolygon::RemoveCycles( poly );
|
poly = tgPolygon::RemoveCycles(poly);
|
||||||
if ( IsDebugShape( poly.GetId() ) ) {
|
if (IsDebugShape(poly.GetId())) {
|
||||||
sprintf(layer, "rem_cycles_%d", poly.GetId() );
|
sprintf(layer, "rem_cycles_%d", poly.GetId());
|
||||||
tgShapefile::FromPolygon( poly, ds_name, layer, "poly" );
|
tgShapefile::FromPolygon(poly, ds_name, layer, "poly");
|
||||||
}
|
}
|
||||||
|
|
||||||
polys_clipped.set_poly(area, p, poly);
|
polys_clipped.set_poly(area, p, poly);
|
||||||
|
@ -115,28 +117,28 @@ void TGConstruct::CleanClippedPolys() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGConstruct::AverageEdgeElevations( void )
|
void TGConstruct::AverageEdgeElevations(void)
|
||||||
{
|
{
|
||||||
for ( unsigned int i = 0; i < neighbor_faces.size(); i++ ) {
|
for (unsigned int i = 0; i < neighbor_faces.size(); i++) {
|
||||||
TGNeighborFaces faces = neighbor_faces[i];
|
TGNeighborFaces faces = neighbor_faces[i];
|
||||||
double elevation = 0.0;
|
double elevation = 0.0;
|
||||||
unsigned int num_elevations = faces.elevations.size();
|
unsigned int num_elevations = faces.elevations.size();
|
||||||
|
|
||||||
for ( unsigned int j = 0; j < num_elevations; j++ ) {
|
for (unsigned int j = 0; j < num_elevations; j++) {
|
||||||
elevation += faces.elevations[j];
|
elevation += faces.elevations[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
elevation = elevation / num_elevations;
|
elevation = elevation / num_elevations;
|
||||||
|
|
||||||
/* Find this node, and update it's elevation */
|
/* Find this node, and update it's elevation */
|
||||||
int idx = nodes.find( faces.node );
|
int idx = nodes.find(faces.node);
|
||||||
|
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
TGNode const& node = nodes.get_node( idx );
|
TGNode const& node = nodes.get_node(idx);
|
||||||
|
|
||||||
if ( !node.GetFixedPosition() ) {
|
if (!node.GetFixedPosition()) {
|
||||||
// set elevation as the average between all tiles that have it
|
// set elevation as the average between all tiles that have it
|
||||||
nodes.SetElevation( idx, elevation );
|
nodes.SetElevation(idx, elevation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// $Id: construct.cxx,v 1.4 2004-11-19 22:25:49 curt Exp $
|
// $Id: construct.cxx,v 1.4 2004-11-19 22:25:49 curt Exp $
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
void TGConstruct::set_debug( std::string path, std::vector<string> a_defs, std::vector<string> s_defs )
|
void TGConstruct::set_debug(std::string path, std::vector<string> a_defs, std::vector<string> s_defs)
|
||||||
{
|
{
|
||||||
debug_path = path;
|
debug_path = path;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ void TGConstruct::set_debug( std::string path, std::vector<string> a_defs, std::
|
||||||
debug_shape_defs = s_defs;
|
debug_shape_defs = s_defs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGConstruct::get_debug( void )
|
void TGConstruct::get_debug(void)
|
||||||
{
|
{
|
||||||
// clear out any previous entries
|
// clear out any previous entries
|
||||||
debug_areas.clear();
|
debug_areas.clear();
|
||||||
|
@ -48,20 +48,19 @@ void TGConstruct::get_debug( void )
|
||||||
|
|
||||||
/* Find any ids for our tile */
|
/* Find any ids for our tile */
|
||||||
for (unsigned int i = 0; i < debug_area_defs.size(); ++i) {
|
for (unsigned int i = 0; i < debug_area_defs.size(); ++i) {
|
||||||
string dsd = debug_area_defs[i];
|
string dsd = debug_area_defs[i];
|
||||||
size_t d_pos = dsd.find(":");
|
size_t d_pos = dsd.find(":");
|
||||||
string tile = dsd.substr(0, d_pos);
|
string tile = dsd.substr(0, d_pos);
|
||||||
|
|
||||||
if ( tile == bucket.gen_index_str() ) {
|
if (tile == bucket.gen_index_str()) {
|
||||||
dsd.erase(0, d_pos + 1);
|
dsd.erase(0, d_pos + 1);
|
||||||
|
|
||||||
if ( dsd == "all" ) {
|
if (dsd == "all") {
|
||||||
debug_all = true;
|
debug_all = true;
|
||||||
} else {
|
} else {
|
||||||
std::stringstream ss(dsd);
|
std::stringstream ss(dsd);
|
||||||
int idx;
|
int idx;
|
||||||
while (ss >> idx)
|
while (ss >> idx) {
|
||||||
{
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Adding debug area " << idx);
|
SG_LOG(SG_GENERAL, SG_ALERT, "Adding debug area " << idx);
|
||||||
|
|
||||||
debug_areas.push_back(idx);
|
debug_areas.push_back(idx);
|
||||||
|
@ -74,20 +73,19 @@ void TGConstruct::get_debug( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < debug_shape_defs.size(); ++i) {
|
for (unsigned int i = 0; i < debug_shape_defs.size(); ++i) {
|
||||||
string dsd = debug_shape_defs[i];
|
string dsd = debug_shape_defs[i];
|
||||||
size_t d_pos = dsd.find(":");
|
size_t d_pos = dsd.find(":");
|
||||||
string tile = dsd.substr(0, d_pos);
|
string tile = dsd.substr(0, d_pos);
|
||||||
|
|
||||||
if ( tile == bucket.gen_index_str() ) {
|
if (tile == bucket.gen_index_str()) {
|
||||||
dsd.erase(0, d_pos + 1);
|
dsd.erase(0, d_pos + 1);
|
||||||
|
|
||||||
if ( dsd == "all" ) {
|
if (dsd == "all") {
|
||||||
debug_all = true;
|
debug_all = true;
|
||||||
} else {
|
} else {
|
||||||
std::stringstream ss(dsd);
|
std::stringstream ss(dsd);
|
||||||
int idx;
|
int idx;
|
||||||
while (ss >> idx)
|
while (ss >> idx) {
|
||||||
{
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Adding debug shape " << idx);
|
SG_LOG(SG_GENERAL, SG_ALERT, "Adding debug shape " << idx);
|
||||||
|
|
||||||
debug_shapes.push_back(idx);
|
debug_shapes.push_back(idx);
|
||||||
|
@ -100,16 +98,16 @@ void TGConstruct::get_debug( void )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TGConstruct::IsDebugShape( unsigned int id )
|
bool TGConstruct::IsDebugShape(unsigned int id)
|
||||||
{
|
{
|
||||||
bool is_debug = false;
|
bool is_debug = false;
|
||||||
|
|
||||||
/* Check global flag */
|
/* Check global flag */
|
||||||
if ( debug_all ) {
|
if (debug_all) {
|
||||||
is_debug = true;
|
is_debug = true;
|
||||||
} else {
|
} else {
|
||||||
for (unsigned int i=0; i<debug_shapes.size(); i++) {
|
for (unsigned int i = 0; i < debug_shapes.size(); i++) {
|
||||||
if ( debug_shapes[i] == id ) {
|
if (debug_shapes[i] == id) {
|
||||||
is_debug = true;
|
is_debug = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -119,16 +117,16 @@ bool TGConstruct::IsDebugShape( unsigned int id )
|
||||||
return is_debug;
|
return is_debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TGConstruct::IsDebugArea( unsigned int area )
|
bool TGConstruct::IsDebugArea(unsigned int area)
|
||||||
{
|
{
|
||||||
bool is_debug = false;
|
bool is_debug = false;
|
||||||
|
|
||||||
/* Check global flag */
|
/* Check global flag */
|
||||||
if ( debug_all ) {
|
if (debug_all) {
|
||||||
is_debug = true;
|
is_debug = true;
|
||||||
} else {
|
} else {
|
||||||
for (unsigned int i=0; i<debug_areas.size(); i++) {
|
for (unsigned int i = 0; i < debug_areas.size(); i++) {
|
||||||
if ( debug_areas[i] == area ) {
|
if (debug_areas[i] == area) {
|
||||||
is_debug = true;
|
is_debug = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// $Id: construct.cxx,v 1.4 2004-11-19 22:25:49 curt Exp $
|
// $Id: construct.cxx,v 1.4 2004-11-19 22:25:49 curt Exp $
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
@ -32,33 +32,34 @@ using std::string;
|
||||||
|
|
||||||
// Load elevation data from an Array file (a regular grid of elevation data)
|
// Load elevation data from an Array file (a regular grid of elevation data)
|
||||||
// and return list of fitted nodes.
|
// and return list of fitted nodes.
|
||||||
void TGConstruct::LoadElevationArray( bool add_nodes ) {
|
void TGConstruct::LoadElevationArray(bool add_nodes)
|
||||||
|
{
|
||||||
string base = bucket.gen_base_path();
|
string base = bucket.gen_base_path();
|
||||||
|
|
||||||
for ( int i = 0; i < (int)load_dirs.size(); ++i ) {
|
for (int i = 0; i < (int)load_dirs.size(); ++i) {
|
||||||
string array_path = work_base + "/" + load_dirs[i] + "/" + base + "/" + bucket.gen_index_str();
|
string array_path = work_base + "/" + load_dirs[i] + "/" + base + "/" + bucket.gen_index_str();
|
||||||
|
|
||||||
if ( array.open(array_path) ) {
|
if (array.open(array_path)) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Failed to open Array file " << array_path);
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Failed to open Array file " << array_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
array.parse( bucket );
|
array.parse(bucket);
|
||||||
array.remove_voids( );
|
array.remove_voids();
|
||||||
|
|
||||||
if ( add_nodes ) {
|
if (add_nodes) {
|
||||||
std::vector<SGGeod> const& corner_list = array.get_corner_list();
|
std::vector<SGGeod> const& corner_list = array.get_corner_list();
|
||||||
for (unsigned int i = 0; i < corner_list.size(); ++i) {
|
for (unsigned int i = 0; i < corner_list.size(); ++i) {
|
||||||
nodes.unique_add( corner_list[i] );
|
nodes.unique_add(corner_list[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SGGeod> const& fit_list = array.get_fitted_list();
|
std::vector<SGGeod> const& fit_list = array.get_fitted_list();
|
||||||
for (unsigned int i = 0; i < fit_list.size(); ++i) {
|
for (unsigned int i = 0; i < fit_list.size(); ++i) {
|
||||||
SGGeod node = fit_list[i];
|
SGGeod node = fit_list[i];
|
||||||
if ( CheckMatchingNode( node, false, false ) ) {
|
if (CheckMatchingNode(node, false, false)) {
|
||||||
nodes.unique_add( node );
|
nodes.unique_add(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,19 +68,19 @@ void TGConstruct::LoadElevationArray( bool add_nodes ) {
|
||||||
// fix the elevations of the geodetic nodes
|
// fix the elevations of the geodetic nodes
|
||||||
// This should be done in the nodes class itself, except for the need for the triangle type
|
// This should be done in the nodes class itself, except for the need for the triangle type
|
||||||
// hopefully, this will get better when we have the area lookup via superpoly...
|
// hopefully, this will get better when we have the area lookup via superpoly...
|
||||||
void TGConstruct::CalcElevations( void )
|
void TGConstruct::CalcElevations(void)
|
||||||
{
|
{
|
||||||
std::vector<SGGeod> raw_nodes;
|
std::vector<SGGeod> raw_nodes;
|
||||||
double e1, e2, e3, min;
|
double e1, e2, e3, min;
|
||||||
int n1, n2, n3;
|
int n1, n2, n3;
|
||||||
|
|
||||||
for (int i = 0; i < (int)nodes.size(); ++i) {
|
for (int i = 0; i < (int)nodes.size(); ++i) {
|
||||||
TGNode const& node = nodes.get_node( i );
|
TGNode const& node = nodes.get_node(i);
|
||||||
SGGeod pos = node.GetPosition();
|
SGGeod pos = node.GetPosition();
|
||||||
|
|
||||||
if ( !node.GetFixedPosition() ) {
|
if (!node.GetFixedPosition()) {
|
||||||
// set elevation as interpolated point from DEM data.
|
// set elevation as interpolated point from DEM data.
|
||||||
nodes.SetElevation( i, array.altitude_from_grid(pos.getLongitudeDeg() * 3600.0, pos.getLatitudeDeg() * 3600.0) );
|
nodes.SetElevation(i, array.altitude_from_grid(pos.getLongitudeDeg() * 3600.0, pos.getLatitudeDeg() * 3600.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,137 +88,149 @@ void TGConstruct::CalcElevations( void )
|
||||||
|
|
||||||
// now flatten some stuff
|
// now flatten some stuff
|
||||||
for (unsigned int area = 0; area < area_defs.size(); area++) {
|
for (unsigned int area = 0; area < area_defs.size(); area++) {
|
||||||
if ( area_defs.is_lake_area(area) ) {
|
if (area_defs.is_lake_area(area)) {
|
||||||
for (int p = 0; p < (int)polys_clipped.area_size(area); ++p ) {
|
for (int p = 0; p < (int)polys_clipped.area_size(area); ++p) {
|
||||||
SG_LOG( SG_CLIPPER, SG_DEBUG, "Flattening " << area_defs.get_area_name(area) << ":" << p+1 << " of " << polys_clipped.area_size(area) );
|
SG_LOG(SG_CLIPPER, SG_DEBUG, "Flattening " << area_defs.get_area_name(area) << ":" << p + 1 << " of " << polys_clipped.area_size(area));
|
||||||
tgPolygon poly = polys_clipped.get_poly( area, p );
|
tgPolygon poly = polys_clipped.get_poly(area, p);
|
||||||
|
|
||||||
for (unsigned int tri=0; tri < poly.Triangles(); tri++) {
|
for (unsigned int tri = 0; tri < poly.Triangles(); tri++) {
|
||||||
n1 = poly.GetTriIdx( tri, 0 );
|
n1 = poly.GetTriIdx(tri, 0);
|
||||||
e1 = nodes.get_node(n1).GetPosition().getElevationM();
|
e1 = nodes.get_node(n1).GetPosition().getElevationM();
|
||||||
n2 = poly.GetTriIdx( tri, 1 );
|
n2 = poly.GetTriIdx(tri, 1);
|
||||||
e2 = nodes.get_node(n2).GetPosition().getElevationM();
|
e2 = nodes.get_node(n2).GetPosition().getElevationM();
|
||||||
n3 = poly.GetTriIdx( tri, 2 );
|
n3 = poly.GetTriIdx(tri, 2);
|
||||||
e3 = nodes.get_node(n3).GetPosition().getElevationM();
|
e3 = nodes.get_node(n3).GetPosition().getElevationM();
|
||||||
|
|
||||||
min = e1;
|
min = e1;
|
||||||
if ( e2 < min ) { min = e2; }
|
if (e2 < min) { min = e2; }
|
||||||
if ( e3 < min ) { min = e3; }
|
if (e3 < min) { min = e3; }
|
||||||
|
|
||||||
nodes.SetElevation( n1, min );
|
nodes.SetElevation(n1, min);
|
||||||
nodes.SetElevation( n2, min );
|
nodes.SetElevation(n2, min);
|
||||||
nodes.SetElevation( n3, min );
|
nodes.SetElevation(n3, min);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( area_defs.is_stream_area(area) ) {
|
if (area_defs.is_stream_area(area)) {
|
||||||
for (unsigned int p = 0; p < polys_clipped.area_size(area); ++p ) {
|
for (unsigned int p = 0; p < polys_clipped.area_size(area); ++p) {
|
||||||
SG_LOG( SG_CLIPPER, SG_DEBUG, "Flattening " << area_defs.get_area_name(area) << ":" << p+1 << " of " << polys_clipped.area_size(area) );
|
SG_LOG(SG_CLIPPER, SG_DEBUG, "Flattening " << area_defs.get_area_name(area) << ":" << p + 1 << " of " << polys_clipped.area_size(area));
|
||||||
tgPolygon poly = polys_clipped.get_poly( area, p );
|
tgPolygon poly = polys_clipped.get_poly(area, p);
|
||||||
|
|
||||||
for (unsigned int tri=0; tri < poly.Triangles(); tri++) {
|
for (unsigned int tri = 0; tri < poly.Triangles(); tri++) {
|
||||||
n1 = poly.GetTriIdx( tri, 0 );
|
n1 = poly.GetTriIdx(tri, 0);
|
||||||
e1 = nodes.get_node(n1).GetPosition().getElevationM();
|
e1 = nodes.get_node(n1).GetPosition().getElevationM();
|
||||||
n2 = poly.GetTriIdx( tri, 1 );
|
n2 = poly.GetTriIdx(tri, 1);
|
||||||
e2 = nodes.get_node(n2).GetPosition().getElevationM();
|
e2 = nodes.get_node(n2).GetPosition().getElevationM();
|
||||||
n3 = poly.GetTriIdx( tri, 2 );
|
n3 = poly.GetTriIdx(tri, 2);
|
||||||
e3 = nodes.get_node(n3).GetPosition().getElevationM();
|
e3 = nodes.get_node(n3).GetPosition().getElevationM();
|
||||||
|
|
||||||
min = e1;
|
min = e1;
|
||||||
SGGeod src = raw_nodes[n1];
|
SGGeod src = raw_nodes[n1];
|
||||||
|
|
||||||
if ( e2 < min ) { min = e2; src = raw_nodes[n2]; }
|
if (e2 < min) {
|
||||||
if ( e3 < min ) { min = e3; src = raw_nodes[n3]; }
|
min = e2;
|
||||||
|
src = raw_nodes[n2];
|
||||||
|
}
|
||||||
|
if (e3 < min) {
|
||||||
|
min = e3;
|
||||||
|
src = raw_nodes[n3];
|
||||||
|
}
|
||||||
|
|
||||||
double d1, d2, d3;
|
double d1, d2, d3;
|
||||||
if ( min == e1 ) {
|
if (min == e1) {
|
||||||
d1 = 0.0f;
|
d1 = 0.0f;
|
||||||
} else {
|
} else {
|
||||||
d1 = SGGeodesy::distanceM( src, raw_nodes[n1] );
|
d1 = SGGeodesy::distanceM(src, raw_nodes[n1]);
|
||||||
}
|
}
|
||||||
if ( min == e2 ) {
|
if (min == e2) {
|
||||||
d2 = 0.0f;
|
d2 = 0.0f;
|
||||||
} else {
|
} else {
|
||||||
d2 = SGGeodesy::distanceM( src, raw_nodes[n2] );
|
d2 = SGGeodesy::distanceM(src, raw_nodes[n2]);
|
||||||
}
|
}
|
||||||
if ( min == e3 ) {
|
if (min == e3) {
|
||||||
d3 = 0.0f;
|
d3 = 0.0f;
|
||||||
} else {
|
} else {
|
||||||
d3 = SGGeodesy::distanceM( src, raw_nodes[n3] );
|
d3 = SGGeodesy::distanceM(src, raw_nodes[n3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
double max1 = d1 * 0.20 + min;
|
double max1 = d1 * 0.20 + min;
|
||||||
double max2 = d2 * 0.20 + min;
|
double max2 = d2 * 0.20 + min;
|
||||||
double max3 = d3 * 0.20 + min;
|
double max3 = d3 * 0.20 + min;
|
||||||
|
|
||||||
if ( max1 < e1 ) { nodes.SetElevation( n1, max1 ); }
|
if (max1 < e1) { nodes.SetElevation(n1, max1); }
|
||||||
if ( max2 < e2 ) { nodes.SetElevation( n2, max2 ); }
|
if (max2 < e2) { nodes.SetElevation(n2, max2); }
|
||||||
if ( max3 < e3 ) { nodes.SetElevation( n3, max3 ); }
|
if (max3 < e3) { nodes.SetElevation(n3, max3); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( area_defs.is_road_area(area) ) {
|
if (area_defs.is_road_area(area)) {
|
||||||
for (int p = 0; p < (int)polys_clipped.area_size(area); ++p ) {
|
for (int p = 0; p < (int)polys_clipped.area_size(area); ++p) {
|
||||||
SG_LOG( SG_CLIPPER, SG_DEBUG, "Flattening " << area_defs.get_area_name(area) << ":" << p+1 << " of " << polys_clipped.area_size(area) );
|
SG_LOG(SG_CLIPPER, SG_DEBUG, "Flattening " << area_defs.get_area_name(area) << ":" << p + 1 << " of " << polys_clipped.area_size(area));
|
||||||
tgPolygon poly = polys_clipped.get_poly( area, p );
|
tgPolygon poly = polys_clipped.get_poly(area, p);
|
||||||
|
|
||||||
for (unsigned int tri=0; tri < poly.Triangles(); tri++) {
|
for (unsigned int tri = 0; tri < poly.Triangles(); tri++) {
|
||||||
n1 = poly.GetTriIdx( tri, 0 );
|
n1 = poly.GetTriIdx(tri, 0);
|
||||||
e1 = nodes.get_node(n1).GetPosition().getElevationM();
|
e1 = nodes.get_node(n1).GetPosition().getElevationM();
|
||||||
n2 = poly.GetTriIdx( tri, 1 );
|
n2 = poly.GetTriIdx(tri, 1);
|
||||||
e2 = nodes.get_node(n2).GetPosition().getElevationM();
|
e2 = nodes.get_node(n2).GetPosition().getElevationM();
|
||||||
n3 = poly.GetTriIdx( tri, 2 );
|
n3 = poly.GetTriIdx(tri, 2);
|
||||||
e3 = nodes.get_node(n3).GetPosition().getElevationM();
|
e3 = nodes.get_node(n3).GetPosition().getElevationM();
|
||||||
|
|
||||||
min = e1;
|
min = e1;
|
||||||
SGGeod src = raw_nodes[n1];
|
SGGeod src = raw_nodes[n1];
|
||||||
|
|
||||||
if ( e2 < min ) { min = e2; src = raw_nodes[n2]; }
|
if (e2 < min) {
|
||||||
if ( e3 < min ) { min = e3; src = raw_nodes[n3]; }
|
min = e2;
|
||||||
|
src = raw_nodes[n2];
|
||||||
|
}
|
||||||
|
if (e3 < min) {
|
||||||
|
min = e3;
|
||||||
|
src = raw_nodes[n3];
|
||||||
|
}
|
||||||
|
|
||||||
double d1, d2, d3;
|
double d1, d2, d3;
|
||||||
if ( min == e1 ) {
|
if (min == e1) {
|
||||||
d1 = 0.0f;
|
d1 = 0.0f;
|
||||||
} else {
|
} else {
|
||||||
d1 = SGGeodesy::distanceM( src, raw_nodes[n1] );
|
d1 = SGGeodesy::distanceM(src, raw_nodes[n1]);
|
||||||
}
|
}
|
||||||
if ( min == e2 ) {
|
if (min == e2) {
|
||||||
d2 = 0.0f;
|
d2 = 0.0f;
|
||||||
} else {
|
} else {
|
||||||
d2 = SGGeodesy::distanceM( src, raw_nodes[n2] );
|
d2 = SGGeodesy::distanceM(src, raw_nodes[n2]);
|
||||||
}
|
}
|
||||||
if ( min == e3 ) {
|
if (min == e3) {
|
||||||
d3 = 0.0f;
|
d3 = 0.0f;
|
||||||
} else {
|
} else {
|
||||||
d3 = SGGeodesy::distanceM( src, raw_nodes[n3] );
|
d3 = SGGeodesy::distanceM(src, raw_nodes[n3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
double max1 = d1 * 0.30 + min;
|
double max1 = d1 * 0.30 + min;
|
||||||
double max2 = d2 * 0.30 + min;
|
double max2 = d2 * 0.30 + min;
|
||||||
double max3 = d3 * 0.30 + min;
|
double max3 = d3 * 0.30 + min;
|
||||||
|
|
||||||
if ( max1 < e1 ) { nodes.SetElevation( n1, max1 ); }
|
if (max1 < e1) { nodes.SetElevation(n1, max1); }
|
||||||
if ( max2 < e2 ) { nodes.SetElevation( n2, max2 ); }
|
if (max2 < e2) { nodes.SetElevation(n2, max2); }
|
||||||
if ( max3 < e3 ) { nodes.SetElevation( n3, max3 ); }
|
if (max3 < e3) { nodes.SetElevation(n3, max3); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( area_defs.is_ocean_area(area) ) {
|
if (area_defs.is_ocean_area(area)) {
|
||||||
for (int p = 0; p < (int)polys_clipped.area_size(area); ++p ) {
|
for (int p = 0; p < (int)polys_clipped.area_size(area); ++p) {
|
||||||
SG_LOG( SG_CLIPPER, SG_DEBUG, "Flattening " << area_defs.get_area_name(area) << ":" << p+1 << " of " << polys_clipped.area_size(area) );
|
SG_LOG(SG_CLIPPER, SG_DEBUG, "Flattening " << area_defs.get_area_name(area) << ":" << p + 1 << " of " << polys_clipped.area_size(area));
|
||||||
tgPolygon poly = polys_clipped.get_poly( area, p );
|
tgPolygon poly = polys_clipped.get_poly(area, p);
|
||||||
|
|
||||||
for (unsigned int tri=0; tri < poly.Triangles(); tri++) {
|
for (unsigned int tri = 0; tri < poly.Triangles(); tri++) {
|
||||||
n1 = poly.GetTriIdx( tri, 0 );
|
n1 = poly.GetTriIdx(tri, 0);
|
||||||
n2 = poly.GetTriIdx( tri, 1 );
|
n2 = poly.GetTriIdx(tri, 1);
|
||||||
n3 = poly.GetTriIdx( tri, 2 );
|
n3 = poly.GetTriIdx(tri, 2);
|
||||||
|
|
||||||
nodes.SetElevation( n1, 0.0 );
|
nodes.SetElevation(n1, 0.0);
|
||||||
nodes.SetElevation( n2, 0.0 );
|
nodes.SetElevation(n2, 0.0);
|
||||||
nodes.SetElevation( n3, 0.0 );
|
nodes.SetElevation(n3, 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
// $Id: construct.cxx,v 1.4 2004-11-19 22:25:49 curt Exp $
|
// $Id: construct.cxx,v 1.4 2004-11-19 22:25:49 curt Exp $
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
@ -32,20 +32,20 @@
|
||||||
// This function populates the Superpoly tri_idx polygon.
|
// This function populates the Superpoly tri_idx polygon.
|
||||||
// This polygon is a mirror of tris, except the verticies are
|
// This polygon is a mirror of tris, except the verticies are
|
||||||
// indexes into the node array (cast as unsigned long)
|
// indexes into the node array (cast as unsigned long)
|
||||||
void TGConstruct::LookupNodesPerVertex( void )
|
void TGConstruct::LookupNodesPerVertex(void)
|
||||||
{
|
{
|
||||||
// for each node, traverse all the triangles - and create face lists
|
// for each node, traverse all the triangles - and create face lists
|
||||||
for ( unsigned int area = 0; area < area_defs.size(); area++ ) {
|
for (unsigned int area = 0; area < area_defs.size(); area++) {
|
||||||
for( unsigned int p = 0; p < polys_clipped.area_size(area); p++ ) {
|
for (unsigned int p = 0; p < polys_clipped.area_size(area); p++) {
|
||||||
tgPolygon& poly = polys_clipped.get_poly( area, p );
|
tgPolygon& poly = polys_clipped.get_poly(area, p);
|
||||||
|
|
||||||
for (unsigned int tri=0; tri < poly.Triangles(); tri++) {
|
for (unsigned int tri = 0; tri < poly.Triangles(); tri++) {
|
||||||
for (unsigned int vertex = 0; vertex < 3; vertex++) {
|
for (unsigned int vertex = 0; vertex < 3; vertex++) {
|
||||||
int idx = nodes.find( poly.GetTriNode( tri, vertex ) );
|
int idx = nodes.find(poly.GetTriNode(tri, vertex));
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
poly.SetTriIdx( tri, vertex, idx );
|
poly.SetTriIdx(tri, vertex, idx);
|
||||||
} else {
|
} else {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "didn't find vertex! " << poly.GetTriNode( tri, vertex ) );
|
SG_LOG(SG_GENERAL, SG_ALERT, "didn't find vertex! " << poly.GetTriNode(tri, vertex));
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,17 +54,17 @@ void TGConstruct::LookupNodesPerVertex( void )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGConstruct::LookupFacesPerNode( void )
|
void TGConstruct::LookupFacesPerNode(void)
|
||||||
{
|
{
|
||||||
// Add each face that includes a node to the node's face list
|
// Add each face that includes a node to the node's face list
|
||||||
for ( unsigned int area = 0; area < area_defs.size(); area++ ) {
|
for (unsigned int area = 0; area < area_defs.size(); area++) {
|
||||||
for( unsigned int p = 0; p < polys_clipped.area_size(area); p++ ) {
|
for (unsigned int p = 0; p < polys_clipped.area_size(area); p++) {
|
||||||
tgPolygon const& poly = polys_clipped.get_poly(area, p );
|
tgPolygon const& poly = polys_clipped.get_poly(area, p);
|
||||||
|
|
||||||
for (unsigned int tri=0; tri < poly.Triangles(); tri++) {
|
for (unsigned int tri = 0; tri < poly.Triangles(); tri++) {
|
||||||
for (int v = 0; v < 3; v++) {
|
for (int v = 0; v < 3; v++) {
|
||||||
int i = poly.GetTriIdx( tri, v );
|
int i = poly.GetTriIdx(tri, v);
|
||||||
nodes.AddFace( i, area, p, tri );
|
nodes.AddFace(i, area, p, tri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,15 @@
|
||||||
// $Id: construct.cxx,v 1.4 2004-11-19 22:25:49 curt Exp $
|
// $Id: construct.cxx,v 1.4 2004-11-19 22:25:49 curt Exp $
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
|
||||||
#include "tgconstruct.hxx"
|
#include "tgconstruct.hxx"
|
||||||
|
|
||||||
SGVec3f TGConstruct::calc_normal( double area, const SGVec3d& p1, const SGVec3d& p2, const SGVec3d& p3 ) const {
|
SGVec3f TGConstruct::calc_normal(double area, const SGVec3d& p1, const SGVec3d& p2, const SGVec3d& p3) const
|
||||||
|
{
|
||||||
SGVec3f v1, v2;
|
SGVec3f v1, v2;
|
||||||
SGVec3f normal;
|
SGVec3f normal;
|
||||||
|
|
||||||
|
@ -41,17 +42,17 @@ SGVec3f TGConstruct::calc_normal( double area, const SGVec3d& p1, const SGVec3d&
|
||||||
|
|
||||||
bool degenerate = false;
|
bool degenerate = false;
|
||||||
const double area_eps = 1.0e-12;
|
const double area_eps = 1.0e-12;
|
||||||
if ( area < area_eps ) {
|
if (area < area_eps) {
|
||||||
degenerate = true;
|
degenerate = true;
|
||||||
} else if ( fabs(p1.x() - p2.x()) < SG_EPSILON && fabs(p1.x() - p3.x()) < SG_EPSILON ) {
|
} else if (fabs(p1.x() - p2.x()) < SG_EPSILON && fabs(p1.x() - p3.x()) < SG_EPSILON) {
|
||||||
degenerate = true;
|
degenerate = true;
|
||||||
} else if ( fabs(p1.y() - p2.y()) < SG_EPSILON && fabs(p1.y() - p3.y()) < SG_EPSILON ) {
|
} else if (fabs(p1.y() - p2.y()) < SG_EPSILON && fabs(p1.y() - p3.y()) < SG_EPSILON) {
|
||||||
degenerate = true;
|
degenerate = true;
|
||||||
} else if ( fabs(p1.z() - p2.z()) < SG_EPSILON && fabs(p1.z() - p3.z()) < SG_EPSILON ) {
|
} else if (fabs(p1.z() - p2.z()) < SG_EPSILON && fabs(p1.z() - p3.z()) < SG_EPSILON) {
|
||||||
degenerate = true;
|
degenerate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( degenerate ) {
|
if (degenerate) {
|
||||||
normal = normalize(SGVec3f(p1.x(), p1.y(), p1.z()));
|
normal = normalize(SGVec3f(p1.x(), p1.y(), p1.z()));
|
||||||
} else {
|
} else {
|
||||||
v1[0] = p2.x() - p1.x();
|
v1[0] = p2.x() - p1.x();
|
||||||
|
@ -66,90 +67,91 @@ SGVec3f TGConstruct::calc_normal( double area, const SGVec3d& p1, const SGVec3d&
|
||||||
return normal;
|
return normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGConstruct::calc_normals( std::vector<SGGeod>& geod_nodes, std::vector<SGVec3d>& wgs84_nodes, tgPolygon& poly ) {
|
void TGConstruct::calc_normals(std::vector<SGGeod>& geod_nodes, std::vector<SGVec3d>& wgs84_nodes, tgPolygon& poly)
|
||||||
|
{
|
||||||
// for each face in the superpoly, calculate a face normal
|
// for each face in the superpoly, calculate a face normal
|
||||||
SGVec3f normal;
|
SGVec3f normal;
|
||||||
|
|
||||||
for (unsigned int tri = 0; tri < poly.Triangles(); tri++) {
|
for (unsigned int tri = 0; tri < poly.Triangles(); tri++) {
|
||||||
SGGeod g1 = geod_nodes[ poly.GetTriIdx( tri, 0 ) ];
|
SGGeod g1 = geod_nodes[poly.GetTriIdx(tri, 0)];
|
||||||
SGGeod g2 = geod_nodes[ poly.GetTriIdx( tri, 1 ) ];
|
SGGeod g2 = geod_nodes[poly.GetTriIdx(tri, 1)];
|
||||||
SGGeod g3 = geod_nodes[ poly.GetTriIdx( tri, 2 ) ];
|
SGGeod g3 = geod_nodes[poly.GetTriIdx(tri, 2)];
|
||||||
|
|
||||||
SGVec3d v1 = wgs84_nodes[ poly.GetTriIdx( tri, 0 ) ];
|
SGVec3d v1 = wgs84_nodes[poly.GetTriIdx(tri, 0)];
|
||||||
SGVec3d v2 = wgs84_nodes[ poly.GetTriIdx( tri, 1 ) ];
|
SGVec3d v2 = wgs84_nodes[poly.GetTriIdx(tri, 1)];
|
||||||
SGVec3d v3 = wgs84_nodes[ poly.GetTriIdx( tri, 2 ) ];
|
SGVec3d v3 = wgs84_nodes[poly.GetTriIdx(tri, 2)];
|
||||||
|
|
||||||
double area = tgTriangle::area( g1, g2, g3 );
|
double area = tgTriangle::area(g1, g2, g3);
|
||||||
normal = calc_normal( area, v1, v2, v3 );
|
normal = calc_normal(area, v1, v2, v3);
|
||||||
|
|
||||||
poly.SetTriFaceArea( tri, area );
|
poly.SetTriFaceArea(tri, area);
|
||||||
poly.SetTriFaceNormal( tri, normal );
|
poly.SetTriFaceNormal(tri, normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGConstruct::CalcFaceNormals( void )
|
void TGConstruct::CalcFaceNormals(void)
|
||||||
{
|
{
|
||||||
// traverse the superpols, and calc normals for each tri within
|
// traverse the superpols, and calc normals for each tri within
|
||||||
std::vector<SGVec3d> wgs84_nodes;
|
std::vector<SGVec3d> wgs84_nodes;
|
||||||
nodes.get_wgs84_nodes( wgs84_nodes );
|
nodes.get_wgs84_nodes(wgs84_nodes);
|
||||||
|
|
||||||
std::vector<SGGeod> geod_nodes;
|
std::vector<SGGeod> geod_nodes;
|
||||||
nodes.get_geod_nodes( geod_nodes );
|
nodes.get_geod_nodes(geod_nodes);
|
||||||
|
|
||||||
for (unsigned int area = 0; area < area_defs.size(); area++) {
|
for (unsigned int area = 0; area < area_defs.size(); area++) {
|
||||||
for (unsigned int p = 0; p < polys_clipped.area_size(area); p++ ) {
|
for (unsigned int p = 0; p < polys_clipped.area_size(area); p++) {
|
||||||
SG_LOG( SG_CLIPPER, SG_DEBUG, "Calculating face normals for " << area_defs.get_area_name(area) << ":" << p+1 << " of " << polys_in.area_size(area) );
|
SG_LOG(SG_CLIPPER, SG_DEBUG, "Calculating face normals for " << area_defs.get_area_name(area) << ":" << p + 1 << " of " << polys_in.area_size(area));
|
||||||
calc_normals( geod_nodes, wgs84_nodes, polys_clipped.get_poly( area, p ) );
|
calc_normals(geod_nodes, wgs84_nodes, polys_clipped.get_poly(area, p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGConstruct::CalcPointNormals( void )
|
void TGConstruct::CalcPointNormals(void)
|
||||||
{
|
{
|
||||||
// traverse triangle structure building the face normal table
|
// traverse triangle structure building the face normal table
|
||||||
SGVec3f normal;
|
SGVec3f normal;
|
||||||
double face_area;
|
double face_area;
|
||||||
|
|
||||||
std::vector<SGVec3d> wgs84_nodes;
|
std::vector<SGVec3d> wgs84_nodes;
|
||||||
nodes.get_wgs84_nodes( wgs84_nodes );
|
nodes.get_wgs84_nodes(wgs84_nodes);
|
||||||
|
|
||||||
unsigned int one_percent = nodes.size() / 100;
|
unsigned int one_percent = nodes.size() / 100;
|
||||||
unsigned int cur_percent = 1;
|
unsigned int cur_percent = 1;
|
||||||
|
|
||||||
for ( unsigned int i = 0; i<nodes.size(); i++ ) {
|
for (unsigned int i = 0; i < nodes.size(); i++) {
|
||||||
TGNode const& node = nodes.get_node( i );
|
TGNode const& node = nodes.get_node(i);
|
||||||
TGFaceList const& faces = node.GetFaces();
|
TGFaceList const& faces = node.GetFaces();
|
||||||
TGNeighborFaces const* neighbor_faces = NULL;
|
TGNeighborFaces const* neighbor_faces = NULL;
|
||||||
double total_area = 0.0;
|
double total_area = 0.0;
|
||||||
|
|
||||||
SGVec3f average( 0.0, 0.0, 0.0 );
|
SGVec3f average(0.0, 0.0, 0.0);
|
||||||
|
|
||||||
if ( i == one_percent ) {
|
if (i == one_percent) {
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Calculating point normals: " << cur_percent << "%" );
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Calculating point normals: " << cur_percent << "%");
|
||||||
one_percent += nodes.size() / 100;
|
one_percent += nodes.size() / 100;
|
||||||
cur_percent += 1;
|
cur_percent += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for each triangle that shares this node
|
// for each triangle that shares this node
|
||||||
for ( unsigned int j = 0; j < faces.size(); ++j ) {
|
for (unsigned int j = 0; j < faces.size(); ++j) {
|
||||||
unsigned int at = faces[j].area;
|
unsigned int at = faces[j].area;
|
||||||
unsigned int poly = faces[j].poly;
|
unsigned int poly = faces[j].poly;
|
||||||
unsigned int tri = faces[j].tri;
|
unsigned int tri = faces[j].tri;
|
||||||
|
|
||||||
normal = polys_clipped.get_face_normal( at, poly, tri );
|
normal = polys_clipped.get_face_normal(at, poly, tri);
|
||||||
face_area = polys_clipped.get_face_area( at, poly, tri );
|
face_area = polys_clipped.get_face_area(at, poly, tri);
|
||||||
|
|
||||||
normal *= face_area; // scale normal weight relative to area
|
normal *= face_area; // scale normal weight relative to area
|
||||||
total_area += face_area;
|
total_area += face_area;
|
||||||
average += normal;
|
average += normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if this node exists in the shared edge db, add the faces from the neighbooring tile
|
// if this node exists in the shared edge db, add the faces from the neighboring tile
|
||||||
neighbor_faces = FindNeighborFaces( node.GetPosition() );
|
neighbor_faces = FindNeighborFaces(node.GetPosition());
|
||||||
if ( neighbor_faces ) {
|
if (neighbor_faces) {
|
||||||
int num_faces = neighbor_faces->face_areas.size();
|
int num_faces = neighbor_faces->face_areas.size();
|
||||||
for ( int j = 0; j < num_faces; j++ ) {
|
for (int j = 0; j < num_faces; j++) {
|
||||||
normal = neighbor_faces->face_normals[j];
|
normal = neighbor_faces->face_normals[j];
|
||||||
face_area = neighbor_faces->face_areas[j];
|
face_area = neighbor_faces->face_areas[j];
|
||||||
|
|
||||||
normal *= face_area;
|
normal *= face_area;
|
||||||
|
@ -159,6 +161,6 @@ void TGConstruct::CalcPointNormals( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
average /= total_area;
|
average /= total_area;
|
||||||
nodes.SetNormal( i, average );
|
nodes.SetNormal(i, average);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -22,7 +22,7 @@
|
||||||
// $Id: construct.cxx,v 1.4 2004-11-19 22:25:49 curt Exp $
|
// $Id: construct.cxx,v 1.4 2004-11-19 22:25:49 curt Exp $
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
@ -31,56 +31,55 @@
|
||||||
|
|
||||||
#include "tgconstruct.hxx"
|
#include "tgconstruct.hxx"
|
||||||
|
|
||||||
void TGConstruct::TesselatePolys( void )
|
void TGConstruct::TesselatePolys(void)
|
||||||
{
|
{
|
||||||
// tesselate the polygons and prepair them for final output
|
// tesselate the polygons and prepair them for final output
|
||||||
std::vector<SGGeod> poly_extra;
|
std::vector<SGGeod> poly_extra;
|
||||||
SGGeod min, max;
|
SGGeod min, max;
|
||||||
|
|
||||||
for (unsigned int area = 0; area < area_defs.size(); area++) {
|
for (unsigned int area = 0; area < area_defs.size(); area++) {
|
||||||
for (unsigned int p = 0; p < polys_clipped.area_size(area); p++ ) {
|
for (unsigned int p = 0; p < polys_clipped.area_size(area); p++) {
|
||||||
tgPolygon poly = polys_clipped.get_poly(area, p );
|
tgPolygon poly = polys_clipped.get_poly(area, p);
|
||||||
|
|
||||||
if ( IsDebugShape( poly.GetId() ) ) {
|
if (IsDebugShape(poly.GetId())) {
|
||||||
char layer[32];
|
char layer[32];
|
||||||
sprintf(layer, "pretess_%u_%u", area, p );
|
sprintf(layer, "pretess_%u_%u", area, p);
|
||||||
tgShapefile::FromPolygon( poly, ds_name, layer, "poly" );
|
tgShapefile::FromPolygon(poly, ds_name, layer, "poly");
|
||||||
}
|
}
|
||||||
|
|
||||||
tgRectangle rect = poly.GetBoundingBox();
|
tgRectangle rect = poly.GetBoundingBox();
|
||||||
nodes.get_geod_inside( rect.getMin(), rect.getMax(), poly_extra );
|
nodes.get_geod_inside(rect.getMin(), rect.getMax(), poly_extra);
|
||||||
|
|
||||||
SG_LOG( SG_CLIPPER, SG_DEBUG, "Tesselating " << area_defs.get_area_name(area) << "(" << area << "): " <<
|
SG_LOG(SG_CLIPPER, SG_DEBUG, "Tesselating " << area_defs.get_area_name(area) << "(" << area << "): " << p + 1 << " of " << polys_clipped.area_size(area) << ": id = " << poly.GetId());
|
||||||
p+1 << " of " << polys_clipped.area_size(area) << ": id = " << poly.GetId() );
|
|
||||||
|
|
||||||
if ( IsDebugShape( poly.GetId() ) ) {
|
if (IsDebugShape(poly.GetId())) {
|
||||||
SG_LOG( SG_CLIPPER, SG_INFO, poly );
|
SG_LOG(SG_CLIPPER, SG_INFO, poly);
|
||||||
}
|
}
|
||||||
|
|
||||||
poly.Tesselate( poly_extra );
|
poly.Tesselate(poly_extra);
|
||||||
|
|
||||||
polys_clipped.set_poly( area, p, poly );
|
polys_clipped.set_poly(area, p, poly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int area = 0; area < area_defs.size(); area++) {
|
for (unsigned int area = 0; area < area_defs.size(); area++) {
|
||||||
bool isRoad = area_defs.is_road_area( area );
|
bool isRoad = area_defs.is_road_area(area);
|
||||||
for (unsigned int p = 0; p < polys_clipped.area_size(area); p++ ) {
|
for (unsigned int p = 0; p < polys_clipped.area_size(area); p++) {
|
||||||
tgPolygon& poly = polys_clipped.get_poly(area, p );
|
tgPolygon& poly = polys_clipped.get_poly(area, p);
|
||||||
|
|
||||||
// ensure all added nodes are accounted for
|
// ensure all added nodes are accounted for
|
||||||
for (unsigned int k=0; k < poly.Triangles(); k++) {
|
for (unsigned int k = 0; k < poly.Triangles(); k++) {
|
||||||
for (int l = 0; l < 3; l++) {
|
for (int l = 0; l < 3; l++) {
|
||||||
// ensure we have all nodes...
|
// ensure we have all nodes...
|
||||||
SGGeod node = poly.GetTriNode( k, l );
|
SGGeod node = poly.GetTriNode(k, l);
|
||||||
if ( CheckMatchingNode( node, isRoad, false ) ) {
|
if (CheckMatchingNode(node, isRoad, false)) {
|
||||||
nodes.unique_add( node );
|
nodes.unique_add(node);
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_GENERAL, SG_INFO, "after tesselation, we can't add a node - quit");
|
SG_LOG(SG_GENERAL, SG_INFO, "after tesselation, we can't add a node - quit");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
// $Id: construct.hxx,v 1.13 2004-11-19 22:25:49 curt Exp $
|
// $Id: construct.hxx,v 1.13 2004-11-19 22:25:49 curt Exp $
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "tglandclass.hxx"
|
#include "tglandclass.hxx"
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
void TGLandclass::clear(void)
|
void TGLandclass::clear(void)
|
||||||
{
|
{
|
||||||
for (unsigned int i=0; i<polys.size(); i++) {
|
for (unsigned int i = 0; i < polys.size(); i++) {
|
||||||
polys[i].clear();
|
polys[i].clear();
|
||||||
}
|
}
|
||||||
// keep the number of arrays intact - it's constant throughout construct
|
// keep the number of arrays intact - it's constant throughout construct
|
||||||
|
@ -47,32 +47,32 @@ void TGLandclass::LoadFromGzFile(gzFile& fp)
|
||||||
int i, j, num_layers, num_polys;
|
int i, j, num_layers, num_polys;
|
||||||
|
|
||||||
// Load all landclass shapes
|
// Load all landclass shapes
|
||||||
sgReadInt( fp, &num_layers );
|
sgReadInt(fp, &num_layers);
|
||||||
|
|
||||||
polys.clear();
|
polys.clear();
|
||||||
for (i=0; i<num_layers; i++) {
|
for (i = 0; i < num_layers; i++) {
|
||||||
tgpolygon_list lc;
|
tgpolygon_list lc;
|
||||||
sgReadInt( fp, &num_polys );
|
sgReadInt(fp, &num_polys);
|
||||||
|
|
||||||
lc.clear();
|
lc.clear();
|
||||||
for (j=0; j<num_polys; j++) {
|
for (j = 0; j < num_polys; j++) {
|
||||||
tgPolygon poly;
|
tgPolygon poly;
|
||||||
poly.LoadFromGzFile( fp );
|
poly.LoadFromGzFile(fp);
|
||||||
lc.push_back( poly );
|
lc.push_back(poly);
|
||||||
}
|
}
|
||||||
polys.push_back(lc);
|
polys.push_back(lc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator<< ( std::ostream& out, const TGLandclass& lc )
|
std::ostream& operator<<(std::ostream& out, const TGLandclass& lc)
|
||||||
{
|
{
|
||||||
tgPolygon poly;
|
tgPolygon poly;
|
||||||
|
|
||||||
// Save all landclass shapes
|
// Save all landclass shapes
|
||||||
for (unsigned int i=0; i<lc.polys.size(); i++) {
|
for (unsigned int i = 0; i < lc.polys.size(); i++) {
|
||||||
unsigned int count = lc.polys[i].size();
|
unsigned int count = lc.polys[i].size();
|
||||||
out << count << "\n";
|
out << count << "\n";
|
||||||
for (unsigned int j=0; j<count; j++) {
|
for (unsigned int j = 0; j < count; j++) {
|
||||||
out << lc.polys[i][j] << " ";
|
out << lc.polys[i][j] << " ";
|
||||||
}
|
}
|
||||||
out << "\n";
|
out << "\n";
|
||||||
|
@ -88,13 +88,13 @@ void TGLandclass::SaveToGzFile(gzFile& fp)
|
||||||
|
|
||||||
// Save all landclass shapes
|
// Save all landclass shapes
|
||||||
num_layers = polys.size();
|
num_layers = polys.size();
|
||||||
sgWriteInt( fp, num_layers );
|
sgWriteInt(fp, num_layers);
|
||||||
for (i=0; i<num_layers; i++) {
|
for (i = 0; i < num_layers; i++) {
|
||||||
int num_polys = polys[i].size();
|
int num_polys = polys[i].size();
|
||||||
sgWriteInt( fp, num_polys );
|
sgWriteInt(fp, num_polys);
|
||||||
|
|
||||||
for (j=0; j<num_polys; j++) {
|
for (j = 0; j < num_polys; j++) {
|
||||||
polys[i][j].SaveToGzFile( fp );
|
polys[i][j].SaveToGzFile(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue