/// <summary> /// Use for a 'step by step' search only. This method is alternate to SearchPath. /// Initializes AStar before performing search steps manually with NextStep. /// </summary> /// <exception cref="ArgumentNullException">StartNode and EndNode cannot be null.</exception> /// <param name="StartNode">The node from which the path must start.</param> /// <param name="EndNode">The node to which the path must end.</param> public void Initialize(Node StartNode, Node EndNode) { if (StartNode == null || EndNode == null) { throw new ArgumentNullException(); } _Closed.Clear(); _Open.Clear(); Track.Target = EndNode; _Open.Add(new Track(StartNode)); _NbIterations = 0; _LeafToGoBackUp = null; }
public bool ContainsPoint(List <Point2> _polygon, Point2 _target) { int len = _polygon.Count; for (int i = 0; i < len; i++) { m_rowPoints.Add(_polygon[i]); } //ShowPoints("-----polygon points-----"); m_rowPoints.Add(_target); //sort from left to right m_rowPoints.QuickSort(); //ShowPoints("-----sorted points-----"); //sweep from left to right int _bufLen = m_rowPoints.Count; bool _result = false; for (int i = 0; i < _bufLen; i++) { Point2 _pI = m_rowPoints[i]; if (_pI == _target) { _result = m_sweepLine0.InoutOf(_target) == InOut.In; break; } Point2 _pIL = _pI.m_left; Point2 _pIR = _pI.m_right; Vector2 _pIV = _pI.getValue(); Vector2 _toLeft = _pIL.getValue() - _pIV; Vector2 _toRight = _pIR.getValue() - _pIV; if (_toLeft.x > 0 && _toRight.x > 0) //Open Site,add double slope { m_sweepLine0.OpenRegion(_pI); } else if (_toLeft.x < 0 && _toRight.x < 0) //Close Site,remove double slopes { m_sweepLine0.CloseRegion(_pI, _toLeft, _toRight); } else //Turn Site,add single slope { m_sweepLine0.TurnReion(_pI); } } m_rowPoints.Clear(); m_sweepLine0.Clear(); return(_result); }
public void Clear() { foreach (var item in m_sweepRegions) { SlopeRegion.Pool.GiveBack(item); } m_sweepRegions.Clear(); }