]> git.mxchange.org Git - flightgear.git/blobdiff - Triangulate/triangle.cxx
Continued work on triangulation preparation.
[flightgear.git] / Triangulate / triangle.cxx
index 2a226dd3b2777dacd7c6bcdf85e25a62f77ba037..1d90cbfbe8f99ef82c69a4e49d1cfddcef91bb62 100644 (file)
@@ -36,38 +36,70 @@ FGTriangle::~FGTriangle( void ) {
 
 
 // populate this class based on the specified gpc_polys list
-int FGTriangle::build( FGgpcPolyList gpc_polys ) {
+int FGTriangle::build( const FGgpcPolyList& gpc_polys ) {
+    int index;
+    tripoly poly;
+
     // traverse the gpc_polys and build a unified node list and a set
     // of Triangle PSLG that reference the node list by index
     // (starting at zero)
 
     gpc_polygon *gpc_poly;
-    gpcpoly_iterator current, last;
+    const_gpcpoly_iterator current, last;
 
     // process polygons in priority order
     cout << "prepairing node list and polygons" << endl;
 
-    for ( int i = 0; i < FG_MAX_AREAS; ++i ) {
+    for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
        cout << "area type = " << i << endl;
        current = gpc_polys.polys[i].begin();
        last = gpc_polys.polys[i].end();
        for ( ; current != last; ++current ) {
            gpc_poly = *current;
+           cout << "processing a polygon, contours = " 
+                << gpc_poly->num_contours << endl;
+
+           poly.erase(poly.begin(), poly.end());
+
+           if (gpc_poly->num_contours <= 0 ) {
+               cout << "FATAL ERROR! no contours in this polygon" << endl;
+               exit(-1);
+           }
+
+           if (gpc_poly->num_contours > 1 ) {
+               cout << "FATAL ERROR! no multi-contour support" << endl;
+               exit(-1);
+           }
 
            for ( int j = 0; j < gpc_poly->num_contours; j++ ) {
                for ( int k = 0; k < gpc_poly->contour[j].num_vertices; k++ ) {
                    Point3D p( gpc_poly->contour[j].vertex[k].x,
                               gpc_poly->contour[j].vertex[k].y,
                               0 );
-                   cout << trinodes.unique_add( p ) << endl;
+                   index = trinodes.unique_add( p );
+                   poly.push_back(index);
+                   // cout << index << endl;
                }
+               polylist[i].push_back(poly);
            }
        }
     }
+
+    for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
+       cout << "polylist[" << i << "] = " << polylist[i].size() << endl;
+    }
+    return 0;
 }
 
 
 // $Log$
+// Revision 1.3  1999/03/19 00:27:10  curt
+// Continued work on triangulation preparation.
+//
+// Revision 1.2  1999/03/18 04:31:11  curt
+// Let's not pass copies of huge structures on the stack ... ye might see a
+// segfault ... :-)
+//
 // Revision 1.1  1999/03/17 23:51:59  curt
 // Initial revision.
 //