Speed up linear feature clipping. This makes the creation of airports much faster.
This commit is contained in:
parent
edf8e8310f
commit
e18c939f66
3 changed files with 27 additions and 17 deletions
|
@ -517,11 +517,11 @@ void Airport::merge_slivers( superpoly_list& polys, poly_list& slivers_list ) {
|
||||||
|
|
||||||
void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
||||||
{
|
{
|
||||||
ClipPolyType accum;
|
ClipPolyType accum;
|
||||||
poly_list slivers;
|
poly_list slivers;
|
||||||
|
|
||||||
// try to keep line accumulator in clipper format for speed...
|
// try to keep line accumulator in clipper format for speed...
|
||||||
ClipPolyType line_accum;
|
ClipPolyType lines;
|
||||||
poly_list line_slivers;
|
poly_list line_slivers;
|
||||||
|
|
||||||
TGPolygon apt_base;
|
TGPolygon apt_base;
|
||||||
|
@ -608,7 +608,7 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
||||||
make_shapefiles = false;
|
make_shapefiles = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
features[i]->BuildBtg( altitude, &line_polys, &line_tps, &line_accum, &rwy_lights, make_shapefiles );
|
features[i]->BuildBtg( &line_polys, &line_tps, &lines, &rwy_lights, make_shapefiles );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
#include <simgear/math/sg_geodesy.hxx>
|
#include <simgear/math/sg_geodesy.hxx>
|
||||||
#include <simgear/math/SGVec3.hxx>
|
#include <simgear/math/SGVec3.hxx>
|
||||||
#include <simgear/math/SGMisc.hxx>
|
#include <simgear/math/SGMisc.hxx>
|
||||||
|
#include <simgear/math/SGMath.hxx>
|
||||||
|
#include <simgear/math/SGGeometryFwd.hxx>
|
||||||
|
#include <simgear/math/SGBox.hxx>
|
||||||
|
#include <simgear/math/SGIntersect.hxx>
|
||||||
|
|
||||||
#include <Geometry/poly_support.hxx>
|
#include <Geometry/poly_support.hxx>
|
||||||
|
|
||||||
|
@ -929,12 +933,12 @@ int LinearFeature::Finish( bool closed, unsigned int idx )
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LinearFeature::BuildBtg(float alt_m, superpoly_list* line_polys, texparams_list* line_tps, ClipPolyType* line_accum, superpoly_list* lights, bool make_shapefiles )
|
int LinearFeature::BuildBtg(superpoly_list* line_polys, texparams_list* line_tps, ClipPolyType* lines, superpoly_list* lights, bool make_shapefiles )
|
||||||
{
|
{
|
||||||
TGPolygon poly;
|
TGPolygon poly, tmp;
|
||||||
TGPolygon clipped;
|
|
||||||
void* ds_id = NULL; // If we are going to build shapefiles
|
void* ds_id = NULL; // If we are going to build shapefiles
|
||||||
void* l_id = NULL; // datasource and layer IDs
|
void* l_id = NULL; // datasource and layer IDs
|
||||||
|
SGVec3d min, max, minp, maxp;
|
||||||
|
|
||||||
if ( make_shapefiles ) {
|
if ( make_shapefiles ) {
|
||||||
char ds_name[128];
|
char ds_name[128];
|
||||||
|
@ -946,16 +950,23 @@ int LinearFeature::BuildBtg(float alt_m, superpoly_list* line_polys, texparams_l
|
||||||
for ( unsigned int i = 0; i < marking_polys.size(); i++)
|
for ( unsigned int i = 0; i < marking_polys.size(); i++)
|
||||||
{
|
{
|
||||||
poly = marking_polys[i].get_poly();
|
poly = marking_polys[i].get_poly();
|
||||||
//poly = tgPolygonSimplify( poly );
|
poly.get_bounding_box(minp, maxp);
|
||||||
//poly = remove_tiny_contours( poly );
|
SGBoxd box1(minp, maxp);
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::BuildBtg: clipping poly " << i << " of " << marking_polys.size() << " with CLIPPER ");
|
for (int j= 0; j < lines->contours(); ++j)
|
||||||
clipped = tgPolygonDiffClipper( poly, *line_accum );
|
{
|
||||||
|
tmp.erase();
|
||||||
|
tmp.add_contour(lines->get_contour(j), 0);
|
||||||
|
tmp.get_bounding_box(min, max);
|
||||||
|
SGBoxd box2(min, max);
|
||||||
|
|
||||||
// clean the poly before union with accum
|
if ( intersects(box2, box1 ) )
|
||||||
clipped = reduce_degeneracy( clipped );
|
{
|
||||||
|
poly = tgPolygonDiffClipper( poly, tmp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
marking_polys[i].set_poly( clipped );
|
marking_polys[i].set_poly( poly );
|
||||||
line_polys->push_back( marking_polys[i] );
|
line_polys->push_back( marking_polys[i] );
|
||||||
|
|
||||||
/* If debugging this lf, write the poly, and the accum buffer at each step into their own layers */
|
/* If debugging this lf, write the poly, and the accum buffer at each step into their own layers */
|
||||||
|
@ -972,11 +983,10 @@ int LinearFeature::BuildBtg(float alt_m, superpoly_list* line_polys, texparams_l
|
||||||
l_id = tgShapefileOpenLayer( ds_id, layer_name );
|
l_id = tgShapefileOpenLayer( ds_id, layer_name );
|
||||||
|
|
||||||
sprintf( feature_name, "accum_%d", i );
|
sprintf( feature_name, "accum_%d", i );
|
||||||
tgShapefileCreateFeature( ds_id, l_id, *line_accum, feature_name );
|
tgShapefileCreateFeature( ds_id, l_id, *lines, feature_name );
|
||||||
}
|
}
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "LinearFeature::BuildBtg: union poly " << i << " of " << marking_polys.size() << " with CLIPPER " );
|
lines->add_contour(poly.get_contour(0), 0);
|
||||||
*line_accum = tgPolygonUnionClipper( poly, *line_accum );
|
|
||||||
|
|
||||||
line_tps->push_back( marking_tps[i] );
|
line_tps->push_back( marking_tps[i] );
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int Finish( bool closed, unsigned int idx );
|
int Finish( bool closed, unsigned int idx );
|
||||||
int BuildBtg( float alt_m, superpoly_list* line_polys, texparams_list* line_tps, ClipPolyType* line_accum, superpoly_list* lights, bool debug );
|
int BuildBtg( superpoly_list* line_polys, texparams_list* line_tps, ClipPolyType* lines, superpoly_list* lights, bool debug );
|
||||||
// int BuildBtg( float alt_m, superpoly_list* line_polys, texparams_list* line_tps, ClipPolyType* line_accum, superpoly_list* lights );
|
// int BuildBtg( float alt_m, superpoly_list* line_polys, texparams_list* line_tps, ClipPolyType* line_accum, superpoly_list* lights );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Reference in a new issue