More work on tile add matching. Added second triangulation. Now need to
debug to see why none of it works! :-)
This commit is contained in:
parent
bab8b9cadf
commit
dd516b37d9
3 changed files with 75 additions and 14 deletions
|
@ -145,8 +145,8 @@ int fit_dem(FGArray& array, int error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// triangulate the data for each polygon
|
// triangulate the data for each polygon ( first time before splitting )
|
||||||
void do_triangulate( FGConstruct& c, const FGArray& array,
|
void first_triangulate( FGConstruct& c, const FGArray& array,
|
||||||
FGTriangle& t ) {
|
FGTriangle& t ) {
|
||||||
// first we need to consolidate the points of the DEM fit list and
|
// first we need to consolidate the points of the DEM fit list and
|
||||||
// all the polygons into a more "Triangle" friendly format
|
// all the polygons into a more "Triangle" friendly format
|
||||||
|
@ -160,11 +160,23 @@ void do_triangulate( FGConstruct& c, const FGArray& array,
|
||||||
cout << "done building node list and polygons" << endl;
|
cout << "done building node list and polygons" << endl;
|
||||||
|
|
||||||
cout << "ready to do triangulation" << endl;
|
cout << "ready to do triangulation" << endl;
|
||||||
t.run_triangulate();
|
t.run_triangulate( 1 );
|
||||||
cout << "finished triangulation" << endl;
|
cout << "finished triangulation" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// triangulate the data for each polygon ( second time after splitting
|
||||||
|
// and reassembling )
|
||||||
|
void second_triangulate( FGConstruct& c, FGTriangle& t ) {
|
||||||
|
t.rebuild( c );
|
||||||
|
cout << "done re building node list and polygons" << endl;
|
||||||
|
|
||||||
|
cout << "ready to do second triangulation" << endl;
|
||||||
|
t.run_triangulate( 2 );
|
||||||
|
cout << "finished second triangulation" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// build the wgs-84 point list (and fix the elevations of the geodetic
|
// build the wgs-84 point list (and fix the elevations of the geodetic
|
||||||
// nodes)
|
// nodes)
|
||||||
static void fix_point_heights( FGConstruct& c, const FGArray& array ) {
|
static void fix_point_heights( FGConstruct& c, const FGArray& array ) {
|
||||||
|
@ -314,8 +326,7 @@ static point_list gen_point_normals( FGConstruct& c ) {
|
||||||
|
|
||||||
|
|
||||||
// generate the flight gear scenery file
|
// generate the flight gear scenery file
|
||||||
void do_output( FGConstruct& c, const FGTriangle& t,
|
void do_output( FGConstruct& c, FGGenOutput& output ) {
|
||||||
const FGArray& array, FGGenOutput& output ) {
|
|
||||||
output.build( c );
|
output.build( c );
|
||||||
output.write( c );
|
output.write( c );
|
||||||
}
|
}
|
||||||
|
@ -348,7 +359,7 @@ void construct_tile( FGConstruct& c ) {
|
||||||
array.fit( error );
|
array.fit( error );
|
||||||
|
|
||||||
// triangulate the data for each polygon
|
// triangulate the data for each polygon
|
||||||
do_triangulate( c, array, t );
|
first_triangulate( c, array, t );
|
||||||
|
|
||||||
acceptable = true;
|
acceptable = true;
|
||||||
|
|
||||||
|
@ -408,10 +419,19 @@ void construct_tile( FGConstruct& c ) {
|
||||||
m.assemble_tile( c );
|
m.assemble_tile( c );
|
||||||
|
|
||||||
// now we must retriangulate the pasted together tile points
|
// now we must retriangulate the pasted together tile points
|
||||||
|
second_triangulate( c, t );
|
||||||
|
|
||||||
|
// save the results of the triangulation
|
||||||
|
c.set_tri_nodes( t.get_out_nodes() );
|
||||||
|
c.set_tri_elements( t.get_elelist() );
|
||||||
|
c.set_tri_segs( t.get_out_segs() );
|
||||||
|
|
||||||
|
// calculate wgs84 (cartesian) form of node list
|
||||||
|
fix_point_heights( c, array );
|
||||||
|
|
||||||
// generate the output
|
// generate the output
|
||||||
FGGenOutput output;
|
FGGenOutput output;
|
||||||
do_output( c, t, array, output );
|
do_output( c, output );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,18 @@ FGTriangle::build( const point_list& corner_list,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// populate this class based on the specified gpc_polys list
|
||||||
|
int FGTriangle::rebuild( FGConstruct& c ) {
|
||||||
|
in_nodes.clear();
|
||||||
|
in_segs.clear();
|
||||||
|
|
||||||
|
in_nodes = c.get_tri_nodes();
|
||||||
|
in_segs = c.get_tri_segs();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void write_out_data(struct triangulateio *out) {
|
static void write_out_data(struct triangulateio *out) {
|
||||||
FILE *node = fopen("tile.node", "w");
|
FILE *node = fopen("tile.node", "w");
|
||||||
fprintf(node, "%d 2 %d 0\n",
|
fprintf(node, "%d 2 %d 0\n",
|
||||||
|
@ -254,8 +266,14 @@ static void write_out_data(struct triangulateio *out) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// triangulate each of the polygon areas
|
// Front end triangulator for polygon list. Allocates and builds up
|
||||||
int FGTriangle::run_triangulate() {
|
// all the needed structures for the triangulator, runs it, copies the
|
||||||
|
// results, and frees all the data structures used by the
|
||||||
|
// triangulator. "pass" can be 1 or 2. 1 = first pass which
|
||||||
|
// generates extra nodes for a better triangulation. 2 = second pass
|
||||||
|
// after split/reassem where we don't want any extra nodes generated.
|
||||||
|
|
||||||
|
int FGTriangle::run_triangulate( int pass ) {
|
||||||
FGPolygon poly;
|
FGPolygon poly;
|
||||||
Point3D p;
|
Point3D p;
|
||||||
struct triangulateio in, out, vorout;
|
struct triangulateio in, out, vorout;
|
||||||
|
@ -391,9 +409,22 @@ int FGTriangle::run_triangulate() {
|
||||||
// from zero (z), assign a regional attribute to each element (A),
|
// from zero (z), assign a regional attribute to each element (A),
|
||||||
// and produce an edge list (e), and a triangle neighbor list (n).
|
// and produce an edge list (e), and a triangle neighbor list (n).
|
||||||
|
|
||||||
string tri_options = "pczq10Aen";
|
string tri_options;
|
||||||
// string tri_options = "pzAen";
|
if ( pass == 1 ) {
|
||||||
// string tri_options = "pczq15S400Aen";
|
// use a quality value of 10 (q10) meaning no interior
|
||||||
|
// triangle angles less than 10 degrees
|
||||||
|
tri_options = "pczq10Aen";
|
||||||
|
// string tri_options = "pzAen";
|
||||||
|
// string tri_options = "pczq15S400Aen";
|
||||||
|
} else if ( pass == 2 ) {
|
||||||
|
// no new points on boundary (Y), no internal segment
|
||||||
|
// splitting (YY), no quality refinement ()
|
||||||
|
tri_options = "pczYYAen";
|
||||||
|
} else {
|
||||||
|
cout << "unknown pass number = " << pass
|
||||||
|
<< " in FGTriangle::run_triangulate()" << endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
cout << "Triangulation with options = " << tri_options << endl;
|
cout << "Triangulation with options = " << tri_options << endl;
|
||||||
|
|
||||||
triangulate(tri_options.c_str(), &in, &out, &vorout);
|
triangulate(tri_options.c_str(), &in, &out, &vorout);
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
#include <Array/array.hxx>
|
#include <Array/array.hxx>
|
||||||
#include <Clipper/clipper.hxx>
|
#include <Clipper/clipper.hxx>
|
||||||
|
#include <Main/construct.hxx>
|
||||||
#include <Math/point3d.hxx>
|
#include <Math/point3d.hxx>
|
||||||
#include <Polygon/names.hxx>
|
#include <Polygon/names.hxx>
|
||||||
|
|
||||||
|
@ -80,8 +81,17 @@ public:
|
||||||
const point_list& fit_list,
|
const point_list& fit_list,
|
||||||
const FGgpcPolyList& gpc_polys );
|
const FGgpcPolyList& gpc_polys );
|
||||||
|
|
||||||
// front end triangulator for polygon list
|
// populate this class based on the specified gpc_polys list
|
||||||
int run_triangulate();
|
int rebuild( FGConstruct& c );
|
||||||
|
|
||||||
|
// Front end triangulator for polygon list. Allocates and builds
|
||||||
|
// up all the needed structures for the triangulator, runs it,
|
||||||
|
// copies the results, and frees all the data structures used by
|
||||||
|
// the triangulator. "pass" can be 1 or 2. 1 = first pass which
|
||||||
|
// generates extra nodes for a better triangulation. 2 = second
|
||||||
|
// pass after split/reassem where we don't want any extra nodes
|
||||||
|
// generated.
|
||||||
|
int run_triangulate( int pass );
|
||||||
|
|
||||||
inline FGTriNodes get_out_nodes() const { return out_nodes; }
|
inline FGTriNodes get_out_nodes() const { return out_nodes; }
|
||||||
inline size_t get_out_nodes_size() const { return out_nodes.size(); }
|
inline size_t get_out_nodes_size() const { return out_nodes.size(); }
|
||||||
|
|
Loading…
Add table
Reference in a new issue