diff --git a/src/Lib/terragear/tg_accumulator.cxx b/src/Lib/terragear/tg_accumulator.cxx index 11fbb0ba..9850b36f 100644 --- a/src/Lib/terragear/tg_accumulator.cxx +++ b/src/Lib/terragear/tg_accumulator.cxx @@ -14,6 +14,10 @@ tgPolygon tgAccumulator::Diff( const tgContour& subject ) all_nodes.add( subject.GetNode(i) ); } + for ( unsigned int i = 0; i < nodes.size(); i++ ) { + all_nodes.add( nodes[i] ); + } + unsigned int num_hits = 0; tgRectangle box1 = subject.GetBoundingBox(); @@ -50,40 +54,6 @@ tgPolygon tgAccumulator::Diff( const tgContour& subject ) return result; } -void tgAccumulator::Add( const tgContour& subject ) -{ - tgPolygon poly; - poly.AddContour( subject ); - - ClipperLib::Polygons clipper_subject = tgPolygon::ToClipper( poly ); - accum.push_back( clipper_subject ); -} - -void tgAccumulator::ToShapefiles( const std::string& path, const std::string& layer_prefix, bool individual ) -{ - char shapefile[32]; - char layer[32]; - - if ( individual ) { - for (unsigned int i=0; i < accum.size(); i++) { - sprintf( layer, "%s_%d", layer_prefix.c_str(), i ); - sprintf( shapefile, "accum_%d", i ); - tgShapefile::FromClipper( accum[i], path, layer, std::string(shapefile) ); - } - } else { - ClipperLib::Polygons clipper_result; - ClipperLib::Clipper c; - c.Clear(); - - for ( unsigned int i=0; i clipper_polygons_list; clipper_polygons_list accum; + UniqueSGGeodSet nodes; }; #endif // _TGACCUMULATOR_HXX \ No newline at end of file diff --git a/src/Lib/terragear/tg_chopper.cxx b/src/Lib/terragear/tg_chopper.cxx index cd5b3b3d..2b27e14b 100644 --- a/src/Lib/terragear/tg_chopper.cxx +++ b/src/Lib/terragear/tg_chopper.cxx @@ -45,7 +45,7 @@ tgPolygon tgChopper::Clip( const tgPolygon& subject, base.AddNode( 0, SGGeod::fromDeg( max.getLongitudeDeg(), max.getLatitudeDeg()) ); base.AddNode( 0, SGGeod::fromDeg( min.getLongitudeDeg(), max.getLatitudeDeg()) ); - result = tgPolygon::Intersect( base, subject ); + result = tgPolygon::Intersect( subject, base ); if ( result.Contours() > 0 ) { if ( subject.GetPreserve3D() ) { result.InheritElevations( subject ); @@ -138,21 +138,21 @@ void tgChopper::Add( const tgPolygon& subject, const std::string& type ) clip_row.AddNode( 0, SGGeod::fromDeg( 180.0, clip_top) ); clip_row.AddNode( 0, SGGeod::fromDeg(-180.0, clip_top) ); - clipped = tgPolygon::Intersect( clip_row, subject ); + clipped = tgPolygon::Intersect( subject, clip_row ); if ( clipped.TotalNodes() > 0 ) { - if ( subject.GetPreserve3D() ) { - clipped.InheritElevations( subject ); - clipped.SetPreserve3D( true ); - } - clipped.SetTexParams( subject.GetTexParams() ); - if ( subject.GetTexMethod() == TG_TEX_BY_GEODE ) { - // need to set center latitude for geodetic texturing - clipped.SetTexMethod( TG_TEX_BY_GEODE, b_clip.get_center_lat() ); - } - clipped.SetFlag(type); + if ( subject.GetPreserve3D() ) { + clipped.InheritElevations( subject ); + clipped.SetPreserve3D( true ); + } + clipped.SetTexParams( subject.GetTexParams() ); + if ( subject.GetTexMethod() == TG_TEX_BY_GEODE ) { + // need to set center latitude for geodetic texturing + clipped.SetTexMethod( TG_TEX_BY_GEODE, b_clip.get_center_lat() ); + } + clipped.SetFlag(type); - ClipRow( clipped, b_clip.get_center_lat(), type ); + ClipRow( clipped, b_clip.get_center_lat(), type ); #if 0 { diff --git a/src/Lib/terragear/tg_contour.cxx b/src/Lib/terragear/tg_contour.cxx index 35ba70c6..fe106a7a 100644 --- a/src/Lib/terragear/tg_contour.cxx +++ b/src/Lib/terragear/tg_contour.cxx @@ -456,6 +456,12 @@ tgPolygon tgContour::Union( const tgContour& subject, tgPolygon& clip ) all_nodes.add( subject.GetNode(i) ); } + for ( unsigned int i = 0; i < clip.Contours(); ++i ) { + for ( unsigned int j = 0; j < clip.ContourSize( i ); ++j ) { + all_nodes.add( clip.GetNode(i, j) ); + } + } + ClipperLib::Polygon clipper_subject = tgContour::ToClipper( subject ); ClipperLib::Polygons clipper_clip = tgPolygon::ToClipper( clip ); ClipperLib::Polygons clipper_result; @@ -481,6 +487,12 @@ tgPolygon tgContour::Diff( const tgContour& subject, tgPolygon& clip ) for ( unsigned int i = 0; i < subject.GetSize(); ++i ) { all_nodes.add( subject.GetNode(i) ); } + + for ( unsigned int i = 0; i < clip.Contours(); ++i ) { + for ( unsigned int j = 0; j < clip.ContourSize( i ); ++j ) { + all_nodes.add( clip.GetNode(i, j) ); + } + } ClipperLib::Polygon clipper_subject = tgContour::ToClipper( subject ); ClipperLib::Polygons clipper_clip = tgPolygon::ToClipper( clip ); @@ -508,6 +520,10 @@ tgPolygon tgContour::Intersect( const tgContour& subject, const tgContour& clip all_nodes.add( subject.GetNode(i) ); } + for ( unsigned int i = 0; i < clip.GetSize(); ++i ) { + all_nodes.add( clip.GetNode(i) ); + } + ClipperLib::Polygon clipper_subject = tgContour::ToClipper( subject ); ClipperLib::Polygon clipper_clip = tgContour::ToClipper( clip ); ClipperLib::Polygons clipper_result; diff --git a/src/Lib/terragear/tg_polygon_clip.cxx b/src/Lib/terragear/tg_polygon_clip.cxx index 04b996be..e3db6c7a 100644 --- a/src/Lib/terragear/tg_polygon_clip.cxx +++ b/src/Lib/terragear/tg_polygon_clip.cxx @@ -24,6 +24,12 @@ tgPolygon tgPolygon::Union( const tgPolygon& subject, tgPolygon& clip ) } } + for ( unsigned int i = 0; i < clip.Contours(); ++i ) { + for ( unsigned int j = 0; j < clip.ContourSize( i ); ++j ) { + all_nodes.add( clip.GetNode(i, j) ); + } + } + ClipperLib::Polygons clipper_subject = tgPolygon::ToClipper( subject ); ClipperLib::Polygons clipper_clip = tgPolygon::ToClipper( clip ); ClipperLib::Polygons clipper_result; @@ -100,6 +106,12 @@ tgPolygon tgPolygon::Diff( const tgPolygon& subject, tgPolygon& clip ) } } + for ( unsigned int i = 0; i < clip.Contours(); ++i ) { + for ( unsigned int j = 0; j < clip.ContourSize( i ); ++j ) { + all_nodes.add( clip.GetNode(i, j) ); + } + } + ClipperLib::Polygons clipper_subject = tgPolygon::ToClipper( subject ); ClipperLib::Polygons clipper_clip = tgPolygon::ToClipper( clip ); ClipperLib::Polygons clipper_result; @@ -131,6 +143,12 @@ tgPolygon tgPolygon::Intersect( const tgPolygon& subject, const tgPolygon& clip } } + for ( unsigned int i = 0; i < clip.Contours(); ++i ) { + for ( unsigned int j = 0; j < clip.ContourSize( i ); ++j ) { + all_nodes.add( clip.GetNode(i, j) ); + } + } + ClipperLib::Polygons clipper_subject = tgPolygon::ToClipper( subject ); ClipperLib::Polygons clipper_clip = tgPolygon::ToClipper( clip ); ClipperLib::Polygons clipper_result; diff --git a/src/Lib/terragear/tg_polygon_tesselate.cxx b/src/Lib/terragear/tg_polygon_tesselate.cxx index 503e3b29..6a346ef5 100644 --- a/src/Lib/terragear/tg_polygon_tesselate.cxx +++ b/src/Lib/terragear/tg_polygon_tesselate.cxx @@ -128,7 +128,9 @@ void tgPolygon::Tesselate( const std::vector& extra ) tg_insert_polygon(cdt, poly); } - + /* make conforming - still has an issue, and can't be compiled with exact_construction kernel */ + // CGAL::make_conforming_Delaunay_2( cdt ); + tg_mark_domains( cdt ); int count=0;