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

Method FixupOutPolygon

TheForceEngine/TFE_Polygon/clipper.cpp:3143–3181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3141//------------------------------------------------------------------------------
3142
3143void Clipper::FixupOutPolygon(OutRec &outrec)
3144{
3145 //FixupOutPolygon() - removes duplicate points and simplifies consecutive
3146 //parallel edges by removing the middle vertex.
3147 OutPt *lastOK = 0;
3148 outrec.BottomPt = 0;
3149 OutPt *pp = outrec.Pts;
3150 bool preserveCol = m_PreserveCollinear || m_StrictSimple;
3151
3152 for (;;)
3153 {
3154 if (pp->Prev == pp || pp->Prev == pp->Next)
3155 {
3156 DisposeOutPts(pp);
3157 outrec.Pts = 0;
3158 return;
3159 }
3160
3161 //test for duplicate points and collinear edges ...
3162 if ((pp->Pt == pp->Next->Pt) || (pp->Pt == pp->Prev->Pt) ||
3163 (SlopesEqual(pp->Prev->Pt, pp->Pt, pp->Next->Pt, m_UseFullRange) &&
3164 (!preserveCol || !Pt2IsBetweenPt1AndPt3(pp->Prev->Pt, pp->Pt, pp->Next->Pt))))
3165 {
3166 lastOK = 0;
3167 OutPt *tmp = pp;
3168 pp->Prev->Next = pp->Next;
3169 pp->Next->Prev = pp->Prev;
3170 pp = pp->Prev;
3171 delete tmp;
3172 }
3173 else if (pp == lastOK) break;
3174 else
3175 {
3176 if (!lastOK) lastOK = pp;
3177 pp = pp->Next;
3178 }
3179 }
3180 outrec.Pts = pp;
3181}
3182//------------------------------------------------------------------------------
3183
3184int PointCount(OutPt *Pts)

Callers

nothing calls this directly

Calls 3

DisposeOutPtsFunction · 0.85
SlopesEqualFunction · 0.85
Pt2IsBetweenPt1AndPt3Function · 0.85

Tested by

no test coverage detected