]> git.mxchange.org Git - flightgear.git/commitdiff
Working towards better handling of multi-contoured polygons.
authorcurt <curt>
Tue, 30 Mar 1999 13:41:38 +0000 (13:41 +0000)
committercurt <curt>
Tue, 30 Mar 1999 13:41:38 +0000 (13:41 +0000)
Clipper/clipper.cxx

index a6d78fd3acf7a86c0e483f6cc673a861a99705f6..9817cf6de40df411dbf727d66b6a1d0e047fd0e0 100644 (file)
@@ -55,7 +55,7 @@ bool FGClipper::init() {
 // Load a polygon definition file
 bool FGClipper::load_polys(const string& path) {
     string poly_name;
-    AreaType poly_type;
+    AreaType poly_type = DefaultArea;
     int contours, count, i, j;
     double startx, starty, x, y, lastx, lasty;
 
@@ -68,6 +68,10 @@ bool FGClipper::load_polys(const string& path) {
        exit(-1);
     }
 
+    gpc_polygon *poly = new gpc_polygon;
+    poly->num_contours = 0;
+    poly->contour = NULL;
+
     in >> skipcomment;
     while ( !in.eof() ) {
        in >> poly_name;
@@ -116,24 +120,22 @@ bool FGClipper::load_polys(const string& path) {
                        << lastx << ", " << lasty );
            }
 
-           gpc_polygon *poly = new gpc_polygon;
-           poly->num_contours = 0;
-           poly->contour = NULL;
            gpc_add_contour( poly, &v_list );
 
-           int area = (int)poly_type;
-           if ( area < FG_MAX_AREA_TYPES ) {
-               polys_in.polys[area].push_back(poly);
-           } else {
-               FG_LOG( FG_CLIPPER, FG_ALERT, "Polygon type out of range = " 
-                       << (int)poly_type);
-               exit(-1);
-           }
        }
 
        in >> skipcomment;
     }
 
+    int area = (int)poly_type;
+    if ( area < FG_MAX_AREA_TYPES ) {
+       polys_in.polys[area].push_back(poly);
+    } else {
+       FG_LOG( FG_CLIPPER, FG_ALERT, "Polygon type out of range = " 
+               << (int)poly_type);
+       exit(-1);
+    }
+
     // FILE *ofp= fopen("outfile", "w");
     // gpc_write_polygon(ofp, &polys.landuse);
 
@@ -175,7 +177,7 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) {
 
     // process polygons in priority order
     for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
-
+       cout << "num polys of this type = " << polys_in.polys[i].size() << endl;
        current = polys_in.polys[i].begin();
        last = polys_in.polys[i].end();
        for ( ; current != last; ++current ) {
@@ -256,6 +258,9 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) {
 
 
 // $Log$
+// Revision 1.7  1999/03/30 13:41:38  curt
+// Working towards better handling of multi-contoured polygons.
+//
 // Revision 1.6  1999/03/27 05:20:53  curt
 // Pass along default area explicitely to triangulator.
 //