Ejemplo n.º 1
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //每次给两条线两次相交的交点之间涂色 , 两个交点之间line1在右边则为红色 line2在右边则为绿色
        public static void Gei_Qu_Xian_De_Jiao_Dian_Nei_Bu_Tu_Se_Quicker(Color line1_color, Color line2_color, 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;

            //对两条线,每次在找到两条线的交点 后涂色
            int              j                   = 0;
            LJJSPoint        last_jiaoDian       = null;
            LJJSPoint        curr_jiaoDian       = null;
            List <LJJSPoint> part_left_list      = new List <LJJSPoint>();
            List <LJJSPoint> part_right_list     = new List <LJJSPoint>();
            bool             is_line1_bigger     = false;
            bool             curr_jiaodian_found = false;

            while (true)
            {
                part_left_list.Clear();
                part_right_list.Clear();

                //LJJSPoint jiaoDianPoint = null;
                if (j == line1.Count)
                {
                    break;
                }
                is_line1_bigger     = false;
                curr_jiaodian_found = false;
                LJJSPoint line1_point = null;
                LJJSPoint line2_point = null;
                #region

                //寻找两个曲线焦点之间的封闭区域
                for (; j < line1.Count; j++)
                {
                    line1_point = line1[j];
                    line2_point = line2[j];
                    if (line1_point.XValue > line2_point.XValue)
                    {
                        is_line1_bigger = true;

                        part_left_list.Add(line2_point);
                        part_right_list.Add(line1_point);
                    }
                    else if (line1_point.XValue < line2_point.XValue)
                    {
                        is_line1_bigger = false;
                        part_left_list.Add(line1_point);
                        part_right_list.Add(line2_point);
                    }
                    if (line1_point.XValue == line2_point.XValue && line1_point.YValue == line2_point.YValue)
                    {
                        //找到了焦点
                        curr_jiaoDian       = line1_point;
                        curr_jiaodian_found = true;
                        j++;
                        break;
                    }

                    if (j + 1 < line1.Count)
                    {
                        if ((line1_point.XValue < line2_point.XValue && line1[j + 1].XValue > line2[j + 1].XValue) || (line1_point.XValue > line2_point.XValue && line1[j + 1].XValue < line2[j + 1].XValue))
                        {  //用函数粗略找到交点坐标
                            curr_jiaoDian       = GetJiaoDIan.getjiaoDian(line1_point, line1[j + 1], line2_point, line2[j + 1]);
                            curr_jiaodian_found = true;
                            j++;
                            break;
                        }
                    }
                    //jiaodian_list.Add(line1_point);
                    //jiaodian_list.Add(line2_point);
                }
                #endregion

                Color fillColor = Color.Black;
                if (is_line1_bigger == true)
                {   //line1在右边,则填充色为 line1 线的颜色
                    fillColor = line1_color;
                }
                else
                {   //line1在左边,则填充色为 line2 线的颜色
                    fillColor = line2_color;
                }

                List <LJJSPoint> finalList = new List <LJJSPoint>();
                if (last_jiaoDian != null)
                {
                    finalList.Add(last_jiaoDian);
                }
                foreach (LJJSPoint point in part_left_list)
                {
                    finalList.Add(point);
                }
                if (curr_jiaoDian != null)
                {
                    finalList.Add(curr_jiaoDian);
                }



                if (curr_jiaodian_found == false)   //没有找到现在的焦点,构不成封闭区域
                {
                    double x = (line1[j - 1].XValue + line2[j - 1].XValue) / 2;
                    double y = line1[j - 1].YValue;
                    finalList.Add(new LJJSPoint(x, y));
                }

                for (int cc = part_right_list.Count - 1; cc >= 0; cc--)
                {
                    finalList.Add(part_right_list[cc]);
                }
                string    hatchColor = get_color_argb_by_color(fillColor).ToString();
                LJJSHatch ljjshatch  = new LJJSHatch(hatchColor, "true");
                //GAY
                MyHatch.AddAreaHatch(activeDOcu, finalList, ljjshatch);

                last_jiaoDian = curr_jiaoDian;
                curr_jiaoDian = null;
            }
        }