1
0
Fork 0

Partially revert "fix some uninitialized data found with valgrind"

Some unwanted changes sneaked in
This commit is contained in:
Christian Schmitt 2012-09-03 19:19:57 +02:00
parent e6d8d69c87
commit 3e068ed6dd

View file

@ -559,17 +559,16 @@ int TGConstruct::LoadLandclassPolys( void ) {
// load 2D polygons from all directories provided
for ( i = 0; i < (int)load_dirs.size(); ++i ) {
poly_path = get_work_base() + "/" + load_dirs[i] + '/' + base;
SG_LOG(SG_GENERAL, SG_ALERT, "poly_path = " << poly_path);
string tile_str = bucket.gen_index_str();
simgear::Dir d(poly_path);
if (!d.exists()) {
SG_LOG(SG_GENERAL, SG_ALERT, "directory not found: " << poly_path);
SG_LOG(SG_GENERAL, SG_DEBUG, "directory not found: " << poly_path);
continue;
}
simgear::PathList files = d.children(simgear::Dir::TYPE_FILE);
SG_LOG( SG_CLIPPER, SG_INFO, "Loading " << files.size() << " polys from " << d.path() );
SG_LOG( SG_CLIPPER, SG_ALERT, files.size() << " Polys in " << d.path() );
BOOST_FOREACH(const SGPath& p, files) {
if (p.file_base() != tile_str) {
@ -582,18 +581,17 @@ int TGConstruct::LoadLandclassPolys( void ) {
{
// skipped!
} else if (lext == "osgb36") {
SG_LOG(SG_GENERAL, SG_ALERT, "Loading osgb36 poly definition file");
SG_LOG(SG_GENERAL, SG_ALERT, " Loading osgb36 poly definition file " << p.file());
load_osgb36_poly( p.str() );
++count;
} else {
load_poly( p.str() );
SG_LOG(SG_GENERAL, SG_ALERT, " Loaded " << p.file());
++count;
}
} // of directory file children
SG_LOG(SG_GENERAL, SG_ALERT, " loaded " << count << " total polys");
}
SG_LOG(SG_GENERAL, SG_ALERT, " Total polys used for this tile: " << count );
return count;
}
@ -604,11 +602,7 @@ int TGConstruct::LoadLandclassPolys( void ) {
// to reduce the number of separate polygons.
void TGConstruct::add_to_polys ( TGPolygon &accum, const TGPolygon &poly) {
if ( accum.contours() > 0 ) {
#if USE_CLIPPER
accum = tgPolygonUnionClipper( accum, poly );
#else
accum = tgPolygonUnion( accum, poly );
#endif
} else {
accum = poly;
}
@ -1242,11 +1236,7 @@ void TGConstruct::merge_slivers( TGLandclass& clipped, poly_list& slivers_list
poly = clipped.get_poly( area, shape, segment );
original_contours = poly.contours();
#if USE_CLIPPER
result = tgPolygonUnionClipper( poly, sliver );
#else
result = tgPolygonUnion( poly, sliver );
#endif
result_contours = result.contours();
if ( original_contours == result_contours ) {
@ -1257,11 +1247,7 @@ void TGConstruct::merge_slivers( TGLandclass& clipped, poly_list& slivers_list
/* add the sliver to the clip_mask, too */
TGPolygon mask = clipped.get_mask( area, shape );
#if USE_CLIPPER
result = tgPolygonUnionClipper( mask, sliver );
#else
result = tgPolygonUnion( mask, sliver );
#endif
clipped.set_mask( area, shape, result );
if ( IsDebugShape( shape_id ) ) {
@ -1302,11 +1288,7 @@ bool TGConstruct::ClipLandclassPolys( void ) {
#if USE_ACCUMULATOR
#if USE_CLIPPER
tgPolygonInitClipperAccumulator();
#else
tgPolygonInitGPCAccumulator();
#endif
#else
accum.erase();
@ -1344,29 +1326,17 @@ bool TGConstruct::ClipLandclassPolys( void ) {
for ( i = 0; i < TG_MAX_AREA_TYPES; i++ ) {
if ( is_landmass_area( i ) && !ignoreLandmass ) {
for ( unsigned int j = 0; j < polys_in.area_size(i); ++j ) {
#if USE_CLIPPER
land_mask = tgPolygonUnionClipper( land_mask, polys_in.get_mask(i, j) );
#else
land_mask = tgPolygonUnion( land_mask, polys_in.get_mask(i, j) );
#endif
}
} else if ( is_water_area( i ) ) {
for (unsigned int j = 0; j < polys_in.area_size(i); j++) {
#if USE_CLIPPER
water_mask = tgPolygonUnionClipper( water_mask, polys_in.get_mask(i, j) );
#else
water_mask = tgPolygonUnion( water_mask, polys_in.get_mask(i, j) );
#endif
}
} else if ( is_island_area( i ) ) {
for (unsigned int j = 0; j < polys_in.area_size(i); j++) {
#if USE_CLIPPER
island_mask = tgPolygonUnionClipper( island_mask, polys_in.get_mask(i, j) );
#else
island_mask = tgPolygonUnion( island_mask, polys_in.get_mask(i, j) );
#endif
}
}
}
@ -1389,21 +1359,13 @@ bool TGConstruct::ClipLandclassPolys( void ) {
// if not a hole, clip the area to the land_mask
if ( !ignoreLandmass && !is_hole_area( i ) ) {
#if USE_CLIPPER
tmp = tgPolygonIntClipper( tmp, land_mask );
#else
tmp = tgPolygonInt( tmp, land_mask );
#endif
}
// if a water area, cut out potential islands
if ( is_water_area( i ) ) {
// clip against island mask
#if USE_CLIPPER
tmp = tgPolygonDiffClipper( tmp, island_mask );
#else
tmp = tgPolygonDiff( tmp, island_mask );
#endif
}
if ( IsDebugShape( polys_in.get_shape( i, j ).id ) ) {
@ -1412,23 +1374,12 @@ bool TGConstruct::ClipLandclassPolys( void ) {
WriteDebugPoly( "pre-clip", name, tmp );
}
#if USE_CLIPPER
#if USE_ACCUMULATOR
clipped = tgPolygonDiffClipperWithAccumulator( tmp );
#else
clipped = tgPolygonDiffClipper( tmp, accum );
#endif
#else
#if USE_ACCUMULATOR
clipped = tgPolygonDiffWithAccumulator( tmp );
#else
clipped = tgPolygonDiff( tmp, accum );
#endif
#endif
// only add to output list if the clip left us with a polygon
if ( clipped.contours() > 0 ) {
@ -1460,23 +1411,12 @@ bool TGConstruct::ClipLandclassPolys( void ) {
}
}
#if USE_CLIPPER
#if USE_ACCUMULATOR
tgPolygonAddToClipperAccumulator( tmp );
#else
accum = tgPolygonUnionClipper( tmp, accum );
#endif
#else
#if USE_ACCUMULATOR
tgPolygonAddToAccumulator( tmp );
#else
accum = tgPolygonUnion( tmp, accum );
#endif
#endif
}
}
@ -1493,22 +1433,10 @@ bool TGConstruct::ClipLandclassPolys( void ) {
slivers.clear();
// finally, what ever is left over goes to ocean
#if USE_CLIPPER
#if USE_ACCUMULATOR
remains = tgPolygonDiffClipperWithAccumulator( safety_base );
#else
remains = tgPolygonDiffClipper( safety_base, accum );
#endif
#else
#if USE_ACCUMULATOR
remains = tgPolygonDiffWithAccumulator( safety_base );
#else
remains = tgPolygonDiff( safety_base, accum );
#endif
#endif
if ( remains.contours() > 0 ) {
@ -1545,6 +1473,7 @@ bool TGConstruct::ClipLandclassPolys( void ) {
sp.set_material( material );
sp.set_poly( remains );
shape.SetMask( remains );
shape.textured = false;
shape.sps.push_back( sp );
polys_clipped.add_shape( (int)get_sliver_target_area_type(), shape );
@ -1553,11 +1482,7 @@ bool TGConstruct::ClipLandclassPolys( void ) {
#if USE_ACCUMULATOR
#if USE_CLIPPER
tgPolygonFreeClipperAccumulator();
#else
tgPolygonFreeGPCAccumulator();
#endif
#endif
@ -2010,7 +1935,6 @@ void TGConstruct::WriteBtgFile( void )
}
void TGConstruct::CleanClippedPolys() {
unsigned int before, after;
// Clean the polys
for ( unsigned int area = 0; area < TG_MAX_AREA_TYPES; area++ ) {
@ -2101,7 +2025,7 @@ void TGConstruct::ConstructBucketStage1() {
/* If we have some debug IDs, create a datasource */
if ( debug_shapes.size() || debug_all ) {
sprintf(ds_name, "%s/constructdbg_%s", debug_path.c_str(), bucket.gen_index_str().c_str() );
SG_LOG(SG_GENERAL, SG_ALERT, "Construct tile, bucket = " << bucket << " debug_string: " << ds_name );
SG_LOG(SG_GENERAL, SG_ALERT, "Debug_string: " << ds_name );
} else {
strcpy( ds_name, "" );
}