no more Point2d - use SGVec2d.
This commit is contained in:
parent
531ec93b29
commit
59e2f22050
9 changed files with 92 additions and 159 deletions
|
@ -33,26 +33,13 @@
|
|||
|
||||
#define TG_MAX_AREA_TYPES 128
|
||||
|
||||
//#include <string>
|
||||
//#include <vector>
|
||||
|
||||
//#include <simgear/compiler.h>
|
||||
//#include <simgear/bucket/newbucket.hxx>
|
||||
//#include <simgear/misc/sg_path.hxx>
|
||||
//#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <Array/array.hxx>
|
||||
|
||||
//#include <Polygon/superpoly.hxx>
|
||||
//#include <Polygon/texparams.hxx>
|
||||
#include <Geometry/tg_nodes.hxx>
|
||||
|
||||
#include <landcover/landcover.hxx>
|
||||
|
||||
#include "tglandclass.hxx"
|
||||
//#include "priorities.hxx"
|
||||
|
||||
#define FIND_SLIVERS (0)
|
||||
#define FIND_SLIVERS (1)
|
||||
#define USE_ACCUMULATOR (1)
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ bool TGConstruct::ClipLandclassPolys( void ) {
|
|||
poly_list slivers;
|
||||
int i, j;
|
||||
Point3D p;
|
||||
point2d min, max;
|
||||
SGVec2d min, max;
|
||||
bool debug_area, debug_shape;
|
||||
static int accum_idx = 0;
|
||||
|
||||
|
@ -46,10 +46,10 @@ bool TGConstruct::ClipLandclassPolys( void ) {
|
|||
#endif
|
||||
|
||||
// Get clip bounds
|
||||
min.x = bucket.get_center_lon() - 0.5 * bucket.get_width();
|
||||
min.y = bucket.get_center_lat() - 0.5 * bucket.get_height();
|
||||
max.x = bucket.get_center_lon() + 0.5 * bucket.get_width();
|
||||
max.y = bucket.get_center_lat() + 0.5 * bucket.get_height();
|
||||
min.x() = bucket.get_center_lon() - 0.5 * bucket.get_width();
|
||||
min.y() = bucket.get_center_lat() - 0.5 * bucket.get_height();
|
||||
max.x() = bucket.get_center_lon() + 0.5 * bucket.get_width();
|
||||
max.y() = bucket.get_center_lat() + 0.5 * bucket.get_height();
|
||||
|
||||
#if USE_ACCUMULATOR
|
||||
|
||||
|
@ -62,19 +62,19 @@ bool TGConstruct::ClipLandclassPolys( void ) {
|
|||
// set up clipping tile : and remember to add the nodes!
|
||||
safety_base.erase();
|
||||
|
||||
p = Point3D(min.x, min.y, -9999.0);
|
||||
p = Point3D(min.x(), min.y(), -9999.0);
|
||||
safety_base.add_node( 0, p );
|
||||
nodes.unique_add( p );
|
||||
|
||||
p = Point3D(max.x, min.y, -9999.0);
|
||||
p = Point3D(max.x(), min.y(), -9999.0);
|
||||
safety_base.add_node( 0, p );
|
||||
nodes.unique_add( p );
|
||||
|
||||
p = Point3D(max.x, max.y, -9999.0);
|
||||
p = Point3D(max.x(), max.y(), -9999.0);
|
||||
safety_base.add_node( 0, p );
|
||||
nodes.unique_add( p );
|
||||
|
||||
p = Point3D(min.x, max.y, -9999.0);
|
||||
p = Point3D(min.x(), max.y(), -9999.0);
|
||||
safety_base.add_node( 0, p );
|
||||
nodes.unique_add( p );
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
/**
|
||||
* Simple 2d point class where members can be accessed as x, dist, or lon
|
||||
* and y, theta, or lat
|
||||
*/
|
||||
|
||||
#ifndef TG_POINT2D_HXX
|
||||
#define TG_POINT2D_HXX
|
||||
|
||||
class point2d {
|
||||
public:
|
||||
union {
|
||||
double x;
|
||||
double dist;
|
||||
double lon;
|
||||
};
|
||||
union {
|
||||
double y;
|
||||
double theta;
|
||||
double lat;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // TG_POINT2D_HXX
|
|
@ -40,7 +40,6 @@
|
|||
#include <poly2tri/interface.h>
|
||||
|
||||
#include "polygon.hxx"
|
||||
#include "point2d.hxx"
|
||||
|
||||
using std::endl;
|
||||
using std::cout;
|
||||
|
@ -153,34 +152,24 @@ void TGPolygon::set_elevations( double elev ) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Calculate theta of angle (a, b, c)
|
||||
double tgPolygonCalcAngle(point2d a, point2d b, point2d c) {
|
||||
point2d u, v;
|
||||
double udist, vdist, uv_dot, tmp;
|
||||
double tgPolygonCalcAngle(SGVec2d a, SGVec2d b, SGVec2d c) {
|
||||
SGVec2d u, v;
|
||||
double udist, vdist, uv_dot;
|
||||
|
||||
// u . v = ||u|| * ||v|| * cos(theta)
|
||||
|
||||
u.x = b.x - a.x;
|
||||
u.y = b.y - a.y;
|
||||
udist = sqrt( u.x * u.x + u.y * u.y );
|
||||
// printf("udist = %.6f\n", udist);
|
||||
u = b-a;
|
||||
udist = dist(a,b);
|
||||
|
||||
v.x = b.x - c.x;
|
||||
v.y = b.y - c.y;
|
||||
vdist = sqrt( v.x * v.x + v.y * v.y );
|
||||
// printf("vdist = %.6f\n", vdist);
|
||||
v = b-c;
|
||||
vdist = dist(b,c);
|
||||
|
||||
uv_dot = u.x * v.x + u.y * v.y;
|
||||
// printf("uv_dot = %.6f\n", uv_dot);
|
||||
uv_dot = dot(u,v);
|
||||
|
||||
tmp = uv_dot / (udist * vdist);
|
||||
// printf("tmp = %.6f\n", tmp);
|
||||
|
||||
return acos(tmp);
|
||||
return acos(uv_dot / (udist * vdist));
|
||||
}
|
||||
|
||||
|
||||
// return the perimeter of a contour (assumes simple polygons,
|
||||
// i.e. non-self intersecting.)
|
||||
//
|
||||
|
@ -208,7 +197,7 @@ double TGPolygon::minangle_contour( const int contour ) {
|
|||
point_list c = poly[contour];
|
||||
int size = c.size();
|
||||
int p1_index, p2_index, p3_index;
|
||||
point2d p1, p2, p3;
|
||||
SGVec2d p1, p2, p3;
|
||||
double angle;
|
||||
double min_angle = 2.0 * SGD_PI;
|
||||
|
||||
|
@ -225,14 +214,14 @@ double TGPolygon::minangle_contour( const int contour ) {
|
|||
p3_index -= size;
|
||||
}
|
||||
|
||||
p1.x = c[p1_index].x();
|
||||
p1.y = c[p1_index].y();
|
||||
p1.x() = c[p1_index].x();
|
||||
p1.y() = c[p1_index].y();
|
||||
|
||||
p2.x = c[p2_index].x();
|
||||
p2.y = c[p2_index].y();
|
||||
p2.x() = c[p2_index].x();
|
||||
p2.y() = c[p2_index].y();
|
||||
|
||||
p3.x = c[p3_index].x();
|
||||
p3.y = c[p3_index].y();
|
||||
p3.x() = c[p3_index].x();
|
||||
p3.y() = c[p3_index].y();
|
||||
|
||||
angle = tgPolygonCalcAngle( p1, p2, p3 );
|
||||
|
||||
|
@ -244,7 +233,6 @@ double TGPolygon::minangle_contour( const int contour ) {
|
|||
return min_angle;
|
||||
}
|
||||
|
||||
|
||||
// return true if contour A is inside countour B
|
||||
bool TGPolygon::is_inside( int a, int b ) const {
|
||||
// make polygons from each specified contour
|
||||
|
|
|
@ -38,8 +38,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "point2d.hxx"
|
||||
|
||||
// forward declaration
|
||||
class TGPolygon;
|
||||
|
||||
|
@ -220,7 +218,7 @@ typedef poly_list::const_iterator const_poly_list_iterator;
|
|||
|
||||
|
||||
// Calculate theta of angle (a, b, c)
|
||||
double tgPolygonCalcAngle(point2d a, point2d b, point2d c);
|
||||
double tgPolygonCalcAngle(SGVec2d a, SGVec2d b, SGVec2d c);
|
||||
|
||||
|
||||
// canonify the polygon winding, outer contour must be anti-clockwise,
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include <simgear/misc/sg_dir.hxx>
|
||||
|
||||
#include <HGT/hgt.hxx>
|
||||
#include <Polygon/point2d.hxx>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -75,16 +74,14 @@ int main(int argc, char **argv) {
|
|||
hgt.load();
|
||||
hgt.close();
|
||||
|
||||
point2d min, max;
|
||||
min.x = hgt.get_originx() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
min.y = hgt.get_originy() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_min( min.x, min.y );
|
||||
SGVec2d min, max;
|
||||
min.x() = hgt.get_originx() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
min.y() = hgt.get_originy() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_min( min.x(), min.y() );
|
||||
|
||||
max.x = (hgt.get_originx() + hgt.get_cols() * hgt.get_col_step()) / 3600.0
|
||||
- SG_HALF_BUCKET_SPAN;
|
||||
max.y = (hgt.get_originy() + hgt.get_rows() * hgt.get_row_step()) / 3600.0
|
||||
- SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_max( max.x, max.y );
|
||||
max.x() = (hgt.get_originx() + hgt.get_cols() * hgt.get_col_step()) / 3600.0 - SG_HALF_BUCKET_SPAN;
|
||||
max.y() = (hgt.get_originy() + hgt.get_rows() * hgt.get_row_step()) / 3600.0 - SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_max( max.x(), max.y() );
|
||||
|
||||
if ( b_min == b_max ) {
|
||||
hgt.write_area( work_dir, b_min );
|
||||
|
@ -103,7 +100,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
for ( j = 0; j <= dy; j++ ) {
|
||||
for ( i = 0; i <= dx; i++ ) {
|
||||
b_cur = sgBucketOffset(min.x, min.y, i, j);
|
||||
b_cur = sgBucketOffset(min.x(), min.y(), i, j);
|
||||
hgt.write_area( work_dir, b_cur );
|
||||
}
|
||||
}
|
||||
|
@ -111,5 +108,3 @@ int main(int argc, char **argv) {
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,13 +43,8 @@
|
|||
#include <simgear/misc/sg_dir.hxx>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <tiffio.h>
|
||||
|
||||
#include <Polygon/point2d.hxx>
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#include <Lib/HGT/srtmbase.hxx>
|
||||
|
||||
using std::cout;
|
||||
|
@ -351,16 +346,14 @@ int main(int argc, char **argv) {
|
|||
hgt.load();
|
||||
hgt.close();
|
||||
|
||||
point2d min, max;
|
||||
min.x = hgt.get_originx() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
min.y = hgt.get_originy() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_min( min.x, min.y );
|
||||
SGVec2d min, max;
|
||||
min.x() = hgt.get_originx() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
min.y() = hgt.get_originy() / 3600.0 + SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_min( min.x(), min.y() );
|
||||
|
||||
max.x = (hgt.get_originx() + hgt.get_cols() * hgt.get_col_step()) / 3600.0
|
||||
- SG_HALF_BUCKET_SPAN;
|
||||
max.y = (hgt.get_originy() + hgt.get_rows() * hgt.get_row_step()) / 3600.0
|
||||
- SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_max( max.x, max.y );
|
||||
max.x() = (hgt.get_originx() + hgt.get_cols() * hgt.get_col_step()) / 3600.0 - SG_HALF_BUCKET_SPAN;
|
||||
max.y() = (hgt.get_originy() + hgt.get_rows() * hgt.get_row_step()) / 3600.0 - SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_max( max.x(), max.y() );
|
||||
|
||||
if ( b_min == b_max ) {
|
||||
hgt.write_area( work_dir, b_min );
|
||||
|
@ -379,7 +372,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
for ( j = 0; j <= dy; j++ ) {
|
||||
for ( i = 0; i <= dx; i++ ) {
|
||||
b_cur = sgBucketOffset(min.x, min.y, i, j);
|
||||
b_cur = sgBucketOffset(min.x(), min.y(), i, j);
|
||||
hgt.write_area( work_dir, b_cur );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <Array/array.hxx>
|
||||
#include <Polygon/point2d.hxx>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
using std::cout;
|
||||
|
@ -62,14 +60,14 @@ int main(int argc, char **argv) {
|
|||
int lat_arcsec = (int)(lat_deg * 3600.0);
|
||||
int res = 1;
|
||||
|
||||
point2d min, max;
|
||||
min.x = lon_deg + SG_HALF_BUCKET_SPAN;
|
||||
min.y = lat_deg + SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_min( min.x, min.y );
|
||||
SGVec2d min, max;
|
||||
min.x() = lon_deg + SG_HALF_BUCKET_SPAN;
|
||||
min.y() = lat_deg + SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_min( min.x(), min.y() );
|
||||
|
||||
max.x = lon_deg + 1 - SG_HALF_BUCKET_SPAN;
|
||||
max.y = lat_deg + 1 - SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_max( max.x, max.y );
|
||||
max.x() = lon_deg + 1 - SG_HALF_BUCKET_SPAN;
|
||||
max.y() = lat_deg + 1 - SG_HALF_BUCKET_SPAN;
|
||||
SGBucket b_max( max.x(), max.y() );
|
||||
|
||||
SGBucket b_cur;
|
||||
int dx, dy, i, j;
|
||||
|
@ -84,7 +82,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
for ( j = 0; j <= dy; j++ ) {
|
||||
for ( i = 0; i <= dx; i++ ) {
|
||||
b_cur = sgBucketOffset(min.x, min.y, i, j);
|
||||
b_cur = sgBucketOffset(min.x(), min.y(), i, j);
|
||||
string file = work_dir + "/";
|
||||
file += b_cur.gen_base_path() + "/";
|
||||
file += b_cur.gen_index_str();
|
||||
|
@ -127,5 +125,3 @@ int main(int argc, char **argv) {
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include <simgear/misc/sg_dir.hxx>
|
||||
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <Polygon/point2d.hxx>
|
||||
|
||||
#include <ogrsf_frmts.h>
|
||||
|
||||
|
|
Loading…
Reference in a new issue