/// <summary> /// 查找最大和最小封闭区域 /// </summary> /// <param name="searchLines"></param> /// <param name="isLargeRegion"></param> /// <param name="isDecompose"></param> /// <returns></returns> public List <List <Line2D> > Lookup(List <Line2D> searchLines, bool isLargeRegion, bool isDecompose = false) { //最少有三条线,不然无法组成封闭区域 if (searchLines.Count < 3) { return(null); } List <List <Line2D> > closets = new List <List <Line2D> >(); //需要处理的所有线 List <Line2D> readyLines = new List <Line2D>(searchLines); //对线进行打断 if (isDecompose) { readyLines = GraphicAlgorithm.Decompose(readyLines); } //剔除有一个点没有连接点的点 readyLines = GraphicAlgorithm.Weed(readyLines); //去除相同的元素 readyLines = readyLines.Distinct(new Line2DEqualityComparer()).ToList(); if (readyLines == null || readyLines.Count == 0) { return(null); } List <Line2D> Large = null; //查找最大的多边形 FindMaxOne(readyLines, ref Large); if (isLargeRegion) { if (Large != null) { closets.Add(Large); } return(closets); } else { if (Large != null) { FindMins(readyLines, Large, closets); } return(closets); } }