From 453a82a03038da6febcfe44fed9e1a27072eeab3 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 19 Mar 1999 22:29:04 +0000 Subject: [PATCH] Working on preparationsn for triangulation. --- Triangulate/triangle.cxx | 56 ++++++++++++++++++++++++++++++++++++++-- Triangulate/triangle.hxx | 17 ++++++++++++ Triangulate/trinodes.hxx | 6 +++++ 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/Triangulate/triangle.cxx b/Triangulate/triangle.cxx index 1d90cbfbe..854b5b508 100644 --- a/Triangulate/triangle.cxx +++ b/Triangulate/triangle.cxx @@ -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. // diff --git a/Triangulate/triangle.hxx b/Triangulate/triangle.hxx index 9ba18005b..9c9b133cd 100644 --- a/Triangulate/triangle.hxx +++ b/Triangulate/triangle.hxx @@ -39,6 +39,11 @@ #include #include +#define REAL double +extern "C" { +#include +} + #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. // diff --git a/Triangulate/trinodes.hxx b/Triangulate/trinodes.hxx index 2245b5a8c..1a540f981 100644 --- a/Triangulate/trinodes.hxx +++ b/Triangulate/trinodes.hxx @@ -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. // -- 2.39.2