/// <summary> /// 删除直线中的一个结点,可能会导致直线合并 /// </summary> /// <param name="point"></param> /// <param name="p"></param> internal void DeletePoint(Point point, bool p) { List <PartitionLine> allLines = new List <PartitionLine>(HPartionLines); allLines.AddRange(VPartionLines); FindLineByPoint findByPoint = new FindLineByPoint(point); PartitionLine resultLine = allLines.Find(findByPoint.PredicatePointIn); if (resultLine != null) { resultLine.MergeByPoint(point); } }
/// <summary> /// 根据位置来分割线段 /// </summary> /// <param name="position"></param> public void PartitionByPos(int position) { Point point; if (IsRow) { point = new Point(position, Position); } else { point = new Point(Position, position); } ///如果没有孩子线段 if (this.ChildLines == null) { ChildLines = new SDLinkedList <PartitionLine>(); PartitionLine preLine = new PartitionLine(this.Start, position, this.Position, this.IsRow); PartitionLine aftLine = new PartitionLine(position, this.End, this.Position, this.IsRow); preLine.FatherLine = this; aftLine.FatherLine = this; ChildLines.AddFirst(preLine); ChildLines.AddLast(aftLine); } else { ///找到被切割的线段 FindLineByPoint findByPoint = new FindLineByPoint(point); LinkedListNode <PartitionLine> resultNode = ChildLines.Find(findByPoint.PredicatePointIn); ///在被切割的线段前后添加一线段,同时删除原线段 if (resultNode != null) { PartitionLine preLine = new PartitionLine(resultNode.Value.Start, position, resultNode.Value.Position, this.IsRow); PartitionLine aftLine = new PartitionLine(position, resultNode.Value.End, resultNode.Value.Position, this.IsRow); preLine.FatherLine = this; aftLine.FatherLine = this; ChildLines.AddBefore(resultNode, preLine); ChildLines.AddAfter(resultNode, aftLine); ChildLines.Remove(resultNode); } } }