Minor tweaks to clipping rules.
This commit is contained in:
parent
5982e567fd
commit
84e7866b35
1 changed files with 26 additions and 6 deletions
|
@ -240,6 +240,12 @@ void FGClipper::merge_slivers( FGPolyList& clipped, FGPolygon& slivers ) {
|
||||||
done = false;
|
done = false;
|
||||||
|
|
||||||
for ( int area = 0; area < FG_MAX_AREA_TYPES && !done; ++area ) {
|
for ( int area = 0; area < FG_MAX_AREA_TYPES && !done; ++area ) {
|
||||||
|
|
||||||
|
if ( area == HoleArea ) {
|
||||||
|
// don't merge a non-hole sliver in with a hole
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
cout << " testing area = " << area << " with "
|
cout << " testing area = " << area << " with "
|
||||||
<< clipped.polys[area].size() << " polys" << endl;
|
<< clipped.polys[area].size() << " polys" << endl;
|
||||||
for ( int j = 0;
|
for ( int j = 0;
|
||||||
|
@ -284,8 +290,8 @@ void FGClipper::merge_slivers( FGPolyList& clipped, FGPolygon& slivers ) {
|
||||||
|
|
||||||
// Do actually clipping work
|
// Do actually clipping work
|
||||||
bool FGClipper::clip_all(const point2d& min, const point2d& max) {
|
bool FGClipper::clip_all(const point2d& min, const point2d& max) {
|
||||||
FGPolygon accum, result_union, tmp;
|
FGPolygon accum, tmp;
|
||||||
FGPolygon result_diff, slivers, remains;
|
FGPolygon slivers, remains;
|
||||||
// gpcpoly_iterator current, last;
|
// gpcpoly_iterator current, last;
|
||||||
|
|
||||||
FG_LOG( FG_CLIPPER, FG_INFO, "Running master clipper" );
|
FG_LOG( FG_CLIPPER, FG_INFO, "Running master clipper" );
|
||||||
|
@ -309,9 +315,8 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) {
|
||||||
FGPolygon land_mask;
|
FGPolygon land_mask;
|
||||||
land_mask.erase();
|
land_mask.erase();
|
||||||
for ( int i = 0; i < (int)polys_in.polys[DefaultArea].size(); ++i ) {
|
for ( int i = 0; i < (int)polys_in.polys[DefaultArea].size(); ++i ) {
|
||||||
result_union =
|
land_mask =
|
||||||
polygon_union( land_mask, polys_in.polys[DefaultArea][i] );
|
polygon_union( land_mask, polys_in.polys[DefaultArea][i] );
|
||||||
land_mask = result_union;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up island mask, for cutting holes in lakes
|
// set up island mask, for cutting holes in lakes
|
||||||
|
@ -322,6 +327,8 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) {
|
||||||
polygon_union( island_mask, polys_in.polys[IslandArea][i] );
|
polygon_union( island_mask, polys_in.polys[IslandArea][i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no longer needed, should be handle by polygon priority scheme
|
||||||
|
#if 0
|
||||||
// set up pond mask, for cutting holes in islands
|
// set up pond mask, for cutting holes in islands
|
||||||
FGPolygon pond_mask;
|
FGPolygon pond_mask;
|
||||||
pond_mask.erase();
|
pond_mask.erase();
|
||||||
|
@ -329,6 +336,7 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) {
|
||||||
pond_mask =
|
pond_mask =
|
||||||
polygon_union( pond_mask, polys_in.polys[PondArea][i] );
|
polygon_union( pond_mask, polys_in.polys[PondArea][i] );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// int count = 0;
|
// int count = 0;
|
||||||
// process polygons in priority order
|
// process polygons in priority order
|
||||||
|
@ -343,20 +351,30 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) {
|
||||||
FG_LOG( FG_CLIPPER, FG_DEBUG, get_area_name( (AreaType)i )
|
FG_LOG( FG_CLIPPER, FG_DEBUG, get_area_name( (AreaType)i )
|
||||||
<< " = " << current.contours() );
|
<< " = " << current.contours() );
|
||||||
|
|
||||||
if ( i > HoleArea ) {
|
// if not a hole, clip the area to the land_mask
|
||||||
|
if ( i != HoleArea ) {
|
||||||
// clip to land mask
|
// clip to land mask
|
||||||
tmp = polygon_int( current, land_mask );
|
tmp = polygon_int( current, land_mask );
|
||||||
} else {
|
} else {
|
||||||
tmp = current;
|
tmp = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( i == LakeArea ) {
|
// if a water area, cut out potential islands
|
||||||
|
if ( i == LakeArea || i == IntLakeArea || i == ReservoirArea ||
|
||||||
|
i == IntReservoirArea || i == StreamArea || i == CanalArea ||
|
||||||
|
i == OceanArea ) {
|
||||||
// clip against island mask
|
// clip against island mask
|
||||||
tmp = polygon_diff( tmp, island_mask );
|
tmp = polygon_diff( tmp, island_mask );
|
||||||
|
}
|
||||||
|
|
||||||
|
// no longer needed, should be handle by polygon priority scheme
|
||||||
|
#if 0
|
||||||
|
// if an island area, cut out potential ponds
|
||||||
} else if ( i == IslandArea ) {
|
} else if ( i == IslandArea ) {
|
||||||
// clip to pond mask
|
// clip to pond mask
|
||||||
tmp = polygon_diff( tmp, pond_mask );
|
tmp = polygon_diff( tmp, pond_mask );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// clip current polygon against previous higher priority
|
// clip current polygon against previous higher priority
|
||||||
// stuff
|
// stuff
|
||||||
|
@ -365,6 +383,8 @@ bool FGClipper::clip_all(const point2d& min, const point2d& max) {
|
||||||
// result_diff->num_contours = 0;
|
// result_diff->num_contours = 0;
|
||||||
// result_diff->contour = NULL;
|
// result_diff->contour = NULL;
|
||||||
|
|
||||||
|
FGPolygon result_union, result_diff;
|
||||||
|
|
||||||
if ( accum.contours() == 0 ) {
|
if ( accum.contours() == 0 ) {
|
||||||
result_diff = tmp;
|
result_diff = tmp;
|
||||||
result_union = tmp;
|
result_union = tmp;
|
||||||
|
|
Loading…
Add table
Reference in a new issue