Пример #1
0
        public bool containsWithinRange(ColoredPoint point)
        {
            foreach (ColoredPoint coloredPoint in this.vertices)
            {
                if(point.withinRoot(coloredPoint))
                {
                    return true;
                }
            }

            return false;
        }
Пример #2
0
        public bool AddVertexFromMouseClick(ColoredPoint vertex)
        {
            Triangulation triangulation = new Triangulation();
            if (this.closed == true) return false;
            if (!containsWithinRange(vertex))
            {

                if (this.vertices.Count == 0 ||
                    triangulation.noIntersection(this.vertices[0].point.X, this.vertices[0].point.Y, vertex.point.X, vertex.point.Y, this))
                {
                    vertex.index = this.vertices.Count;
                    this.vertices.Add(vertex);
                    OnPropertyChanged("vertices");
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                //if we click on the first point, then we are closing the polygon
                if (vertex.withinRoot(this.vertices[0]))
                {
                    this.closed = true;
                    OnPropertyChanged("vertices");
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }