Exemplo n.º 1
0
        public Relation2D(params Point2D[] points)
        {
            var point = points.Last();

            if (point == null)
            {
                throw new Exceptions.InvalidSetRelationException();
            }

            points.ToList <Point2D>().ForEach((p) => { Relatables.Add(p); });

            IIntersectable previousRelations = point.SatisfyRelations();

            IIntersectable i = Satisfy();


            if (i == null)
            {
                throw new Exceptions.InvalidSetRelationException();
            }

            IList <Point> intersect = previousRelations != null?previousRelations.Intersection(i) : null;

            if (previousRelations == null || intersect.Count() > 0)
            {
                Point?p;
                if (previousRelations == null)
                {
                    p = i.GetNearest(point.Point);
                }
                else
                {
                    p = intersect.GetNearest(point.Point);
                }


                point.Point = p != null ? p.Value : point.Point;

                foreach (Point2D pt in points)
                {
                    if (!pt.Relations2D.Contains(this))
                    {
                        pt.Relations2D.Add(this);
                    }
                }
            }
            else
            {
                throw new Exceptions.ConflictRelationException();
            }
        }
Exemplo n.º 2
0
        public Relation2D(params Point2D[] points)
        {
            var point = points.Last();

            points.ToList <Point2D>().ForEach((p) => { Relatables.Add(p); });

            IIntersectable previousRelations = point.SatisfyRelations();

            IIntersectable i         = Satisfy();
            IList <Point>  intersect = previousRelations != null?previousRelations.Intersection(i) : null;

            if (previousRelations == null || intersect.Count() > 0)
            {
                Point?p;
                if (previousRelations == null)
                {
                    p = i.GetNearest(point.Point);
                }
                else
                {
                    p = intersect.GetNearest(point.Point);
                }


                point.Point = p != null ? p.Value : point.Point;

                foreach (Point2D pt in points)
                {
                    pt.Relations2D.Add(this);
                }
            }
            else
            {
                MessageBox.Show("Current relation is in conflict with the previous relations");
                this.Dispose();
            }
        }