string poly_name;
AreaType poly_type = DefaultArea;
int contours, count, i, j;
+ int hole_flag;
double startx, starty, x, y, lastx, lasty;
FG_LOG( FG_CLIPPER, FG_INFO, "Loading " << path << " ..." );
exit(-1);
}
+ in >> hole_flag;
+
in >> startx;
in >> starty;
v_list.vertex[0].x = startx;
<< lastx << ", " << lasty );
}
- gpc_add_contour( poly, &v_list, 0 );
-
+ gpc_add_contour( poly, &v_list, hole_flag );
}
in >> skipcomment;
if ( min_node_index == 0 ) {
p1 = trinodes.get_node( poly[contour][1] );
- p2 = trinodes.get_node( poly[contour][poly.size() - 1] );
+ p2 = trinodes.get_node( poly[contour][poly[contour].size() - 1] );
} else if ( min_node_index == (int)(poly[contour].size()) - 1 ) {
p1 = trinodes.get_node( poly[contour][0] );
- p2 = trinodes.get_node( poly[contour][poly.size() - 1] );
+ p2 = trinodes.get_node( poly[contour][poly[contour].size() - 2] );
} else {
p1 = trinodes.get_node( poly[contour][min_node_index - 1] );
p2 = trinodes.get_node( poly[contour][min_node_index + 1] );
p3.sety(100);
for ( int i = 0; i < (int)poly.size(); ++i ) {
- for ( int j = 0; j < (int)(poly[i].size()) - 1; ++j ) {
- p1 = trinodes.get_node( poly[contour][j] );
- p2 = trinodes.get_node( poly[contour][j+1] );
+ cout << "contour = " << i << " size = " << poly[i].size() << endl;
+ for ( int j = 0; j < (int)(poly[i].size() - 1); ++j ) {
+ cout << " p1 = " << poly[i][j] << " p2 = "
+ << poly[i][j+1] << endl;
+ p1 = trinodes.get_node( poly[i][j] );
+ p2 = trinodes.get_node( poly[i][j+1] );
if ( intersects(p1, p2, m.x(), &result) ) {
// cout << "intersection = " << result << endl;
}
}
}
- p1 = trinodes.get_node( poly[contour][0] );
- p2 = trinodes.get_node( poly[contour][poly.size() - 1] );
+ cout << " p1 = " << poly[i][0] << " p2 = "
+ << poly[i][poly[i].size() - 1] << endl;
+ p1 = trinodes.get_node( poly[i][0] );
+ p2 = trinodes.get_node( poly[i][poly[i].size() - 1] );
if ( intersects(p1, p2, m.x(), &result) ) {
// cout << "intersection = " << result << endl;
if ( ( result.y() < p3.y() ) &&
int j;
for ( j = 0; j < gpc_poly->num_contours; j++ ) {
- cout << " processing contour = " << j << ", nodes = "
- << gpc_poly->contour[j].num_vertices << endl;
+ cout << " processing contour = " << j << ", nodes = "
+ << gpc_poly->contour[j].num_vertices << ", hole = "
+ << gpc_poly->hole[j] << endl;
// sprintf(junkn, "g.%d", junkc++);
// junkfp = fopen(junkn, "w");
// junkp = in_nodes.get_node( index );
// fprintf(junkfp, "%.4f %.4f\n", junkp.x(), junkp.y());
poly.add_node(j, index);
- // cout << index << endl;
+ cout << " - " << index << endl;
}
// fprintf(junkfp, "%.4f %.4f\n",
// gpc_poly->contour[j].vertex[0].x,
// fclose(junkfp);
poly.set_hole_flag( j, gpc_poly->hole[j] );
- polylist[i].push_back( poly );
}
for ( j = 0; j < gpc_poly->num_contours; j++ ) {
poly.calc_point_inside( j, in_nodes );
}
+
+ polylist[i].push_back( poly );
}
}
// region list
in.numberofregions = 0;
for ( int i = 0; i < FG_MAX_AREA_TYPES; ++i ) {
- in.numberofregions += polylist[i].size();
+ poly_list_iterator h_current, h_last;
+ h_current = polylist[i].begin();
+ h_last = polylist[i].end();
+ for ( ; h_current != h_last; ++h_current ) {
+ poly = *h_current;
+ for ( int j = 0; j < poly.contours(); j++ ) {
+ if ( ! poly.get_hole_flag( j ) ) {
+ ++in.numberofregions;
+ }
+ }
+ }
}
in.regionlist = (REAL *) malloc(in.numberofregions * 4 * sizeof(REAL));
for ( ; h_current != h_last; ++h_current ) {
poly = *h_current;
for ( int j = 0; j < poly.contours(); j++ ) {
- p = poly.get_point_inside( j );
- in.regionlist[counter++] = p.x(); // x coord
- in.regionlist[counter++] = p.y(); // y coord
- in.regionlist[counter++] = i; // region attribute
- in.regionlist[counter++] = -1.0; // area constraint (unused)
+ if ( ! poly.get_hole_flag( j ) ) {
+ p = poly.get_point_inside( j );
+ cout << "Region point = " << p << endl;
+ in.regionlist[counter++] = p.x(); // x coord
+ in.regionlist[counter++] = p.y(); // y coord
+ in.regionlist[counter++] = i; // region attribute
+ in.regionlist[counter++] = -1.0; // area constraint
+ // (unused)
+ }
}
}
}