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

Method BuildResult2

TheForceEngine/TFE_Polygon/clipper.cpp:3220–3262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3218//------------------------------------------------------------------------------
3219
3220void Clipper::BuildResult2(PolyTree& polytree)
3221{
3222 polytree.Clear();
3223 polytree.AllNodes.reserve(m_PolyOuts.size());
3224 //add each output polygon/contour to polytree ...
3225 for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++)
3226 {
3227 OutRec* outRec = m_PolyOuts[i];
3228 int cnt = PointCount(outRec->Pts);
3229 if ((outRec->IsOpen && cnt < 2) || (!outRec->IsOpen && cnt < 3)) continue;
3230 FixHoleLinkage(*outRec);
3231 PolyNode* pn = new PolyNode();
3232 //nb: polytree takes ownership of all the PolyNodes
3233 polytree.AllNodes.push_back(pn);
3234 outRec->PolyNd = pn;
3235 pn->Parent = 0;
3236 pn->Index = 0;
3237 pn->Contour.reserve(cnt);
3238 OutPt *op = outRec->Pts->Prev;
3239 for (int j = 0; j < cnt; j++)
3240 {
3241 pn->Contour.push_back(op->Pt);
3242 op = op->Prev;
3243 }
3244 }
3245
3246 //fixup PolyNode links etc ...
3247 polytree.Childs.reserve(m_PolyOuts.size());
3248 for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++)
3249 {
3250 OutRec* outRec = m_PolyOuts[i];
3251 if (!outRec->PolyNd) continue;
3252 if (outRec->IsOpen)
3253 {
3254 outRec->PolyNd->m_IsOpen = true;
3255 polytree.AddChild(*outRec->PolyNd);
3256 }
3257 else if (outRec->FirstLeft && outRec->FirstLeft->PolyNd)
3258 outRec->FirstLeft->PolyNd->AddChild(*outRec->PolyNd);
3259 else
3260 polytree.AddChild(*outRec->PolyNd);
3261 }
3262}
3263//------------------------------------------------------------------------------
3264
3265void SwapIntersectNodes(IntersectNode &int1, IntersectNode &int2)

Callers

nothing calls this directly

Calls 6

PointCountFunction · 0.85
reserveMethod · 0.80
push_backMethod · 0.80
AddChildMethod · 0.80
ClearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected