MCPcopy Create free account
hub / github.com/MapServer/MapServer / FixupOutPolygon

Function FixupOutPolygon

renderers/agg/src/clipper.cpp:1900–1933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1898//------------------------------------------------------------------------------
1899
1900PolyPt* FixupOutPolygon(PolyPt *p)
1901{
1902 //FixupOutPolygon() - removes duplicate points and simplifies consecutive
1903 //parallel edges by removing the middle vertex.
1904 if (!p) return 0;
1905 PolyPt *pp = p, *result = p, *lastOK = 0;
1906 for (;;)
1907 {
1908 if (pp->prev == pp || pp->prev == pp->next )
1909 {
1910 DisposePolyPts(pp);
1911 return 0;
1912 }
1913 //test for duplicate points and for same slope (cross-product) ...
1914 if ( PointsEqual(pp->pt, pp->next->pt) ||
1915 SlopesEqual(pp->prev->pt, pp->pt, pp->next->pt) )
1916 {
1917 lastOK = 0;
1918 pp->prev->next = pp->next;
1919 pp->next->prev = pp->prev;
1920 PolyPt* tmp = pp;
1921 if (pp == result) result = pp->prev;
1922 pp = pp->prev;
1923 delete tmp;
1924 }
1925 else if (pp == lastOK) break;
1926 else
1927 {
1928 if (!lastOK) lastOK = pp;
1929 pp = pp->next;
1930 }
1931 }
1932 return result;
1933}
1934//------------------------------------------------------------------------------
1935
1936void Clipper::BuildResult(Polygons &polypoly)

Callers 1

BuildResultMethod · 0.85

Calls 3

DisposePolyPtsFunction · 0.85
PointsEqualFunction · 0.85
SlopesEqualFunction · 0.85

Tested by

no test coverage detected