private List <Line3D> GetCutRegion(List <List <Line3D> > cellList, List <Line3D> openningOutLines)
        {
            List <Line3D> resultLines = new List <Line3D>();

            foreach (List <Line3D> lines in cellList)
            {
                Vector3D centriod = GetCentriod(lines);
                int      a        = GraphicAlgorithm.InsideOfRegion(centriod, openningOutLines);
                if (a == 1)
                {
                    resultLines = lines;
                    break;
                }
            }
            return(resultLines);
        }
Пример #2
0
        /// <summary>
        /// 检测一个点是否在一个多边形内部
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InsideTestBtn_Click(object sender, RoutedEventArgs e)
        {
            List <Geometry2D> gss   = this.drawingKernel.GeometryShapes;
            List <Line2D>     lines = new List <Line2D>();

            List <Vector2D> vts = new List <Vector2D>();

            foreach (var g in gss)
            {
                if (g is PolygonGeometry)
                {
                    PolygonGeometry poly = g as DrawingKernel.Geometries.Primitives.PolygonGeometry;
                    g.FillColor = Colors.Azure;
                    g.Opacity   = 0.3;
                    poly.Update();
                    lines.AddRange(poly.Lines);
                }
                if (g is DrawingKernel.Geometries.Primitives.LineGeometry)
                {
                    DrawingKernel.Geometries.Primitives.LineGeometry l = g as DrawingKernel.Geometries.Primitives.LineGeometry;
                    vts.Add(l.Start);
                    vts.Add(l.End);
                }
                if (g.GeometryId == "tp")
                {
                    this.drawingKernel.RemoveGeometryShape(g);
                }
            }

            if (vts != null)
            {
                int resultP = 0;
                for (int i = 0; i < vts.Count; i++)
                {
                    resultP = GraphicAlgorithm.InsideOfRegion(vts[i], lines);
                    if (resultP == 0)
                    {
                        CircleGeometry c = new DrawingKernel.Geometries.Primitives.CircleGeometry();
                        c.FillColor  = Colors.Red;
                        c.Start      = vts[i];
                        c.End        = Vector2D.Create(vts[i].X + 5, vts[i].Y);
                        c.GeometryId = "tp";
                        this.drawingKernel.AddShape(c);
                    }
                    else if (resultP == 1)
                    {
                        CircleGeometry c = new DrawingKernel.Geometries.Primitives.CircleGeometry();
                        c.FillColor  = Colors.Green;
                        c.Start      = vts[i];
                        c.End        = Vector2D.Create(vts[i].X + 5, vts[i].Y);
                        c.GeometryId = "tp";
                        this.drawingKernel.AddShape(c);
                    }
                    else
                    {
                        CircleGeometry c = new DrawingKernel.Geometries.Primitives.CircleGeometry();
                        c.FillColor  = Colors.Yellow;
                        c.Start      = vts[i];
                        c.End        = Vector2D.Create(vts[i].X + 5, vts[i].Y);
                        c.GeometryId = "tp";
                        this.drawingKernel.AddShape(c);
                    }
                }
            }
        }