コード例 #1
0
        private void SimpleSplit()
        {
            PartStatus left  = new PartStatus();
            PartStatus right = new PartStatus();

            foreach (ShapePoint pt in _originalPoints)
            {
                if (pt.X >= _X)
                {
                    right.Points.Add(pt);
                }
                else
                {
                    left.Points.Add(pt);
                }
            }
            if (left.Points.Count > 0)
            {
                _leftParts.Add(left);
            }
            if (right.Points.Count > 0)
            {
                _rightParts.Add(right);
            }
        }
コード例 #2
0
        private void GetActivePart(ShapePoint pt, ShapePoint prePoint)
        {
            CrossPoint crossPt = null;

            //获取跨分割线的交点
            if (prePoint != null)
            {
                crossPt = GetCrossPoint(pt, prePoint);
                if (crossPt == null)
                {
                    throw new Exception("获取一对点的交点失败。"); //不会出现这样的错误。
                }
            }
            //
            if (_activePartCollection.Count == 0)
            {
                _activePart = new PartStatus();
                _activePartCollection.Add(_activePart);
                goto endLine;
            }
            else
            {
                //获取相邻的环
                foreach (PartStatus part in _activePartCollection)
                {
                    bool isLessThan = false;
                    if (part.IsNear(crossPt.Index, out isLessThan))//相邻
                    {
                        if (_activePartCollection.Equals(_leftParts) && isLessThan)
                        {
                            _activePart = part;
                            goto endLine;
                        }
                        if ((_activePartCollection.Equals(_rightParts) && !isLessThan))
                        {
                            _activePart = part;
                            goto endLine;
                        }
                    }
                }
                _activePart = new PartStatus();
                //将新建的环加入活动环集合
                _activePartCollection.Add(_activePart);
                goto endLine;
            }
endLine:
            //将当前交点与活动环关联
            if (crossPt != null)
            {
                if (_prePartStatus != null)
                {
                    _prePartStatus.AddLinkeCrossPointIndex(crossPt.Index);
                }
            }
            _prePartStatus = _activePart;
        }
コード例 #3
0
 public void Reset(ShapePoint[] points)
 {
     _originalPoints = new List <ShapePoint>(points);
     _crossPoints.Clear();
     _X = 0;
     _currentPointIndex    = -1;
     _activePart           = null;
     _activePartCollection = null;
     _prePartStatus        = null;
 }