public static void Gei_Qu_Xian_De_Jiao_Dian_Nei_Bu_Tu_Se(List <LJJSPoint> line1, List <LJJSPoint> line2, LineItemStruct lineItemStruct, int index) //给曲线交点内部涂色 { if (lineItemStruct.LiSubClass.Equals("wxcs2") || lineItemStruct.LiSubClass.Equals("jgl")) { //物性指数交汇和进给量的数据有问题,其中一个在y值相同时有两个x值,另外一个比另一个多4个点 需要进行处理 if (line1.Count != line2.Count) { List <LJJSPoint> list = MsehAndMsevContainer.findLostPoints(line1, line2);//寻找多出的点 if (DrawPointContainer.list[index].JinGeiLiangList != null) { bool res1 = MsehAndMsevContainer.check_Multi_Same_YValue(line1); bool res2 = MsehAndMsevContainer.check_Multi_Same_YValue(line2); //若为true,则代表具有此list中有两个点的y值相同,x值不同,需要去掉 List <LJJSPoint> same_Y_list; if (res1 == true) { same_Y_list = MsehAndMsevContainer.same_YValue_PointsList(line1); if (same_Y_list.Count > 0) { for (int i = 0; i < same_Y_list.Count - 1; i++) { line1.Remove(same_Y_list[i]); } } } if (res2 == true) { same_Y_list = MsehAndMsevContainer.same_YValue_PointsList(line2); if (same_Y_list.Count > 0) { for (int i = 0; i < same_Y_list.Count - 1; i++) { line2.Remove(same_Y_list[i]); } } } int jingeiliang1 = line1.Count; int wxcs1 = line2.Count; foreach (LJJSPoint point in list) { line2.Remove(point); //去掉多出的点 } bool rrr = MsehAndMsevContainer.checkSameYValue_orNot(line1, line2); //检测两个list中所有的点的y值能不能对应上 if (rrr == false) //对应不上,则直接返回 { MessageBox.Show("两个曲线上的点的个数不同,错误"); MessageBox.Show(line1.Count.ToString()); MessageBox.Show(line2.Count.ToString()); return; } } //StringBuilder sb = new StringBuilder(); /**if (list != null) * { * foreach (LJJSPoint item in list) * { * sb.Append(string.Format("多出的点坐标:({0},{1})", item.XValue.ToString(), item.YValue.ToString())); * sb.Append("\r\n"); * } * } * MessageBox.Show(sb.ToString());**/ } } for (int i = 0; i < line1.Count; i++) { if (double.IsNaN(line1[i].XValue) == true || double.IsInfinity(line1[i].XValue) == true) { MessageBox.Show(string.Format("值是NaN,第{0}个", i)); } if (double.IsNaN(line2[i].XValue) == true || double.IsInfinity(line2[i].XValue) == true) { MessageBox.Show(string.Format("值是NaN,第{0}个", i)); } if (line1[i].YValue != line2[i].YValue) { MessageBox.Show("两个曲线上的点的YValue不同,错误"); return; } } //MessageBox.Show("正确,可以涂色"); vdDocument activeDOcu = DrawCommonData.activeDocument; //对两条线,每次在每条线上分别取两个点,y值可以对应上(即可以连成两条平行直线) for (int i = 0; i < line1.Count - 1; i++) { LJJSPoint line1_x1y1 = line1[i]; LJJSPoint line1_x2y2 = line1[i + 1]; LJJSPoint line2_x1y1 = line2[i]; LJJSPoint line2_x2y2 = line2[i + 1]; List <LJJSPoint> list; if (line1_x1y1.YValue == line1_x2y2.YValue && line2_x1y1.YValue == line2_x2y2.YValue) { continue; } //line1 is this.drawptcol, line2 is this.randomPointList if (line2_x2y2.XValue < line1_x2y2.XValue) { if (line2_x1y1.XValue < line1_x1y1.XValue) { list = new List <LJJSPoint>() { line2_x2y2, line1_x2y2, line1_x1y1, line2_x1y1 }; CurveColorEnum colorSelect; int colorIndex = Color.Red.ToArgb(); //颜色的argb值 double xAvg = (line1_x1y1.XValue + line1_x2y2.XValue) / 2; if (double.IsNaN(xAvg) == true || double.IsInfinity(xAvg) == true) { MessageBox.Show("xAvg是NaN"); } AddLineHatchManager.selectColorByXValue_WithoutTransition("Original", out colorSelect, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(activeDOcu, list, colorIndex, colorIndex); } else { LJJSPoint jiaodian = GetJiaoDIan.getjiaoDian(line1_x1y1, line1_x2y2, line2_x1y1, line2_x2y2); //两个三角形涂色 //第一个三角形 list = new List <LJJSPoint>() { jiaodian, line2_x1y1, line1_x1y1 }; CurveColorEnum colorSelect; int colorIndex = Color.Red.ToArgb(); //颜色的argb值 double xAvg = (jiaodian.XValue + line2_x1y1.XValue) / 2; if (double.IsNaN(xAvg) == true || double.IsInfinity(xAvg) == true) { MessageBox.Show("xAvg是NaN"); } AddLineHatchManager.selectColorByXValue_WithoutTransition("Red", out colorSelect, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(activeDOcu, list, colorIndex, colorIndex); //第二个三角形 list = new List <LJJSPoint>() { line2_x2y2, line1_x2y2, jiaodian }; colorIndex = Color.Red.ToArgb(); //颜色的argb值 xAvg = (jiaodian.XValue + line1_x2y2.XValue) / 2; if (double.IsNaN(xAvg) == true || double.IsInfinity(xAvg) == true) { MessageBox.Show("xAvg是NaN"); } AddLineHatchManager.selectColorByXValue_WithoutTransition("Original", out colorSelect, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(activeDOcu, list, colorIndex, colorIndex); } } else { if (line2_x1y1.XValue > line1_x1y1.XValue) { list = new List <LJJSPoint>() { line1_x2y2, line2_x2y2, line2_x1y1, line1_x1y1 }; CurveColorEnum colorSelect; int colorIndex = Color.Red.ToArgb(); //颜色的argb值 double xAvg = (line2_x1y1.XValue + line2_x2y2.XValue) / 2; if (double.IsNaN(xAvg) == true || double.IsInfinity(xAvg) == true) { MessageBox.Show("xAvg是NaN"); } AddLineHatchManager.selectColorByXValue_WithoutTransition("Red", out colorSelect, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(activeDOcu, list, colorIndex, colorIndex); } else { LJJSPoint jiaodian = GetJiaoDIan.getjiaoDian(line1_x1y1, line1_x2y2, line2_x1y1, line2_x2y2); //两个三角形涂色 //第一个三角形 list = new List <LJJSPoint>() { jiaodian, line1_x1y1, line2_x1y1 }; CurveColorEnum colorSelect; int colorIndex = Color.Red.ToArgb(); //颜色的argb值 double xAvg = (jiaodian.XValue + line1_x1y1.XValue) / 2; if (double.IsNaN(xAvg) == true || double.IsInfinity(xAvg) == true) { MessageBox.Show("xAvg是NaN"); } AddLineHatchManager.selectColorByXValue_WithoutTransition("Original", out colorSelect, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(activeDOcu, list, colorIndex, colorIndex); //第二个三角形 list = new List <LJJSPoint>() { line1_x2y2, line2_x2y2, jiaodian }; colorIndex = Color.Red.ToArgb(); //颜色的argb值 xAvg = (jiaodian.XValue + line2_x2y2.XValue) / 2; if (double.IsNaN(xAvg) == true || double.IsInfinity(xAvg) == true) { MessageBox.Show("xAvg是NaN"); } AddLineHatchManager.selectColorByXValue_WithoutTransition("Red", out colorSelect, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(activeDOcu, list, colorIndex, colorIndex); } } } }