internal void AddIncidentEdge(ConnectionEdge next)
        {
            //var list = (List<ConnectionEdge>)Origin.DynamicProperties.GetValue(PropertyConstants.IncidentEdges);
            //list.Add(next);

            OriginIncidentEdges.Add(next);
        }
示例#2
0
        private static Boolean IsConvex(ConnectionEdge curPoint, Vector3 Normal)
        {
            Int32 orientation = GetOrientation(curPoint.Prev.Origin, curPoint.Origin, curPoint.Next.Origin,
                                               Normal);

            return(orientation == 1);
        }
        internal void Remove(ConnectionEdge cur)
        {
            cur.Prev.Next = cur.Next;
            cur.Next.Prev = cur.Prev;
            //var incidentEdges = (List<ConnectionEdge>)cur.Origin.DynamicProperties.GetValue(PropertyConstants.IncidentEdges);
            var incidentEdges = cur.OriginIncidentEdges;

            Int32 index = incidentEdges.FindIndex(x => x.Equals(cur));

            Debug.Assert(index >= 0);
            incidentEdges.RemoveAt(index);
            if (incidentEdges.Count == 0)
            {
                PointCount--;
            }
            if (cur == Start)
            {
                Start = cur.Prev;
            }
        }
示例#4
0
        private static void LinkAndAddToList(Polygon polygon,
                                             List <Vector3> points,
                                             Dictionary <Vector3, List <ConnectionEdge> > incidentEdges)
        {
            ConnectionEdge?prev = null, first = null;
            Dictionary <Vector3, Vector3> pointsHashSet = new Dictionary <Vector3, Vector3>();
            Int32 pointCount = 0;

            for (Int32 i = 0; i < points.Count; i++)
            {
                // we don't wanna have duplicates
                Vector3 p0;
                if (pointsHashSet.ContainsKey(points[i]))
                {
                    p0 = pointsHashSet[points[i]];
                }
                else
                {
                    p0 = points[i];
                    pointsHashSet.Add(p0, p0);
                    List <ConnectionEdge> list = new List <ConnectionEdge>();
                    incidentEdges[p0] = list;
                    //p0.DynamicProperties.AddProperty(PropertyConstants.IncidentEdges, list);
                    pointCount++;
                }
                ConnectionEdge current = new ConnectionEdge(p0, polygon, incidentEdges[p0]);
                first = (i == 0) ? current : first; // remember first
                if (prev != null)
                {
                    prev.Next = current;
                }
                current.Prev = prev;
                prev         = current;
            }
            first.Prev         = prev;
            prev.Next          = first;
            polygon.Start      = first;
            polygon.PointCount = pointCount;
        }
 protected Boolean Equals(ConnectionEdge other)
 {
     return(Next.Origin.Equals(other.Next.Origin) && Origin.Equals(other.Origin));
 }