]> git.mxchange.org Git - flightgear.git/commitdiff
More work on tile add matching. Added second triangulation. Now need to
authorcurt <curt>
Tue, 4 May 1999 12:40:18 +0000 (12:40 +0000)
committercurt <curt>
Tue, 4 May 1999 12:40:18 +0000 (12:40 +0000)
debug to see why none of it works! :-)

Tools/Construct/Main/main.cxx
Tools/Construct/Triangulate/triangle.cxx
Tools/Construct/Triangulate/triangle.hxx

index 72fbda7988b315cc2e2bf8c6849e1008aeb7d8f9..1041b99b12cab9c70f69861493d80e8c78be39db 100644 (file)
@@ -145,8 +145,8 @@ int fit_dem(FGArray& array, int error) {
 }
 
 
-// triangulate the data for each polygon
-void do_triangulate( FGConstruct& c, const FGArray& array,
+// triangulate the data for each polygon ( first time before splitting )
+void first_triangulate( FGConstruct& c, const FGArray& array,
                     FGTriangle& t ) {
     // first we need to consolidate the points of the DEM fit list and
     // 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 << "ready to do triangulation" << endl;
-    t.run_triangulate();
+    t.run_triangulate( 1 );
     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
 // nodes)
 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
-void do_output( FGConstruct& c, const FGTriangle& t, 
-               const FGArray& array, FGGenOutput& output ) {
+void do_output( FGConstruct& c, FGGenOutput& output ) {
     output.build( c );
     output.write( c );
 }
@@ -348,7 +359,7 @@ void construct_tile( FGConstruct& c ) {
        array.fit( error );
 
        // triangulate the data for each polygon
-       do_triangulate( c, array, t );
+       first_triangulate( c, array, t );
 
        acceptable = true;
 
@@ -408,10 +419,19 @@ void construct_tile( FGConstruct& c ) {
     m.assemble_tile( c );
 
     // 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
     FGGenOutput output;
-    do_output( c, t, array, output );
+    do_output( c, output );
 }
 
 
index a95b2efb7cdd44560ddb5c9c9e7d99fe270f1899..4258f93b7773b5055ed76e9b88b358aacc5d3271 100644 (file)
@@ -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) {
     FILE *node = fopen("tile.node", "w");
     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
-int FGTriangle::run_triangulate() {
+// 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 FGTriangle::run_triangulate( int pass ) {
     FGPolygon poly;
     Point3D p;
     struct triangulateio in, out, vorout;
@@ -391,9 +409,22 @@ int FGTriangle::run_triangulate() {
     // from zero (z), assign a regional attribute to each element (A),
     // and produce an edge list (e), and a triangle neighbor list (n).
 
-    string tri_options = "pczq10Aen";
-    // string tri_options = "pzAen";
-    // string tri_options = "pczq15S400Aen";
+    string tri_options;
+    if ( pass == 1 ) {
+       // 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;
 
     triangulate(tri_options.c_str(), &in, &out, &vorout);
index b94842501fd2fde631836c76132c3dc76e2f6282..d56ad54c5ba0d648f8aae1d5bec6927a5279eaa9 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <Array/array.hxx>
 #include <Clipper/clipper.hxx>
+#include <Main/construct.hxx>
 #include <Math/point3d.hxx>
 #include <Polygon/names.hxx>
 
@@ -80,8 +81,17 @@ public:
               const point_list& fit_list,
               const FGgpcPolyList& gpc_polys );
 
-    // front end triangulator for polygon list
-    int run_triangulate();
+    // populate this class based on the specified gpc_polys list
+    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 size_t get_out_nodes_size() const { return out_nodes.size(); }