]> git.mxchange.org Git - flightgear.git/blobdiff - Main/construct.cxx
Added GenOutput/
[flightgear.git] / Main / construct.cxx
index 7d8b385b1091d403787586579647447d23fe4e33..629df1918158945ddafcfcc92100528ed0ca0243 100644 (file)
 
 #include <Array/array.hxx>
 #include <Clipper/clipper.hxx>
+#include <GenOutput/genobj.hxx>
 #include <Triangulate/triangle.hxx>
 
 
-// load regular grid of elevation data (dem based)
+// load regular grid of elevation data (dem based), return list of
+// fitted nodes
 int load_dem(const string& work_base, FGBucket& b, FGArray& array) {
+    fitnode_list result;
     char tile_name[256];
     string base = b.gen_base_path();
     long int b_index = b.gen_index();
@@ -44,8 +47,10 @@ int load_dem(const string& work_base, FGBucket& b, FGArray& array) {
     cout << "dem_path = " << dem_path << endl;
 
     if ( ! array.open(dem_path) ) {
+       cout << "ERROR: cannot open " << dem_path << endl;
        return 0;
     }
+
     array.parse();
     array.fit( 100 );
 
@@ -133,19 +138,26 @@ int load_polys( const string& work_base, FGBucket& b, FGClipper& clipper) {
 
 
 // triangulate the data for each polygon
-void triangulate( const FGArray& array, const FGClipper& clipper,
+void do_triangulate( const FGArray& array, const FGClipper& clipper,
                  FGTriangle& t ) {
-    // first we need to consolidate the points of all the polygons
-    // into a more "Triangle" friendly format
-    FGgpcPolyList gpc_polys;
+    // first we need to consolidate the points of the DEM fit list and
+    // all the polygons into a more "Triangle" friendly format
+
+    fitnode_list fit_list = array.get_fit_node_list();
+    FGgpcPolyList gpc_polys = clipper.get_polys_clipped();
 
-    gpc_polys = clipper.get_polys_clipped();
+    cout << "ready to build node list and polygons" << endl;
+    t.build( fit_list, gpc_polys );
+    cout << "done building node list and polygons" << endl;
 
-    t.build( gpc_polys );
+    cout << "ready to do triangulation" << endl;
+    t.run_triangulate();
+    cout << "finished triangulation" << endl;
 }
 
 
 main(int argc, char **argv) {
+    fitnode_list fit_list;
     double lon, lat;
 
     if ( argc != 2 ) {
@@ -155,8 +167,12 @@ main(int argc, char **argv) {
 
     string work_base = argv[1];
    
-    lon = -146.248360; lat = 61.133950;  // PAVD (Valdez, AK)
-    // lon = -110.664244; lat = 33.352890;  // P13
+    // lon = -146.248360; lat = 61.133950;     // PAVD (Valdez, AK)
+    // lon = -110.664244; lat = 33.352890;     // P13
+    // lon = -93.211389; lat = 45.145000;      // KANE
+    // lon = -92.486188; lat = 44.590190;      // KRGK
+    lon = -89.744682312011719; lat= 29.314495086669922;
+
     FGBucket b( lon, lat );
 
     // load and fit grid of elevation data
@@ -169,11 +185,36 @@ main(int argc, char **argv) {
 
     // triangulate the data for each polygon
     FGTriangle t;
-    triangulate( array, clipper, t );
+    do_triangulate( array, clipper, t );
+
+    // generate the output
+    fgGenOutput( t );
 }
 
 
 // $Log$
+// Revision 1.7  1999/03/22 23:48:29  curt
+// Added GenOutput/
+//
+// Revision 1.6  1999/03/21 15:48:01  curt
+// Removed Dem2node from the Tools fold.
+// Tweaked the triangulator options to add quality mesh refinement.
+//
+// Revision 1.5  1999/03/21 14:02:05  curt
+// Added a mechanism to dump out the triangle structures for viewing.
+// Fixed a couple bugs in first pass at triangulation.
+// - needed to explicitely initialize the polygon accumulator in triangle.cxx
+//   before each polygon rather than depending on the default behavior.
+// - Fixed a problem with region attribute propagation where I wasn't generating
+//   the hole points correctly.
+//
+// Revision 1.4  1999/03/20 20:32:54  curt
+// First mostly successful tile triangulation works.  There's plenty of tweaking
+// to do, but we are marching in the right direction.
+//
+// Revision 1.3  1999/03/19 00:26:52  curt
+// Minor tweaks ...
+//
 // Revision 1.2  1999/03/17 23:49:52  curt
 // Started work on Triangulate/ section.
 //