public SBuildStep(PathHullStack lh, PathHullStack rh, int i_b, int i_e, eBuildStep sb) { this.LH = lh; this.RH = rh; this.iB = i_b; this.iE = i_e; this.eBuild = sb; }
private void UpdateHull() { Debug.Assert(m_stack.Count > 0); Debug.Assert(m_stack.First().eBuild == eBuildStep.UpdateHull); //m_keys.Push(m_stack.First().iB); m_LHull = m_stack.First().LH; m_RHull = m_stack.First().RH; m_PHTag = m_stack.First().iB; m_stack.Pop(); }
private void Build() { Debug.Assert(m_stack.Count() > 0); Debug.Assert(m_stack.First().eBuild == eBuildStep.Build); int ib = m_stack.First().iB; int ie = m_stack.First().iE; m_stack.Pop(); m_PHTag = (ib + ie) / 2; m_LHull = new PathHullStack(Points, ib, m_PHTag, true); m_RHull = new PathHullStack(Points, m_PHTag, ie, false); }
public PathHullStack Copy() { PathHullStack ph = new PathHullStack() { }; ph.Pts = this.Pts; ph.i_Begin = this.i_Begin; ph.i_End = this.i_End; ph.HMax = this.HMax; ph.Top = this.Top; ph.Bot = this.Bot; //ph.Hp = this.Hp; ph.Elt = new int[2 * HMax]; //ph.HElt = new int[3 * HMax]; //ph.Op = new eStackOp[3 * HMax]; //for (int i = 0; i <= this.Hp; i++) { // ph.Op[i] = this.Op[i]; // ph.HElt[i] = this.HElt[i]; //} // Clone stackb var arr = new PHullOp[this.StackOp.Count]; this.StackOp.CopyTo(arr, 0); Array.Reverse(arr); ph.StackOp = new Stack <PHullOp>(arr); // Clone stacke for (int i = this.Bot; i <= this.Top; i++) { ph.Elt[i] = this.Elt[i]; } //this.Elt.CopyTo(ph.Elt, 0); //this.HElt.CopyTo(ph.HElt, 0); //this.Op.CopyTo(ph.Op, 0); ph.isLeft = this.isLeft; return(ph); }
private void AddBuildStep(PathHullStack lh, PathHullStack rh, int ib, int ie, eBuildStep eb) { m_stack.Push(new SBuildStep(lh, rh, ib, ie, eb)); }
private void DP() { double rd = 0, ld = 0, lensq = 0; int re = 0, le = 0; Debug.Assert(m_stack.Count() > 0); Debug.Assert(m_stack.First().eBuild == eBuildStep.DP); int ib = m_stack.First().iB; int ie = m_stack.First().iE; m_stack.Pop(); SHomog line = new SHomog(Points[ib], Points[ie]); lensq = Points[ib].SqrDist(Points[ie]); if ((ie - ib) < 2) { AddBuildStep(null, null, ie, ie, eBuildStep.ReturnKey); return; } this.m_LHull.Find_Extreme(line, ref le, ref ld); this.m_RHull.Find_Extreme(line, ref re, ref rd); if (ld > rd) { if (ld * ld > Tol * lensq) { PathHullStack lh = m_LHull.Copy(); PathHullStack rh = m_RHull.Copy(); lh.Split(le); //AddBuildStep(null, null, 0, 0, eBuildStep.OutputVertex); AddBuildStep(null, null, le, ie, eBuildStep.DP); AddBuildStep(lh, rh, m_PHTag, 0, eBuildStep.UpdateHull); AddBuildStep(null, null, ib, le, eBuildStep.DP); AddBuildStep(null, null, ib, le, eBuildStep.Build); //AddBuildStep(null, null, le, ie, eBuildStep.DP); return; } else { AddBuildStep(null, null, ie, ie, eBuildStep.ReturnKey); return; } } else { if (rd * rd > Tol * lensq) { if (m_PHTag != re) { m_RHull.Split(re); } AddBuildStep(null, null, re, ie, eBuildStep.DP); AddBuildStep(null, null, re, ie, eBuildStep.Build); // AddBuildStep(null, null,0, 0, eBuildStep.OutputVertex); AddBuildStep(null, null, ib, re, eBuildStep.DP); if (m_PHTag == re) { AddBuildStep(null, null, ib, re, eBuildStep.Build); } return; } else { AddBuildStep(null, null, ie, ie, eBuildStep.ReturnKey); } } //if ((ie - ib) < 8) { // rd = 0; // for (int i = ib + 1; i < ie; i++) { // ld = Math.Abs(line.DotProduct_2CH(Points[i])); // if (ld > rd) { // rd = ld; // re = i; // } // } // if (rd * rd > Tol * lensq) { // AddBuildStep(re, ie, eBuildStep.DP); // AddBuildStep(ib, re, eBuildStep.OutputVertex); // AddBuildStep(ib, re, eBuildStep.DP); // return; // } else { // AddBuildStep(ie, ie, eBuildStep.ReturnKey); // return; // } //} else { //} }