]> git.mxchange.org Git - flightgear.git/commitdiff
Working on preparationsn for triangulation.
authorcurt <curt>
Fri, 19 Mar 1999 22:29:04 +0000 (22:29 +0000)
committercurt <curt>
Fri, 19 Mar 1999 22:29:04 +0000 (22:29 +0000)
Triangulate/triangle.cxx
Triangulate/triangle.hxx
Triangulate/trinodes.hxx

index 1d90cbfbe8f99ef82c69a4e49d1cfddcef91bb62..854b5b508188588e4c00493844e520c742cc6ef7 100644 (file)
@@ -68,7 +68,8 @@ int FGTriangle::build( const FGgpcPolyList& gpc_polys ) {
 
            if (gpc_poly->num_contours > 1 ) {
                cout << "FATAL ERROR! no multi-contour support" << endl;
-               exit(-1);
+               sleep(5);
+               // exit(-1);
            }
 
            for ( int j = 0; j < gpc_poly->num_contours; j++ ) {
@@ -86,13 +87,64 @@ int FGTriangle::build( const FGgpcPolyList& gpc_polys ) {
     }
 
     for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
-       cout << "polylist[" << i << "] = " << polylist[i].size() << endl;
+       if ( polylist[i].size() ) {
+           cout << get_area_name((AreaType)i) << " = " 
+                << polylist[i].size() << endl;
+       }
+    }
+    return 0;
+}
+
+
+// do actual triangulation
+int FGTriangle::do_triangulate( const tripoly& poly ) {
+    point_container node_list;
+    struct triangulateio in, mid, out, vorout;
+    int counter;
+
+    // define input points
+    node_list = trinodes.get_node_list();
+
+    in.numberofpoints = node_list.size();
+    in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL));
+
+    point_iterator current, last;
+    current = node_list.begin();
+    last = node_list.end();
+    counter = 0;
+    for ( ; current != last; ++current ) {
+       in.pointlist[counter++] = current->x();
+       in.pointlist[counter++] = current->y();
+    }
+}
+
+
+// triangulate each of the polygon areas
+int FGTriangle::triangulate() {
+    tripoly poly;
+
+    tripoly_list_iterator current, last;
+
+    for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
+       cout << "area type = " << i << endl;
+       current = polylist[i].begin();
+       last = polylist[i].end();
+       for ( ; current != last; ++current ) {
+           poly = *current;
+           cout << "triangulating a polygon, size = " << poly.size() << endl;
+
+           do_triangulate( poly );
+       }
     }
+
     return 0;
 }
 
 
 // $Log$
+// Revision 1.4  1999/03/19 22:29:04  curt
+// Working on preparationsn for triangulation.
+//
 // Revision 1.3  1999/03/19 00:27:10  curt
 // Continued work on triangulation preparation.
 //
index 9ba18005b811561da6660669c1ae0288479ebafa..9c9b133cddb89a9a1242fe1c59dee3c37146a631 100644 (file)
 #include <Math/point3d.hxx>
 #include <Polygon/names.hxx>
 
+#define REAL double
+extern "C" {
+#include <Triangle/triangle.h>
+}
+
 #include "trinodes.hxx"
 
 FG_USING_STD(vector);
@@ -66,8 +71,17 @@ public:
     FGTriangle( void );
     ~FGTriangle( void );
 
+    // add nodes from the dem fit
+    int add_nodes();
+
     // populate this class based on the specified gpc_polys list
     int build( const FGgpcPolyList& gpc_polys );
+
+    // do actual triangulation
+    int do_triangulate( const tripoly& poly );
+
+    // front end triangulator for polygon list
+    int triangulate();
 };
 
 
@@ -75,6 +89,9 @@ public:
 
 
 // $Log$
+// Revision 1.4  1999/03/19 22:29:05  curt
+// Working on preparationsn for triangulation.
+//
 // Revision 1.3  1999/03/19 00:27:11  curt
 // Continued work on triangulation preparation.
 //
index 2245b5a8cf9cb8d8b69c1dd02a6474cdb0135d50..1a540f981a660ad9a9992042d2f3281ce55f6da4 100644 (file)
@@ -67,6 +67,9 @@ public:
     // Add a point to the point list if it doesn't already exist.
     // Returns the index (starting at zero) of the point in the list.
     int unique_add( const Point3D& p );
+
+    // return the master node list
+    inline point_container get_node_list() const { return point_list; }
 };
 
 
@@ -74,6 +77,9 @@ public:
 
 
 // $Log$
+// Revision 1.2  1999/03/19 22:29:06  curt
+// Working on preparationsn for triangulation.
+//
 // Revision 1.1  1999/03/17 23:52:00  curt
 // Initial revision.
 //