Exemplo n.º 1
0
        public override object Task1()
        {
            CircularLinkedList <byte> circle = new CircularLinkedList <byte>();

            for (int i = 0; i <= byte.MaxValue; i++)
            {
                circle.AddLast((byte)i);
            }

            string[] parts   = rawInput.Split(',');
            byte[]   lengths = new byte[parts.Length];
            for (int i = 0; i < parts.Length; i++)
            {
                lengths[i] = byte.Parse(parts[i]);
            }
            int totalSkips = 0;
            int skipSize   = 0;

            foreach (int l in lengths)
            {
                ReverseSegment(circle, l);
                circle.MoveHeadRight(skipSize + l);
                totalSkips += skipSize + l;
                skipSize++;
            }
            circle.MoveHeadLeft(totalSkips);

            return(circle.First.Value * circle.First.Next.Value);
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            SingleLinkedList <int>   SingleLinkedList   = new SingleLinkedList <int>();
            DoubleLinkedList <int>   doubleLinkedList   = new DoubleLinkedList <int>();
            CircularLinkedList <int> circularLinkedlist = new CircularLinkedList <int>();

            // Single linked list
            //SingleLinkedList.AddLast(10);
            //SingleLinkedList.AddFirst(5);
            //SingleLinkedList.InsertAfter(5, 8);
            //SingleLinkedList.InsertBefore(8, 6);
            //SingleLinkedList.Display();

            // Double linked list
            //doubleLinkedList.AddLast(10);
            //doubleLinkedList.AddFirst(5);
            //doubleLinkedList.InsertAfter(5, 8);
            //doubleLinkedList.InsertBefore(8, 6);
            //doubleLinkedList.Display();

            // Circular linkedlist
            circularLinkedlist.AddLast(10);
            circularLinkedlist.AddFirst(5);
            circularLinkedlist.InsertAfter(5, 8);
            circularLinkedlist.InsertBefore(8, 6);
            circularLinkedlist.Delete(6);
            circularLinkedlist.Display();

            Console.Read();
        }
Exemplo n.º 3
0
        public TFace AddFace(params TEdge[] es)
        {
            CircularLinkedList <Half> halves = new CircularLinkedList <Half>();

            es.ForEachPair(delegate(EdgeBase ea, EdgeBase eb)
            {
                Half ha = ea.half;
                Half hb = eb.half;

                Half hp = null;
                Half hq = null;

                if (ha.Target == hb.Source)
                {
                    hp = ha;
                    hq = hb;
                }
                else if (ha.pair.Target == hb.Source)
                {
                    hp = ha.pair;
                    hq = hb;
                }
                else if (ha.Target == hb.pair.Source)
                {
                    hp = ha;
                    hq = hb.pair;
                }
                else if (ha.pair.Target == hb.pair.Source)
                {
                    hp = ha.pair;
                    hq = hb.pair;
                }
                else
                {
                    throw new ArgumentException("The edges do not form a chain");
                }
                Debug.Assert(hp.Target == hq.Source);
                if (halves.Count == 0)
                {
                    halves.AddLast(hp);
                }
                halves.AddLast(hq);
            });
            TFace face = FaceFromHalfEdgeLoop(halves);

            return(face);
        }
Exemplo n.º 4
0
    /// <summary>
    /// initialise les springJoints; appelé depuis player
    /// </summary>
    public void InitPhysicRope()
    {
        Debug.Log("init rope ensuite !");
        InitPrefabsValue(true);

        enabledScript = true;
        OnlyOneMainLeft(false);
        ClearJoints(false);  //clear les joints précédents

        //cree un sprintjoint sur la première ball si il n'y en a pas déja
        objectToConnect[0].transform.GetOrAddComponent <SpringJoint>();
        listCircular.AddLast(objectToConnect[0]);

        //cree les balls intermédiaire à la bonne position par rapport aux 2 balls
        for (int i = 0; i < linkCount; i++)
        {
            if (i > linkCountMax)
            {
                break;
            }

            //cherche la position que devrais prendre ce joints
            float maxMid = linkCount + 1;

            float x1 = ((((maxMid - 1.0f) - i) / maxMid) * objectToConnect[0].transform.position.x)
                       + (((1.0f + i) / maxMid) * objectToConnect[1].transform.position.x);
            float y1 = ((((maxMid - 1.0f) - i) / maxMid) * objectToConnect[0].transform.position.y)
                       + (((1.0f + i) / maxMid) * objectToConnect[1].transform.position.y);
            float z1 = ((((maxMid - 1.0f) - i) / maxMid) * objectToConnect[0].transform.position.z)
                       + (((1.0f + i) / maxMid) * objectToConnect[1].transform.position.z);

            Vector3    posJoint = new Vector3(x1, y1, z1);
            GameObject newLink  = ObjectsPooler.Instance.SpawnFromPool(GameData.PoolTag.Link, posJoint, Quaternion.identity, parentLink);

            SetupLink(newLink, i);
            listCircular.AddLast(newLink);
        }
        //détruit le springJoint de la dernière ball si il y a
        objectToConnect[1].transform.DestroyComponent <SpringJoint>();
        listCircular.AddLast(objectToConnect[1]);

        //connecte tout les liens ensemble avec des springs joints;
        ChangeValueSpring();
        ChangeColorLink(colorRope);  //change color

        CreateFakeListForDebug();
    }
        public void AddLast()
        {
            CircularLinkedList <int> cll = new CircularLinkedList <int>();

            cll.AddLast(new CircularLinkedListNode <int>(10));
            cll.AddLast(new CircularLinkedListNode <int>(20));
            cll.AddLast(new CircularLinkedListNode <int>(30));
            cll.AddLast(new CircularLinkedListNode <int>(40));

            /*  10 -> 20 -> 30 - > 40
             *   ^                  |
             *   |__________________|        Head = 10, Tail = 40
             */

            Assert.AreEqual(cll.Head.Value, 10);
            Assert.AreEqual(cll.Tail.Value, 40);
            Assert.AreEqual(cll.Tail.Next.Value, 10);
        }
        public void List_ReturnsFalseIfElementIsNotInList()
        {
            var circular = new CircularLinkedList <string>();

            circular.AddLast("name");
            circular.AddFirst("here");

            Assert.False(circular.Contains("there"));
        }
Exemplo n.º 7
0
 // The last node is always the circular reference, but it'll suffice for the problem at hand.
 public static CircularLinkedList<int> GenerateCircularLinkedList(int size, int max)
 {
     Random rand = new Random();
     var newList = new CircularLinkedList<int>();
     for (int i = 0; i < size; i++) {
         newList.AddLast(rand.Next(0, max));
     }
     return newList;
 }
Exemplo n.º 8
0
    // Builds a circular linked list with a_iIndexesCount index, from 0 to a_iIndexesCount - 1
    private static CircularLinkedList <int> BuildContourVertexIndexesList(int a_iIndexesCount, int a_iIndexOffset)
    {
        CircularLinkedList <int> oVertexIndexesList = new CircularLinkedList <int>( );

        for (int iIndex = 0; iIndex < a_iIndexesCount; ++iIndex)
        {
            oVertexIndexesList.AddLast(iIndex + a_iIndexesCount);
        }

        return(oVertexIndexesList);
    }
        public void Check_Current_on_First()
        {
            CircularLinkedList <string> cllString = new CircularLinkedList <string>();

            cllString.AddFirst("abc");
            cllString.AddFirst("def");
            cllString.AddLast("xyz");
            var ci = cllString.GetCircularIterator();

            Assert.Equal("def", ci.Current());
        }
Exemplo n.º 10
0
        public override object Task1()
        {
            CircularLinkedList <char> programs = new CircularLinkedList <char>();

            for (char i = 'a'; i <= 'p'; i++)
            {
                programs.AddLast(i);
            }

            ApplyDance(programs);
            return(string.Join("", programs));
        }
        public void List_MakesFirstNodeHeadTailAndCyclicUsingAddLast()
        {
            var circular = new CircularLinkedList <int>();

            circular.AddLast(30);
            var cyclic = circular.GetNodeWhereCycleBegins();

            Assert.Equal(1, circular.Size);
            Assert.Equal(30, circular.HeadNode.Value);
            Assert.Equal(30, circular.TailNode.Value);
            Assert.Equal(30, cyclic.Value);
        }
Exemplo n.º 12
0
        public void TestCircularLinkedList()
        {
            CircularLinkedList <int> circularLinkedlist = new CircularLinkedList <int>();

            circularLinkedlist.AddLast(10);
            circularLinkedlist.AddFirst(5);
            circularLinkedlist.InsertAfter(5, 8);
            circularLinkedlist.InsertBefore(8, 6);
            circularLinkedlist.Delete(6);
            //circularLinkedlist.Display();

            Assert.IsTrue(circularLinkedlist.Head.Next.Data == 5);
        }
Exemplo n.º 13
0
        public TradeBuilderForm()
        {
            InitializeComponent();

            api = APIMain.Instance;

            this.DialogResult = DialogResult.Abort;

            initialTradeNameText = txtTradeName.Text;
            // Default to a buy-side entry.
            entrySide = zBuySell.Buy;

            tradeStepPanels = new CircularLinkedList <TradeRulePanelControl>();
            tradeStepPanels.AddFirst(panelPreconditions);
            tradeStepPanels.AddLast(panelStop);
            tradeStepPanels.AddLast(panelExit);
            tradeStepPanels.AddLast(panelEntry);

            ChangeActivePanel(tradeStepPanels.Head);

            ruleChooserForm             = new RuleChooserForm(this);
            ruleChooserForm.RuleSelect += ruleChooserForm_RuleSelect;
        }
Exemplo n.º 14
0
        public override object Task1()
        {
            int rotationSteps = int.Parse(rawInput);
            CircularLinkedList <int> circle = new CircularLinkedList <int>();

            circle.AddLast(0);
            for (int i = 1; i < 2018; i++)
            {
                circle.MoveHeadRight(rotationSteps);
                circle.AddAfter(circle.First, i);
                circle.MoveHeadRight(1);
            }

            return(circle.First.Next.Value);
        }
Exemplo n.º 15
0
        private AngularBisectorNetwork(IEnumerable <Point2D> points, bool closed)
        {
            queueDictionary = PriorityQueueDictionary <double, Intersection> .CreateLowFirstOut();

            // TODO: Throw an exception on duplicate points
            foreach (Point2D point in points)
            {
                skeleton.Add(new BisectorVertex(point));
            }

            // 1. Initialization
            //  a. Organize the given vertices into one double connected list of active vertices (LAV)
            //     stored in the SLAV. The vertices in LAV are all active at the moment.
            CircularLinkedList <Vertex> lav = CreateLav(closed);

            foreach (Point2D point in points)
            {
                lav.AddLast(new Vertex(point));
            }

            // b. For each vertex Vi in LAV add the pointer to to incident edges ei-1 = Vi-1 Vi
            //    band ei = Vi Vi+1 and compute the vertex angle bisector (ray) bi
            InitializeEdges(lav);
            InitalizeBisectors(lav);

            // c. For each vertex Vi compute the nearer intersection of the bisector bi with the adjacent
            //    vertex bisectors bi-1 and bi+1 starting at the neighbouring vertices Vi-1 Vi+1 and (if
            //    it exists) store it into a priority queue according to the distance to the line L(ei) which
            //    holds edge ei. For each intersection point store references to Va and Vb, the two origins of
            //    the bisectors which have created the intersection point.
            FindFirstIntersections(lav);

            // 2. While the priority queue with the intersection points is not empty process the intersection
            //    points to find futher intersections, until all intersecting bisectors have been processed.
            ProcessIntersections();

            // Add infinite rays from any unprocesseed points remaining
            // TODO: foreach lav in slav
            foreach (Vertex v in lav)
            {
                if (!v.processed)
                {
                    AddTerminalRay(v);
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Add the face described by the supplied vertices in either a clockwise or anticlockwise
        /// order. Note that they may be in a reversed order of the resulting face.
        /// </summary>
        /// <param name="vs">A complete list of vertices surrounding a proposed face.</param>
        /// <exception cref="ArgumentException">Thrown if the vertices do not propose a face
        /// which can be legalling inserted into the mesh.</exception>
        /// <returns>The new face</returns>
        public TFace AddFace(IEnumerable <TVertex> vs)
        {
            CircularLinkedList <Half> halves = new CircularLinkedList <Half>();

            vs.Wrap().ForEachPair(delegate(TVertex va, TVertex vb)
            {
                // Locate a half-edge directed between va and vb
                Half half = va.FindHalfEdge(h => h.Target == vb);
                if (half == null)
                {
                    throw new ArgumentException("No half-edge exists between successive vertices");
                }
                halves.AddLast(half);
            });
            TFace face = FaceFromHalfEdgeLoop(halves);

            return(face);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Given a half-edge, trace half-edges head to tail through the mesh
        /// to find closed loops of half-edges.
        /// </summary>
        /// <param name="incidentHalf">The half edge at which tracing should begin</param>
        /// <returns>A circular linked list of half-edges which form a loop</returns>
        private static CircularLinkedList <Half> TraceHalfLoop(Half incidentHalf)
        {
            CircularLinkedList <Half> halfLoop = new CircularLinkedList <Half>();
            Half begin   = incidentHalf;
            Half current = begin;

            do
            {
                if (current == null)
                {
                    throw new IncompleteHalfLoopException();
                }
                Debug.Assert(current != null);
                halfLoop.AddLast(current);
                current = current.next;
            }while (current != begin);
            return(halfLoop);
        }
Exemplo n.º 18
0
            public KnotHash(string input)
            {
                byte[] byteString = Encoding.ASCII.GetBytes(input);
                byte[] lengths    = new byte[byteString.Length + suffix.Length];
                Array.Copy(byteString, lengths, input.Length);
                Array.Copy(suffix, 0, lengths, byteString.Length, suffix.Length);

                CircularLinkedList <byte> circle = new CircularLinkedList <byte>();

                for (int i = 0; i <= byte.MaxValue; i++)
                {
                    circle.AddLast((byte)i);
                }

                TieKnot(circle, lengths, 64);

                DenseHash = MakeDenseHash(circle.ToArray());
                HashCode  = MakeHashCode(DenseHash);
            }
Exemplo n.º 19
0
    // Builds and return a list of vertex indexes that are ear tips.
    private static CircularLinkedList <int> BuildEarTipVerticesList(Vector3[] a_rMeshVertices, CircularLinkedList <int> a_rOuterContourVertexIndexesList, LinkedList <int> a_rReflexVertexIndexesList, LinkedList <int> a_rConvexVertexIndexesList)
    {
        CircularLinkedList <int> oEarTipVertexIndexesList = new CircularLinkedList <int>( );

        // Iterate convex vertices
        for (LinkedListNode <int> rConvexIndexNode = a_rConvexVertexIndexesList.First; rConvexIndexNode != null; rConvexIndexNode = rConvexIndexNode.Next)
        {
            // The convex vertex index
            int iConvexContourVertexIndex = rConvexIndexNode.Value;

            // Is the convex vertex is an ear tip?
            if (IsEarTip(a_rMeshVertices, iConvexContourVertexIndex, a_rOuterContourVertexIndexesList, a_rReflexVertexIndexesList) == true)
            {
                // Yes: adds it to the list
                oEarTipVertexIndexesList.AddLast(iConvexContourVertexIndex);
            }
        }

        // Return the ear tip list
        return(oEarTipVertexIndexesList);
    }
Exemplo n.º 20
0
        /* Rather than keep the head on the elf who's turn it is, it is faster
         * and easier to keep track of which elf is being eliminated
         */
        public override object Task2()
        {
            int numElves = int.Parse(rawInput);
            CircularLinkedList <int> elves = new CircularLinkedList <int>();

            for (int i = 1; i <= numElves; i++)
            {
                elves.AddLast(i);
            }

            elves.MoveHeadRight(numElves / 2);

            while (elves.Count > 1)
            {
                elves.Remove(elves.First);
                if (elves.Count % 2 == 0)
                {
                    elves.MoveHeadRight(1);
                }
            }
            return(elves.First.Value);
        }
 private void AddLast(CircularLinkedList <int[]> list)
 {
     list.AddLast(new int[] { 3390, 2200, 1100, 1290, 4330, 2130 });
 }
 private void AddLast(CircularLinkedList <char> list)
 {
     list.AddLast('~');
 }
 private void AddLast(CircularLinkedList <string> list)
 {
     list.AddLast("Jimmy Tau");
 }
 // Testing the AddLast method.
 private void AddLast(CircularLinkedList <int> list)
 {
     list.AddLast(1000);
 }
        /// <summary>
        /// Setup all the necessary lists for the algorithm to work 
        /// </summary>
        private void setup()
        {
            //initialize SLAV
            SLAV = new List<CircularLinkedList<Vertex>>();

            //initialize priority queue Q
            Q = new HeapPriorityQueue<Event>(500);

            //initialize first LAV
            CircularLinkedList<Vertex> LAV = new CircularLinkedList<Vertex>();
            for (int i = 0; i < polygon.ControlVertices.Count; i++)
            {
                //Create vertex for each controlpoint and store edges + calc bisector ray
                Vertex vertex = new Vertex(polygon.ControlVertices[i], id++);
                vertex.prevEdge = new Edge(polygon.ControlVertices.PreviousVertex(i), vertex.getPoint());
                vertex.nextEdge = new Edge(vertex.getPoint(), polygon.ControlVertices.NextVertex(i));
                vertex.update();

                //Add them to initial LAV
                LAV.AddLast(vertex);
            }

            SLAV.Add(LAV);

            //initial event creation
            testDots = new List<OwnVector2>();
            for(int i = 0; i < LAV.Count; i++)
            {
                Vertex prev = LAV[i].Previous.Value;
                Vertex current = LAV[i].Value;
                Vertex next = LAV[i].Next.Value;

                findClosestIntersectionAndStore(LAV, prev, current, next);
            }
        }
Exemplo n.º 26
0
 public Window AddControl(IControl control)
 {
     controls.AddLast(control);
     return(this);
 }
Exemplo n.º 27
0
        private static void MakeEnterExitList(CircularLinkedList<Vector2> subject,
                                                CircularLinkedList<Vector2> clip,
                                                Dictionary<Vector2, Pair<Vector2>> intersections,
                                                CircularLinkedList<Vector2> entering,
                                                CircularLinkedList<Vector2> exiting)
        {
            LinkedListNode<Vector2> curr = subject.First;
            while (curr != subject.Last)
            {
                if (intersections.ContainsKey(curr.Value))
                {
                    bool isEntering = Vector2Cross(curr.Next.Value.X - curr.Previous.Value.X,
                                                  curr.Next.Value.Y - curr.Previous.Value.Y,
                                                  intersections[curr.Value].Second.X - intersections[curr.Value].First.X,
                                                  intersections[curr.Value].Second.Y - intersections[curr.Value].First.Y) < 0;

                    if (isEntering)
                        entering.AddLast(curr.Value);
                    else
                        exiting.AddLast(curr.Value);
                }

                curr = curr.Next;
            }
        }
Exemplo n.º 28
0
            public override void ModifyLav(AngularBisectorNetwork network)
            {
                Debug.Assert(nodeV.List != null);
                CircularLinkedList <Vertex> lav1 = nodeV.List;
                //    * Create two new nodes V1 and V2 with the same co-ordinates as the intersection point I
                CircularLinkedListNode <Vertex> nodeV1 = new CircularLinkedListNode <Vertex>(new Vertex(this.Position));
                CircularLinkedListNode <Vertex> nodeV2 = new CircularLinkedListNode <Vertex>(new Vertex(this.Position));

                //    * Search the opposite edge in SLAV sequentially
                CircularLinkedListNode <Vertex> oppositeNode = lav1.FindPair(delegate(Vertex va, Vertex vb)
                {
                    // Ignore testing againt the in and out edges of V
                    if (va == V || vb == V)
                    {
                        return(false);
                    }

                    // and the candiate "opposite" line
                    Line2D oppositeLine = new Line2D(va.outEdge.source.Position, va.outEdge.target.Position);

                    // TODO: Check which way round these lines are - so the the positive side defines our zone of interest
                    Line2D oppositeBoundary1 = va.Bisector.SupportingLine.Opposite;
                    Line2D oppositeBoundary2 = vb.Bisector.SupportingLine;

                    OrientedSide sideA = oppositeBoundary1.Side(this.Position);
                    OrientedSide sideB = oppositeLine.Side(this.Position);
                    OrientedSide sideC = oppositeBoundary2.Side(this.Position);
                    //return sideA == OrientedSide.Negative && sideB == OrientedSide.Negative && sideC == OrientedSide.Negative;
                    return(sideA == OrientedSide.Negative && sideB == OrientedSide.Negative && sideC == OrientedSide.Negative);
                });

                // TODO: Is this legitimate?
                if (oppositeNode == null)
                {
                    Debug.Assert(false);
                    return;
                }

                // oppositeNode is Y in the paper
                Debug.Assert(oppositeNode != null);

                //    * insert both new nodes into the SLAV (break one LAV into two parts). Vertex V1 will be
                //      interconnected between the predecessor of V and the vertex/node which is an end point of
                //      the opposite line segment. V2 will be connected between the successor of V and the vertex/
                //      node which is a starting point of the opposite line segment.  This step actually splits the
                //      polygon shape into two parts.

                // Set up nodes according to the naming conventions in the Felkel et al paper.
                CircularLinkedListNode <Vertex> nodeY = oppositeNode;
                CircularLinkedListNode <Vertex> nodeX = oppositeNode.Next;
                CircularLinkedListNode <Vertex> nodeM = nodeV.Previous;
                CircularLinkedListNode <Vertex> nodeN = nodeV.Next;

                // The LinkedList is split into two parts.  The first part remains in the original list,
                // the second part is placed into a new list.
                CircularLinkedList <Vertex> lav2 = network.CreateLav();

                // We search the list for either M or Y, whichever comes first. This tells us which
                // algorithm to use to split the lav in two.
                CircularLinkedListNode <Vertex> found = lav1.FindNode(node => node == nodeM || node == nodeY);

                lav1.Remove(nodeV);



                // Splice nodes from lav1 into lav2
                Debug.Assert(found != null);
                if (found == nodeY)
                {
                    // Splice two sections of lav1 into lav2 with V1 and V2
                    // TODO: We have four nodes in a linked list defining two ranges First--->Y and N--->Last
                    //       These ranges may be non-overlapping, or may be overlapping in some way. e.g. Y may come after N.
                    //       1) Find none overlapping range or ranges
                    //       2) Copy the range(s) to lav2
                    //       3) Insert nodeV2 into the correct place in lav2 after Y

                    // Another alternative 2

                    // 1. Is the break in the list between N and Y?
                    bool continuousNY = null != lav1.FindNodeFrom(nodeN, node => node == nodeY);
                    if (continuousNY)
                    {
                        lav2.AddLast(nodeV2);
                        lav2.SpliceLast(nodeN, nodeY);
                        lav2.IsCircular = true;
                    }
                    else // !continuousNY
                    {
                        lav2.SpliceLast(lav1.First, nodeY);
                        lav2.AddLast(nodeV2);
                        lav2.SpliceLast(nodeN, lav1.Last);
                        lav2.IsCircular = lav1.IsCircular;
                    }

                    // Alternative approach

                    //// 1. Remember whether lav1 is circular
                    //bool lav1Circularity = lav1.IsCircular;

                    //// 1a. Determine whether lav2 should be circular- by whether it is continuous between nodeN and nodeY
                    //bool continuousNY = null != lav1.FindNodeFrom(nodeN, node => node == nodeY);
                    //bool lav2Circularity = lav1Circularity || continuousNY;

                    //// 2. Make lav1 circular, so we can safely iterate from N to Y irrespective of the location of the list head
                    //lav1.IsCircular = true;

                    //// 3. Add nodeV2 into lav2
                    //lav2.AddLast(nodeV2);

                    //// 4. Splice from N to Y into Lav2
                    //lav2.SpliceLast(nodeN, nodeY);

                    //// 5. Restore the circularity of lav1 and lav2
                    //lav1.IsCircular = lav1Circularity;
                    //lav2.IsCircular = lav2Circularity;

                    // X--->M->V1
                    if (lav1.Count > 0) // <--- Is this needed?
                    {
                        Debug.Assert(lav1.First == nodeX);
                        Debug.Assert(lav1.Last == nodeM);
                        lav1.AddLast(nodeV1);
                        lav1.IsCircular = true;
                    }
                }
                else
                {
                    Debug.Assert(found == nodeM);
                    // Splice one section of lav1 into lav2
                    // N--->Y->V2
                    lav2.SpliceFirst(nodeN, nodeY);
                    lav2.AddLast(nodeV2);

                    // First--->M->V2->X--->Last
                    if (lav1.Count > 0)
                    {
                        Debug.Assert(nodeM.Next == nodeX);
                        lav1.AddAfter(nodeM, nodeV1);
                    }
                }

                //    * link the new nodes V1 and V2 with the appropriate edges
                nodeV1.Value.inEdge  = V.inEdge;
                nodeV1.Value.outEdge = nodeY.Value.outEdge;

                nodeV2.Value.inEdge  = nodeY.Value.outEdge;
                nodeV2.Value.outEdge = V.outEdge;

                // f. for both nodes V1 and V2:

                //     * compute the new angle bisectors betwenne the line segment linked to them is step 2e
                nodeV1.Value.Bisector = new Ray2D(nodeV1.Value.Bisector.Source, AngularBisector(nodeV1.Value.inEdge, nodeV1.Value.outEdge));
                nodeV2.Value.Bisector = new Ray2D(nodeV2.Value.Bisector.Source, AngularBisector(nodeV2.Value.inEdge, nodeV2.Value.outEdge));

                //     * compute the intersections of these bisectors with the bisectors starting at their neighbour
                //       vertices according to the LAVs (e.g. at points N and Y and M and X in fig 6a.), the same
                //       way as in step 1c. New intersection points of both types may occur
                //     * store the nearest intersection into the priority queue
                //       TODO: [ Does this mean the nearest for V1 and the nearest for V2, or only the nearest of them both? ]
                network.EnqueueNearestBisectorIntersection(lav1, nodeV1);
                network.EnqueueNearestBisectorIntersection(lav2, nodeV2);
            }
	// Builds a circular linked list with a_iIndexesCount index, from 0 to a_iIndexesCount - 1
	private static CircularLinkedList<int> BuildContourVertexIndexesList( int a_iIndexesCount, int a_iIndexOffset )
	{
		CircularLinkedList<int> oVertexIndexesList = new CircularLinkedList<int>( );

		for( int iIndex = 0; iIndex < a_iIndexesCount; ++iIndex )
		{
			oVertexIndexesList.AddLast( iIndex + a_iIndexesCount );
		}

		return oVertexIndexesList;
	}
Exemplo n.º 30
0
 // Add a contour vertex to the list
 public void AddLast(Vector2 a_f2ContourVertex)
 {
     m_oContourVertices.AddLast(a_f2ContourVertex);
 }
Exemplo n.º 31
0
        static void Main(string[] args)
        {
            //Vector3 a = new Vector3(0, 1, 0);
            //Vector3 b = new Vector3(1, 0, 0);
            //Console.WriteLine(Vector3.Cross(a, b));

            CircularLinkedList<Vector2> subject = new CircularLinkedList<Vector2>();
            CircularLinkedList<Vector2> clip = new CircularLinkedList<Vector2>();

            //#region Big and small square
            //subject.AddLast(new Vector2(0, 0));
            //subject.AddLast(new Vector2(0, 4));
            //subject.AddLast(new Vector2(4, 4));
            //subject.AddLast(new Vector2(4, 0));
            //subject.AddLast(new Vector2(0, 0));

            //clip.AddLast(new Vector2(4, 1));
            //clip.AddLast(new Vector2(4, 3));
            //clip.AddLast(new Vector2(6, 3));
            //clip.AddLast(new Vector2(6, 1));
            //clip.AddLast(new Vector2(4, 1));
            //#endregion

            //#region Shared edge
            //subject.AddLast(new Vector2(0, 0));
            //subject.AddLast(new Vector2(0, 1));
            //subject.AddLast(new Vector2(1, 0));
            //subject.AddLast(new Vector2(0, 0));

            //clip.AddLast(new Vector2(0, 1));
            //clip.AddLast(new Vector2(1, 1));
            //clip.AddLast(new Vector2(1, 0));
            //clip.AddLast(new Vector2(0, 1));
            //#endregion

            //#region Triangle and polygon
            //subject.AddLast(new Vector2(-3, 1));
            //subject.AddLast(new Vector2(2, 2));
            //subject.AddLast(new Vector2(2, -3));
            //subject.AddLast(new Vector2(-3, 1));

            //clip.AddLast(new Vector2(1, -1));
            //clip.AddLast(new Vector2(5, -1));
            //clip.AddLast(new Vector2(2, -5));
            //clip.AddLast(new Vector2(-6, 3));
            //clip.AddLast(new Vector2(1, 1));
            //clip.AddLast(new Vector2(3, 0));
            //clip.AddLast(new Vector2(1, -1));
            //#endregion

            //#region Simple triangles
            //subject.AddLast(new Vector2(-2, 0));
            //subject.AddLast(new Vector2(1, 1));
            //subject.AddLast(new Vector2(-1, -2));
            //subject.AddLast(new Vector2(-2, 0));

            //clip.AddLast(new Vector2(-1, -1));
            //clip.AddLast(new Vector2(1, 0));
            //clip.AddLast(new Vector2(1, -2));
            //clip.AddLast(new Vector2(-1, -1));
            //#endregion

            //#region Two equal
            //subject.AddLast(new Vector2(0, 0));
            //subject.AddLast(new Vector2(0, 1));
            //subject.AddLast(new Vector2(1, 0));
            //subject.AddLast(new Vector2(0, 0));

            //clip.AddLast(new Vector2(0, 0));
            //clip.AddLast(new Vector2(0, 1));
            //clip.AddLast(new Vector2(1, 0));
            //clip.AddLast(new Vector2(0, 0));
            //#endregion

            //#region Two triangles 1
            //subject.AddLast(new Vector2(-3, 0));
            //subject.AddLast(new Vector2(0, 3));
            //subject.AddLast(new Vector2(3, 0));
            //subject.AddLast(new Vector2(-3, 0));

            //clip.AddLast(new Vector2(-2, 1));
            //clip.AddLast(new Vector2(2, 1));
            //clip.AddLast(new Vector2(0, -1));
            //clip.AddLast(new Vector2(-2, 1));
            //#endregion

            //#region Two triangles 2
            //subject.AddLast(new Vector2(-3, 0));
            //subject.AddLast(new Vector2(0, 3));
            //subject.AddLast(new Vector2(3, 0));
            //subject.AddLast(new Vector2(-3, 0));

            //clip.AddLast(new Vector2(-2, 2));
            //clip.AddLast(new Vector2(2, 2));
            //clip.AddLast(new Vector2(0, 0));
            //clip.AddLast(new Vector2(-2, 2));
            //#endregion

            #region Second touches 2 sides from inside and exit through third side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-2, 1));
            clip.AddLast(new Vector2(2, 1));
            clip.AddLast(new Vector2(0, -1));
            clip.AddLast(new Vector2(-2, 1));

            Draw(subject, clip, "Second touches 2 sides from inside and exit through third side");
            #endregion

            #region Second touches 1 side from inside and exit through other sides
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-2, 2));
            clip.AddLast(new Vector2(2, 2));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(-2, 2));

            Draw(subject, clip, "Second touches 1 side from inside and exit through other sides");
            #endregion

            #region Second touches 1 side from inside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-1, 1));
            clip.AddLast(new Vector2(1, 1));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(-1, 1));

            Draw(subject, clip, "Second touches 1 side from inside");
            #endregion

            #region Second partially overlays 2 sides from same vertex
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(-1, 2));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second partially overlays 2 sides from same vertex");
            #endregion

            #region Second partially overlays 1 side from vertex and totally overlays other side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(1, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second partially overlays 1 side from vertex and totally overlays other side");
            #endregion

            #region Second partially overlays 1 side and touches other side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-2, 1));
            clip.AddLast(new Vector2(-1, 2));
            clip.AddLast(new Vector2(-1, 0));
            clip.AddLast(new Vector2(-2, 1));

            Draw(subject, clip, "Second partially overlays 1 side and touches other side");
            #endregion

            #region Second partially overlays 1 side and touches other vertex
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-1, 0));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(1, 0));
            clip.AddLast(new Vector2(-1, 0));

            Draw(subject, clip, "Second partially overlays 1 side and touches other vertex");
            #endregion

            #region Second partially overlays 1 side from inside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-2, 1));
            clip.AddLast(new Vector2(-1, 2));
            clip.AddLast(new Vector2(-1, 1));
            clip.AddLast(new Vector2(-2, 1));

            Draw(subject, clip, "Second partially overlays 1 side from inside");
            #endregion

            #region Second touches every side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-1, 2));
            clip.AddLast(new Vector2(1, 2));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(-1, 2));

            Draw(subject, clip, "Second touches every side");
            #endregion

            #region Second totally overlays 1 side from inside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 2));
            clip.AddLast(new Vector2(3, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second totally overlays 1 side from inside");
            #endregion

            #region Second touches 2 sides from inside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-1, 2));
            clip.AddLast(new Vector2(1, 1));
            clip.AddLast(new Vector2(-1, 0));
            clip.AddLast(new Vector2(-1, 2));

            Draw(subject, clip, "Second touches 2 sides from inside");
            #endregion

            #region Second totally overlays 1 side from outside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(3, 0));
            clip.AddLast(new Vector2(0, -3));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second totally overlays 1 side from outside");
            #endregion

            #region Second partially overlays 1 side from vertex from outside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(-1, -2));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second partially overlays 1 side from vertex from outside");
            #endregion

            #region Second partially overlays 1 side from outside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-2, 0));
            clip.AddLast(new Vector2(2, 0));
            clip.AddLast(new Vector2(0, -2));
            clip.AddLast(new Vector2(-2, 0));

            Draw(subject, clip, "Second partially overlays 1 side from outside");
            #endregion

            #region Second touches 1 side from outside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-1, -2));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(1, -2));
            clip.AddLast(new Vector2(-1, -2));

            Draw(subject, clip, "Second touches 1 side from outside");
            #endregion

            #region Second completely inside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-4, 0));
            subject.AddLast(new Vector2(0, 4));
            subject.AddLast(new Vector2(4, 0));
            subject.AddLast(new Vector2(-4, 0));

            clip.AddLast(new Vector2(-1, 2));
            clip.AddLast(new Vector2(1, 2));
            clip.AddLast(new Vector2(0, 1));
            clip.AddLast(new Vector2(-1, 2));

            Draw(subject, clip, "Second completely inside");
            #endregion

            #region Second touches 1 side and exits from another side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 1));
            clip.AddLast(new Vector2(-1, 3));
            clip.AddLast(new Vector2(-1, 0));
            clip.AddLast(new Vector2(-3, 1));

            Draw(subject, clip, "Second touches 1 side and exits from another side");
            #endregion

            #region Second touches 2 sides and exits from another side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 2));
            clip.AddLast(new Vector2(-1, 2));
            clip.AddLast(new Vector2(-1, 0));
            clip.AddLast(new Vector2(-3, 2));

            Draw(subject, clip, "Second touches 2 sides and exits from another side");
            #endregion

            #region Second touches 1 side and intersects same side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-2, 2));
            clip.AddLast(new Vector2(-1, 2));
            clip.AddLast(new Vector2(-1, 1));
            clip.AddLast(new Vector2(-2, 2));

            Draw(subject, clip, "Second touches 1 side and intersects same side");
            #endregion

            #region Second touches 1 vertex from outside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(3, 0));
            clip.AddLast(new Vector2(4, 1));
            clip.AddLast(new Vector2(4, -1));
            clip.AddLast(new Vector2(3, 0));

            Draw(subject, clip, "Second touches 1 vertex from outside");
            #endregion

            #region Second touches 1 vertex from inside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-1, 1));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(1, 1));
            clip.AddLast(new Vector2(-1, 1));

            Draw(subject, clip, "Second touches 1 vertex from inside");
            #endregion

            #region Second partially overlays 1 side from vertex and exits from another vertex
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 4));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second partially overlays 1 side from vertex and exits from another vertex");
            #endregion

            #region Second touches 1 vertex from inside and intersects other vertex of the same side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 4));
            clip.AddLast(new Vector2(0, 2));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second touches 1 vertex from inside and intersects other vertex of the same side");
            #endregion

            #region Second touches 1 vertex from inside and intersects other vertex of the same side and intersects adjacent side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 4));
            clip.AddLast(new Vector2(0, -1));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second touches 1 vertex from inside and intersects other vertex of the same side and intersects adjacent side");
            #endregion

            #region Second touches 1 vertex from outside and shares 1 vertex
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 1));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(3, 3));
            clip.AddLast(new Vector2(3, -1));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second touches 1 vertex from outside and shares 1 vertex");
            #endregion

            #region Second touches 1 vertex from inside and shares 1 vertex
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-1, 1));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(-1, 1));

            Draw(subject, clip, "Second touches 1 vertex from inside and shares 1 vertex");
            #endregion

            #region Triangles are equal
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(3, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Triangles are equal");
            #endregion

            #region Second has 2 shared vertices and intersects 1 side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(-2, 2));
            clip.AddLast(new Vector2(3, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second has 2 shared vertices and intersects 1 side");
            #endregion

            #region Second touches 2 sides and last vertex outside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-2, 1));
            clip.AddLast(new Vector2(0, 4));
            clip.AddLast(new Vector2(2, 1));
            clip.AddLast(new Vector2(-2, 1));

            Draw(subject, clip, "Second touches 2 sides and last vertex outside");
            #endregion

            #region Second has 2 shared vertices and last vertex outside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 2));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(3, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second has 2 shared vertices and last vertex outside");
            #endregion

            #region Second has 2 shared vertices and 1 side of first partially overlays second side from vertex
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(1, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(3, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second has 2 shared vertices and 1 side of first partially overlays second side from vertex");
            #endregion

            #region Second partially overlays one side with shared vertex and stays inside forever
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 2));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second partially overlays one side with shared vertex and stays inside forever");
            #endregion

            #region Second partially overlays one side with shared vertex and exits through side with shared vertex
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(-2, 2));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second partially overlays one side with shared vertex and exits through side with shared vertex");
            #endregion

            #region Second partially overlays one side with shared vertex and exits through side without shared vertex
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 4));
            clip.AddLast(new Vector2(2, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second partially overlays one side with shared vertex and exits through side without shared vertex");
            #endregion

            #region Second partially overlays one side with shared vertex and touches opposite side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(1, 2));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second partially overlays one side with shared vertex and touches opposite side");
            #endregion

            #region Second has 1 shared vertex, second vertex touches opposite side and sides intersect
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-2, 3));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(-2, 3));

            Draw(subject, clip, "Second has 1 shared vertex, second vertex touches opposite side and sides intersect");
            #endregion

            #region Second has 1 shared vertex, second vertex touches opposite side, third vertex outside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 1));
            subject.AddLast(new Vector2(2, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 2));
            clip.AddLast(new Vector2(1, 0.5f));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second has 1 shared vertex, second vertex touches opposite side, third vertex outside");
            #endregion

            #region Second has 1 shared vertex and opposite side intersects adjacent side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-2, 2));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(-1, 1));
            clip.AddLast(new Vector2(-2, 2));

            Draw(subject, clip, "Second has 1 shared vertex and opposite side intersects adjacent side");
            #endregion

            #region Second has 1 shared vertex, opposite side intersects 2 sides, adjacent side intersects 1 side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(-2, 2));
            clip.AddLast(new Vector2(2, 2));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second has 1 shared vertex, opposite side intersects 2 sides, adjacent side intersects 1 side");
            #endregion

            #region Second has 1 shared vertex and intersects both adjacent sides
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-2, 2));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(2, 2));
            clip.AddLast(new Vector2(-2, 2));

            Draw(subject, clip, "Second has 1 shared vertex and intersects both adjacent sides");
            #endregion

            #region Second has 1 shared vertex and intersects adjacent side and opposite side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 2));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(2, -1));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second has 1 shared vertex and intersects adjacent side and opposite side");
            #endregion

            #region Second has 1 shared vertex and lays completely inside
            subject.Clear();
            clip.Clear();

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(3, 0));
            clip.AddLast(new Vector2(-3, 0));

            subject.AddLast(new Vector2(-1, 1));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(1, 1));
            subject.AddLast(new Vector2(-1, 1));

            Draw(subject, clip, "Second has 1 shared vertex and lays completely inside");
            #endregion

            #region Second has 1 shared vertex and intersects opposite side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 1));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(-1, 3));
            clip.AddLast(new Vector2(2, 1));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second has 1 shared vertex and intersects opposite side");
            #endregion

            #region Second has 1 shared vertex, second vertex lays on opposite side and adjacent side intersects opposite
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 2));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-1, 0));
            clip.AddLast(new Vector2(0, 2));
            clip.AddLast(new Vector2(0, -1));
            clip.AddLast(new Vector2(-1, 0));

            Draw(subject, clip, "Second has 1 shared vertex, second vertex lays on opposite side and adjacent side intersects opposite");
            #endregion

            #region First partially overlays one side from inside
            subject.Clear();
            clip.Clear();

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(3, 0));
            clip.AddLast(new Vector2(-3, 0));

            subject.AddLast(new Vector2(-2, 0));
            subject.AddLast(new Vector2(0, 2));
            subject.AddLast(new Vector2(2, 0));
            subject.AddLast(new Vector2(-2, 0));

            Draw(subject, clip, "First partially overlays one side from inside");
            #endregion

            #region First touches second from inside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-1, 1));
            subject.AddLast(new Vector2(1, 1));
            subject.AddLast(new Vector2(0, 0));
            subject.AddLast(new Vector2(-1, 1));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(3, 0));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "First touches second from inside");
            #endregion

            #region Second has 1 shared vertex, opposite side touches one vertex and adjacent side intesects opposite side of the first
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 0));
            clip.AddLast(new Vector2(-2, 3));
            clip.AddLast(new Vector2(1, 3));
            clip.AddLast(new Vector2(-3, 0));

            Draw(subject, clip, "Second has 1 shared vertex, opposite side touches one vertex and adjacent side intesects opposite side of the first");
            #endregion

            #region Second partially overlays one side and intersects adjacent side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-2, 1));
            clip.AddLast(new Vector2(-1, 2));
            clip.AddLast(new Vector2(0, -1));
            clip.AddLast(new Vector2(-2, 1));

            Draw(subject, clip, "Second partially overlays one side and intersects adjacent side");
            #endregion

            #region Second partially overlays one side and intersects other sides
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 2));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-1, 0));
            clip.AddLast(new Vector2(0, 3));
            clip.AddLast(new Vector2(1, 0));
            clip.AddLast(new Vector2(-1, 0));

            Draw(subject, clip, "Second partially overlays one side and intersects other sides");
            #endregion

            #region Second has 1 vertex on side and intersects adjacent side
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-2, 0));
            subject.AddLast(new Vector2(0, 2));
            subject.AddLast(new Vector2(2, 0));
            subject.AddLast(new Vector2(-2, 0));

            clip.AddLast(new Vector2(-1, 1));
            clip.AddLast(new Vector2(-1, 3));
            clip.AddLast(new Vector2(1, 2));
            clip.AddLast(new Vector2(-1, 1));

            Draw(subject, clip, "Second has 1 vertex on side and intersects adjacent side");
            #endregion

            #region Second has 1 vertex on side and intersects adjacent side containing 2 vertices inside
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-2, 0));
            subject.AddLast(new Vector2(2, 1));
            subject.AddLast(new Vector2(2, 0));
            subject.AddLast(new Vector2(-2, 0));

            clip.AddLast(new Vector2(0, 0.5f));
            clip.AddLast(new Vector2(3, 2));
            clip.AddLast(new Vector2(3, -1));
            clip.AddLast(new Vector2(0, 0.5f));

            Draw(subject, clip, "Second has 1 vertex on side and intersects adjacent side containing 2 vertices inside");
            #endregion

            #region Second has 1 vertex on side and touches opposite vertex
            subject.Clear();
            clip.Clear();

            subject.AddLast(new Vector2(-3, 0));
            subject.AddLast(new Vector2(0, 3));
            subject.AddLast(new Vector2(3, 0));
            subject.AddLast(new Vector2(-3, 0));

            clip.AddLast(new Vector2(-3, 3));
            clip.AddLast(new Vector2(3, 3));
            clip.AddLast(new Vector2(0, 0));
            clip.AddLast(new Vector2(-3, 3));

            Draw(subject, clip, "Second has 1 vertex on side and touches opposite vertex");
            #endregion

            //ICollection<CircularLinkedList<Vector2>> polys = WeilerAtherton.Process(subject, clip, Operation.Difference);

            #region Triangulaion
            //int c = 1;
            //foreach (CircularLinkedList<Vector2> poly in polys)
            //{
            //    #region Old non-hole triangulate
            //    // Small test application demonstrating the usage of the triangulate
            //    // class.

            //    Console.WriteLine("Poly {0}", c++);
            //    // Create a pretty complicated little contour by pushing them onto
            //    // an stl vector.

            //    // allocate an STL vector to hold the answer.

            //    List<Vector2> result = new List<Vector2>();

            //    //  Invoke the triangulator to triangulate this polygon.
            //    if (!Triangulate.Process(new List<Vector2>(poly), result))
            //        Console.WriteLine("Triangulate failed!");

            //    // print out the results.
            //    int tcount = result.Count / 3;

            //    for (int i = 0; i < tcount; i++)
            //    {
            //        Vector2 p1 = result[i * 3 + 0];
            //        Vector2 p2 = result[i * 3 + 1];
            //        Vector2 p3 = result[i * 3 + 2];
            //        Console.WriteLine("Triangle {0} => ({1};{2}) ({3};{4}) ({5};{6})\n", i + 1, p1.X, p1.Y, p2.X, p2.Y, p3.X, p3.Y);
            //    }
            //    #endregion
            //}
            #endregion

            Console.WriteLine("Done");
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            oneDimensionArray();
            multiDimensionArray();
            jaggedArray();

            //SELECTION SORT
            int[] integerValues = { -11, 12, -42, 0, 1, 90, 58, 6, -9 };
            SelectionSort.Sort(integerValues);
            Console.WriteLine(string.Join(" | ", integerValues));    //JOIN ALL ELEMENTS FORM THE ARRAY
            Console.WriteLine();

            string[] stringValues = { "Maria", "Marcin", "Anna", "Jakub", "Jerzy", "Nikola" };
            SelectionSort.Sort(stringValues);
            Console.WriteLine(string.Join(" | ", stringValues));
            Console.WriteLine();

            //INSERTION SORT
            int[] otherValues = { 8, 1, 5, -4, -5, 22, -13 };
            InsertionSort.Sort(otherValues);
            Console.WriteLine(string.Join(" | ", otherValues));
            Console.WriteLine();

            //BUBBLE SORT
            int[] someValues = { 22, 1, -5, -4, -4, 2, 8, 5 };
            BubbleSort.Sort(someValues);
            Console.WriteLine(string.Join(" | ", someValues));
            Console.WriteLine();

            //QUICK SORT
            int[] differentValues = { 0, 2, -3, 18, -18, 15, 6, 7 };
            QuickSort.Sort(differentValues);
            Console.WriteLine(string.Join(" | ", differentValues));
            Console.WriteLine();


            //ARRAY LIST - IT IS COLLECTION WHERE TYPE IS OBJECT (IS NOT STRONGLY TYPED)
            ArrayList arrayList = new ArrayList();

            arrayList.Add(5);
            arrayList.AddRange(new int[] { 6, 3, 8 });
            arrayList.AddRange(new object[] { "Jakub", "Krzysztof" });
            arrayList.Insert(5, 7.9);
            arrayList.Remove(5);
            int arrayValue = (int)arrayList[2];

            Console.WriteLine(arrayValue);
            int  arrayCount    = arrayList.Count;             //NUMBER OF ELEMENTS IN LIST
            int  arrayCapacity = arrayList.Capacity;          //SIZE OF LIST WITH SPACE FOR FUTURE VALUES
            bool containsJakub = arrayList.Contains("Jakub"); //CHECK IF THE POSITION OF VALUES
            int  whichIndex    = arrayList.IndexOf(5);        //CHECK THE POSITION WHERE THE VALUES IS (IF NOT THEN RETURN -1)

            Console.WriteLine();


            //GENERIC LIST (IS STRONGLY TYPED)
            //AVERAGE VALUE
            List <double> numbers = new List <double>();

            do
            {
                Console.Write("Insert the value: ");
                string numberString = Console.ReadLine();
                if (!double.TryParse(numberString, NumberStyles.Float, new NumberFormatInfo(), out double number))
                {
                    break;
                }
                numbers.Add(number);
                Console.WriteLine($"Average value: {numbers.Average()}");
            }while (true);
            Console.WriteLine();


            //GENERIC LIST
            //LIST OF PEOPLE
            List <Person> people = new List <Person>();

            people.Add(new Person()
            {
                Name = "Marcin", Age = 29, Country = CountryEnum.DE
            });
            people.Add(new Person()
            {
                Name = "Sabina", Age = 18, Country = CountryEnum.PL
            });
            people.Add(new Person()
            {
                Name = "Anna", Age = 25, Country = CountryEnum.UK
            });
            List <Person> results = people.OrderBy(p => p.Name).ToList();

            foreach (Person person in results)
            {
                Console.WriteLine($"{person.Name} (age {person.Age}) from {person.Country}.");
            }
            Console.WriteLine();


            //SORTED LIST - IT IS KEY-VALUE PAIRS (WHERE KEY HAVE TO BE UNIQUE)
            //ADDRESS BOOK - WHERE VALUES ARE AUTOMATICLY SORTED BY THEM KEYS
            SortedList <string, Person> addresses = new SortedList <string, Person>();

            addresses.Add("Marcin", new Person()
            {
                Name = "Marcin", Age = 29, Country = CountryEnum.DE
            });
            addresses.Add("Sabina", new Person()
            {
                Name = "Sabina", Age = 18, Country = CountryEnum.PL
            });
            addresses.Add("Anna", new Person()
            {
                Name = "Anna", Age = 25, Country = CountryEnum.UK
            });

            foreach (var address in addresses)  //WHY KEYPAIRVALUE DOES NOT WORK???
            {
                Console.WriteLine($"{address.Value.Name} (age {address.Value.Age}) from {address.Value.Country}.");
            }
            Console.WriteLine();


            //LIKED LIST - THERE IS SINGLE OR DOUBLE LINKED LIST WHERE WE CAN USE THE NEXT OR PREVIOUS PROPERTY
            //EBOOK READER
            Page pageFirst = new Page()
            {
                Content = "Nowadays..."
            };
            Page pageSecond = new Page()
            {
                Content = "Elaboration of that..."
            };
            Page pageThird = new Page()
            {
                Content = "A huge number of..."
            };
            Page pageFourth = new Page()
            {
                Content = "Do you know..."
            };
            Page pageFifth = new Page()
            {
                Content = "Let's consider..."
            };
            Page pageSixth = new Page()
            {
                Content = "Do you aware..."
            };
            LinkedList <Page> pages = new LinkedList <Page>();

            pages.AddLast(pageSecond);
            LinkedListNode <Page> nodePageFourth = pages.AddLast(pageFourth);

            pages.AddLast(pageSixth);
            pages.AddFirst(pageFirst);
            pages.AddBefore(nodePageFourth, pageThird);
            pages.AddAfter(nodePageFourth, pageFifth);

            //CIRCULAR LINKED LIST
            CircularLinkedList <string> categories = new CircularLinkedList <string>();

            categories.AddLast("Sport");
            categories.AddLast("Kultura");
            categories.AddLast("Historia");
            categories.AddLast("Geografia");
            categories.AddLast("Ludzie");
            categories.AddLast("Technologia");
            categories.AddLast("Przyroda");
            categories.AddLast("Fizyka");

            Random random        = new Random();
            int    totalTime     = 0;
            int    remainingTime = 0;

            foreach (string category in categories)
            {
                if (remainingTime <= 0)
                {
                    Console.WriteLine("Press [Enter] to start or other key to leave.");
                    switch (Console.ReadKey().Key)
                    {
                    case ConsoleKey.Enter:
                        totalTime     = random.Next(1000, 5000);
                        remainingTime = totalTime;
                        break;

                    default:
                        return;
                    }
                }
                int categoryTime = (-450 * remainingTime) / (totalTime - 50) + 500 + (22500 / (totalTime - 50));
                remainingTime -= categoryTime;
                Thread.Sleep(categoryTime);

                Console.ForegroundColor = remainingTime <= 0 ? ConsoleColor.Red : ConsoleColor.Gray;
                Console.WriteLine(category);
                Console.ForegroundColor = ConsoleColor.Gray;
            }


            //STACK
            //REVERSE THE WORD
            //STACK AND LIST ARE LIMITED ACCESS DATA STRUCTURES
            Stack <char> chars = new Stack <char>();

            foreach (char c in "WORD")
            {
                chars.Push(c);
            }
            while (chars.Count > 0)
            {
                Console.Write(chars.Pop());
            }


            //QUEUE
            //JOB QUEUE
            Queue <string> tasks = new Queue <string>();

            tasks.Enqueue("Make a website");
            tasks.Enqueue("Code review");
            tasks.Enqueue("Deployment");

            foreach (string task in tasks)
            {
                Console.WriteLine(tasks.Dequeue());
            }


            //HASH TABLE
            Hashtable phoneBook = new Hashtable()
            {
                { "Marcin Jamro", "000-000-000" },
                { "Jan Kowalski", "111-111-111" }
            };

            phoneBook["Liliana Kowalska"] = "333-333-333";
            string hashValue = (string)phoneBook["Jan Kowalski"];   //THE CAST IS NECCESSARY BECAUSE HASHTABLE REPRESENT NONGENERIC VARIANT OF ARRAY WITH HASHTABLE

            Console.WriteLine($"Hashtable value: {hashValue}");


            //DICTIONARY
            //IT IS A GENERIC VERSION OF HASHTABLE
            Dictionary <string, string> dictionary = new Dictionary <string, string>()
            {
                { "Key 1", "Value 1" },
                { "Key 2", "Value 2" }
            };

            dictionary.Add("Key 3", "Value 3");
            string dictionaryValue = dictionary["Key 1"];

            Console.WriteLine($"Dictionary value: {dictionaryValue}");

            foreach (KeyValuePair <string, string> pair in dictionary)
            {
                Console.WriteLine($"{pair.Key} - {pair.Value}");
            }


            //SORTED DICTIONARY
            //SIMILAR TO SORTEDLIST BUT THE SORTED DICTIONARY IS FASTER WHEN WE ADD OR REMOVE ELEMENTS
            SortedDictionary <string, string> definitions = new SortedDictionary <string, string>()
            {
                { "New York", "This is the city in the USA" },
                { "Warsaw", "This is city in Poland" },
                { "London", "This is city in the UK" }
            };

            foreach (KeyValuePair <string, string> definition in definitions)
            {
                Console.WriteLine($"{definition.Key} : {definition.Value}");
            }


            //SET
            //UNION (SUMA), INTERSECTION (CZĘŚĆ WSPÓLNA), SET SUBSTRACTION (RÓŻNICA ZBIORÓW), SYMMETRIC DIFFERENCE (RÓŻNICA ARYTMETYCZNA - SUMA BEZ CZĘŚCI WSPÓLNEJ)
            //VALUES IN SET ARE UNIQUE
            HashSet <int> usedCoupons = new HashSet <int>();

            usedCoupons.Add(100);
            usedCoupons.Add(200);
            if (usedCoupons.Contains(100))
            {
                Console.WriteLine("The set contains a value: 100");
            }

            //SORTEDSET
            //IT IS A COMBINATION OF SORTEDLIST AND HASHSET
            //USE THAT WHEN YOU NEED ORDERED COLLECTION DIFFERENT OBJECTS WITHOUT REPEATS
            List <string> names = new List <string>()
            {
                "Marcin",
                "Maria",
                "Jakub",
                "Albert",
                "Liliana",
                "Emilia",
                "Marcin",
                "Jakub",
                "Janinca"
            };
            SortedSet <string> sorted = new SortedSet <string>(names, Comparer <string> .Create((a, b) => a.ToLower().CompareTo(b.ToLower())));

            foreach (string name in sorted)
            {
                Console.WriteLine(name);
            }


            //TREE
            Tree <int> tree = new Tree <int>();

            tree.Root = new TreeNode <int>()
            {
                Data = 100
            };
            tree.Root.Children = new List <TreeNode <int> >
            {
                new TreeNode <int>()
                {
                    Data = 50, Parent = tree.Root
                },
                new TreeNode <int>()
                {
                    Data = 1, Parent = tree.Root
                },
                new TreeNode <int>()
                {
                    Data = 150, Parent = tree.Root
                }
            };
            tree.Root.Children[2].Children = new List <TreeNode <int> >()
            {
                new TreeNode <int>()
                {
                    Data = 30, Parent = tree.Root.Children[2]
                }
            };

            Console.ReadKey();
        }
Exemplo n.º 33
0
    // Returns a polygonized mesh from a 2D outer contour
    private static void EarClipping(Contour a_rDominantOuterContour, Vector2 a_f2Scale, Vector3 a_f3PivotPoint, float a_fWidth, float a_fHeight, out Vector3[] a_rVerticesArray, out int[] a_rTrianglesArray, out Vector2[] a_rUVs)
    {
        // Sum of all contours count
        int iVerticesCount = a_rDominantOuterContour.Count;

        // Mesh vertices array
        a_rVerticesArray = new Vector3[iVerticesCount];

        // Mesh UVs array
        a_rUVs = new Vector2[iVerticesCount];

        // Vertex indexes lists array (used by ear clipping algorithm)
        CircularLinkedList <int> oVertexIndexesList = new CircularLinkedList <int>( );

        // Build contour vertex index circular list
        // Store every Vector3 into mesh vertices array
        // Store corresponding index into the circular list
        int iVertexIndex = 0;

        foreach (Vector2 f2OuterContourVertex in a_rDominantOuterContour.Vertices)
        {
            a_rVerticesArray[iVertexIndex] = f2OuterContourVertex;
            oVertexIndexesList.AddLast(iVertexIndex);

            ++iVertexIndex;
        }

        // Build reflex/convex vertices lists
        LinkedList <int> rReflexVertexIndexesList;
        LinkedList <int> rConvexVertexIndexesList;

        BuildReflexConvexVertexIndexesLists(a_rVerticesArray, oVertexIndexesList, out rReflexVertexIndexesList, out rConvexVertexIndexesList);

        // Triangles for this contour
        List <int> oTrianglesList = new List <int>(3 * iVerticesCount);

        // Build ear tips list
        CircularLinkedList <int> rEarTipVertexIndexesList = BuildEarTipVerticesList(a_rVerticesArray, oVertexIndexesList, rReflexVertexIndexesList, rConvexVertexIndexesList);

        // Remove the ear tips one by one!
        while (rEarTipVertexIndexesList.Count > 0 && oVertexIndexesList.Count > 2)
        {
            CircularLinkedListNode <int> rEarTipNode = rEarTipVertexIndexesList.First;

            // Ear tip index
            int iEarTipVertexIndex = rEarTipNode.Value;

            // Ear vertex indexes
            CircularLinkedListNode <int> rContourVertexNode = oVertexIndexesList.Find(iEarTipVertexIndex);
            CircularLinkedListNode <int> rPreviousAdjacentContourVertexNode = rContourVertexNode.Previous;
            CircularLinkedListNode <int> rNextAdjacentContourVertexNode     = rContourVertexNode.Next;

            int iPreviousAjdacentContourVertexIndex = rPreviousAdjacentContourVertexNode.Value;
            int iNextAdjacentContourVertexIndex     = rNextAdjacentContourVertexNode.Value;

            // Add the ear triangle to our triangles list
            oTrianglesList.Add(iPreviousAjdacentContourVertexIndex);
            oTrianglesList.Add(iEarTipVertexIndex);
            oTrianglesList.Add(iNextAdjacentContourVertexIndex);

            // Remove the ear tip from vertices / convex / ear lists
            oVertexIndexesList.Remove(iEarTipVertexIndex);
            rConvexVertexIndexesList.Remove(iEarTipVertexIndex);

            // Adjacent n-1 vertex
            // if was convex => remain convex, can possibly an ear
            // if was an ear => can possibly not remain an ear
            // if was reflex => can possibly convex and possibly an ear
            if (rReflexVertexIndexesList.Contains(iPreviousAjdacentContourVertexIndex))
            {
                CircularLinkedListNode <int> rPreviousPreviousAdjacentContourVertexNode = rPreviousAdjacentContourVertexNode.Previous;

                Vector3 f3AdjacentContourVertex         = a_rVerticesArray[rPreviousAdjacentContourVertexNode.Value];
                Vector3 f3PreviousAdjacentContourVertex = a_rVerticesArray[rPreviousPreviousAdjacentContourVertexNode.Value];
                Vector3 f3NextAdjacentContourVertex     = a_rVerticesArray[rPreviousAdjacentContourVertexNode.Next.Value];

                if (IsReflexVertex(f3AdjacentContourVertex, f3PreviousAdjacentContourVertex, f3NextAdjacentContourVertex) == false)
                {
                    rReflexVertexIndexesList.Remove(iPreviousAjdacentContourVertexIndex);
                    rConvexVertexIndexesList.AddFirst(iPreviousAjdacentContourVertexIndex);
                }
            }

            // Adjacent n+1 vertex
            // if was convex => remain convex, can possibly an ear
            // if was an ear => can possibly not remain an ear
            // if was reflex => can possibly convex and possibly an ear
            if (rReflexVertexIndexesList.Contains(iNextAdjacentContourVertexIndex))
            {
                CircularLinkedListNode <int> rNextNextAdjacentContourVertexNode = rNextAdjacentContourVertexNode.Next;

                Vector3 f3AdjacentContourVertex         = a_rVerticesArray[rNextAdjacentContourVertexNode.Value];
                Vector3 f3PreviousAdjacentContourVertex = a_rVerticesArray[rNextAdjacentContourVertexNode.Previous.Value];
                Vector3 f3NextAdjacentContourVertex     = a_rVerticesArray[rNextNextAdjacentContourVertexNode.Value];

                if (IsReflexVertex(f3AdjacentContourVertex, f3PreviousAdjacentContourVertex, f3NextAdjacentContourVertex) == false)
                {
                    rReflexVertexIndexesList.Remove(iNextAdjacentContourVertexIndex);
                    rConvexVertexIndexesList.AddFirst(iNextAdjacentContourVertexIndex);
                }
            }

            if (rConvexVertexIndexesList.Contains(iPreviousAjdacentContourVertexIndex))
            {
                if (IsEarTip(a_rVerticesArray, iPreviousAjdacentContourVertexIndex, oVertexIndexesList, rReflexVertexIndexesList))
                {
                    if (rEarTipVertexIndexesList.Contains(iPreviousAjdacentContourVertexIndex) == false)
                    {
                        rEarTipVertexIndexesList.AddLast(iPreviousAjdacentContourVertexIndex);
                    }
                }
                else
                {
                    rEarTipVertexIndexesList.Remove(iPreviousAjdacentContourVertexIndex);
                }
            }

            if (rConvexVertexIndexesList.Contains(iNextAdjacentContourVertexIndex))
            {
                if (IsEarTip(a_rVerticesArray, iNextAdjacentContourVertexIndex, oVertexIndexesList, rReflexVertexIndexesList))
                {
                    if (rEarTipVertexIndexesList.Contains(iNextAdjacentContourVertexIndex) == false)
                    {
                        rEarTipVertexIndexesList.AddFirst(iNextAdjacentContourVertexIndex);
                    }
                }
                else
                {
                    rEarTipVertexIndexesList.Remove(iNextAdjacentContourVertexIndex);
                }
            }

            rEarTipVertexIndexesList.Remove(iEarTipVertexIndex);
        }

        // Create UVs, rescale vertices, apply pivot
        Vector2 f2Dimensions = new Vector2(1.0f / a_fWidth, 1.0f / a_fHeight);

        for (iVertexIndex = 0; iVertexIndex < iVerticesCount; ++iVertexIndex)
        {
            Vector3 f3VertexPos = a_rVerticesArray[iVertexIndex];

            //a_rUVs[ iVertexIndex ] = Vector2.Scale( f3VertexPos, f2Dimensions );
            a_rUVs[iVertexIndex] = new Vector2(f3VertexPos.x * f2Dimensions.x, f3VertexPos.y * f2Dimensions.y);
            Vector2 f2Vertex = (f3VertexPos - a_f3PivotPoint);
            f2Vertex.x *= a_f2Scale.x;
            f2Vertex.y *= a_f2Scale.y;
            a_rVerticesArray[iVertexIndex] = f2Vertex;
        }

        a_rTrianglesArray = oTrianglesList.ToArray( );
    }
	// Returns a polygonized mesh from a 2D outer contour
	private static void EarClipping( Contour a_rDominantOuterContour, float a_fScale, Vector3 a_f3PivotPoint, float a_fWidth, float a_fHeight, out Vector3[ ] a_rVerticesArray, out int[ ] a_rTrianglesArray, out Vector2[ ] a_rUVs )
	{
		// Sum of all contours count
		int iVerticesCount = a_rDominantOuterContour.Count;

		// Mesh vertices array
		a_rVerticesArray = new Vector3[ iVerticesCount ];

		// Mesh UVs array
		a_rUVs           = new Vector2[ iVerticesCount ];

		// Vertex indexes lists array (used by ear clipping algorithm)
		CircularLinkedList<int> oVertexIndexesList = new CircularLinkedList<int>( );

		// Build contour vertex index circular list
		// Store every Vector3 into mesh vertices array
		// Store corresponding index into the circular list
		int iVertexIndex = 0;
		foreach( Vector2 f2OuterContourVertex in a_rDominantOuterContour.Vertices )
		{
			a_rVerticesArray[ iVertexIndex ] = f2OuterContourVertex;
			oVertexIndexesList.AddLast( iVertexIndex );

			++iVertexIndex;
		}

		// Build reflex/convex vertices lists
		LinkedList<int> rReflexVertexIndexesList;
		LinkedList<int> rConvexVertexIndexesList;
		BuildReflexConvexVertexIndexesLists( a_rVerticesArray, oVertexIndexesList, out rReflexVertexIndexesList, out rConvexVertexIndexesList );

		// Triangles for this contour
		List<int> oTrianglesList = new List<int>( 3 * iVerticesCount );

		// Build ear tips list
		CircularLinkedList<int> rEarTipVertexIndexesList = BuildEarTipVerticesList( a_rVerticesArray, oVertexIndexesList, rReflexVertexIndexesList, rConvexVertexIndexesList );

		// Remove the ear tips one by one!
		while( rEarTipVertexIndexesList.Count > 0 && oVertexIndexesList.Count > 2 )
		{

			CircularLinkedListNode<int> rEarTipNode = rEarTipVertexIndexesList.First;

			// Ear tip index
			int iEarTipVertexIndex = rEarTipNode.Value;

			// Ear vertex indexes
			CircularLinkedListNode<int> rContourVertexNode                 = oVertexIndexesList.Find( iEarTipVertexIndex );
			CircularLinkedListNode<int> rPreviousAdjacentContourVertexNode = rContourVertexNode.Previous;
			CircularLinkedListNode<int> rNextAdjacentContourVertexNode     = rContourVertexNode.Next;

			int iPreviousAjdacentContourVertexIndex = rPreviousAdjacentContourVertexNode.Value;
			int iNextAdjacentContourVertexIndex     = rNextAdjacentContourVertexNode.Value;
		
			// Add the ear triangle to our triangles list
			oTrianglesList.Add( iPreviousAjdacentContourVertexIndex );
			oTrianglesList.Add( iEarTipVertexIndex );
			oTrianglesList.Add( iNextAdjacentContourVertexIndex );

			// Remove the ear tip from vertices / convex / ear lists
			oVertexIndexesList.Remove( iEarTipVertexIndex );
			rConvexVertexIndexesList.Remove( iEarTipVertexIndex );

			// Adjacent n-1 vertex
			// if was convex => remain convex, can possibly an ear
			// if was an ear => can possibly not remain an ear
			// if was reflex => can possibly convex and possibly an ear
			if( rReflexVertexIndexesList.Contains( iPreviousAjdacentContourVertexIndex ) )
			{
				CircularLinkedListNode<int> rPreviousPreviousAdjacentContourVertexNode = rPreviousAdjacentContourVertexNode.Previous;

				Vector3 f3AdjacentContourVertex         = a_rVerticesArray[ rPreviousAdjacentContourVertexNode.Value ];
				Vector3 f3PreviousAdjacentContourVertex = a_rVerticesArray[ rPreviousPreviousAdjacentContourVertexNode.Value ];
				Vector3 f3NextAdjacentContourVertex     = a_rVerticesArray[ rPreviousAdjacentContourVertexNode.Next.Value ];

				if( IsReflexVertex( f3AdjacentContourVertex, f3PreviousAdjacentContourVertex, f3NextAdjacentContourVertex ) == false )
				{
					rReflexVertexIndexesList.Remove( iPreviousAjdacentContourVertexIndex );
					rConvexVertexIndexesList.AddFirst( iPreviousAjdacentContourVertexIndex );
				}
			}

			// Adjacent n+1 vertex
			// if was convex => remain convex, can possibly an ear
			// if was an ear => can possibly not remain an ear
			// if was reflex => can possibly convex and possibly an ear
			if( rReflexVertexIndexesList.Contains( iNextAdjacentContourVertexIndex ) )
			{
				CircularLinkedListNode<int> rNextNextAdjacentContourVertexNode = rNextAdjacentContourVertexNode.Next;

				Vector3 f3AdjacentContourVertex         = a_rVerticesArray[ rNextAdjacentContourVertexNode.Value ];
				Vector3 f3PreviousAdjacentContourVertex = a_rVerticesArray[ rNextAdjacentContourVertexNode.Previous.Value ];
				Vector3 f3NextAdjacentContourVertex     = a_rVerticesArray[ rNextNextAdjacentContourVertexNode.Value ];

				if( IsReflexVertex( f3AdjacentContourVertex, f3PreviousAdjacentContourVertex, f3NextAdjacentContourVertex ) == false )
				{
					rReflexVertexIndexesList.Remove( iNextAdjacentContourVertexIndex );
					rConvexVertexIndexesList.AddFirst( iNextAdjacentContourVertexIndex );
				}
			}

			if( rConvexVertexIndexesList.Contains( iPreviousAjdacentContourVertexIndex ) )
			{
				if( IsEarTip( a_rVerticesArray, iPreviousAjdacentContourVertexIndex, oVertexIndexesList, rReflexVertexIndexesList ) )
				{
					if( rEarTipVertexIndexesList.Contains( iPreviousAjdacentContourVertexIndex ) == false )
					{
						rEarTipVertexIndexesList.AddLast( iPreviousAjdacentContourVertexIndex );
					}
				}
				else
				{
					rEarTipVertexIndexesList.Remove( iPreviousAjdacentContourVertexIndex );
				}
			}

			if( rConvexVertexIndexesList.Contains( iNextAdjacentContourVertexIndex ) )
			{
				if( IsEarTip( a_rVerticesArray, iNextAdjacentContourVertexIndex, oVertexIndexesList, rReflexVertexIndexesList ) )
				{
					if( rEarTipVertexIndexesList.Contains( iNextAdjacentContourVertexIndex ) == false )
					{
						rEarTipVertexIndexesList.AddFirst( iNextAdjacentContourVertexIndex );
					}
				}
				else
				{
					rEarTipVertexIndexesList.Remove( iNextAdjacentContourVertexIndex );
				}
			}

			rEarTipVertexIndexesList.Remove( iEarTipVertexIndex );
		}

		// Create UVs, rescale vertices, apply pivot
		Vector2 f2Dimensions = new Vector2( 1.0f / a_fWidth, 1.0f / a_fHeight );
		for( iVertexIndex = 0; iVertexIndex < iVerticesCount; ++iVertexIndex )
		{
			Vector3 f3VertexPos = a_rVerticesArray[ iVertexIndex ];

			//a_rUVs[ iVertexIndex ] = Vector2.Scale( f3VertexPos, f2Dimensions );
			a_rUVs[ iVertexIndex ]           = new Vector2( f3VertexPos.x * f2Dimensions.x, f3VertexPos.y * f2Dimensions.y );
			a_rVerticesArray[ iVertexIndex ] = ( f3VertexPos - a_f3PivotPoint ) * a_fScale;
		}

		a_rTrianglesArray = oTrianglesList.ToArray( );
	}
	// Builds and return a list of vertex indexes that are ear tips.
	private static CircularLinkedList<int> BuildEarTipVerticesList( Vector3[ ] a_rMeshVertices, CircularLinkedList<int> a_rOuterContourVertexIndexesList, LinkedList<int> a_rReflexVertexIndexesList, LinkedList<int> a_rConvexVertexIndexesList )
	{
		CircularLinkedList<int> oEarTipVertexIndexesList = new CircularLinkedList<int>( );

		// Iterate convex vertices
		for( LinkedListNode<int> rConvexIndexNode = a_rConvexVertexIndexesList.First; rConvexIndexNode != null; rConvexIndexNode = rConvexIndexNode.Next )
		{
			// The convex vertex index
			int iConvexContourVertexIndex = rConvexIndexNode.Value;

			// Is the convex vertex is an ear tip?
			if( IsEarTip( a_rMeshVertices, iConvexContourVertexIndex, a_rOuterContourVertexIndexesList, a_rReflexVertexIndexesList ) == true )
			{
				// Yes: adds it to the list
				oEarTipVertexIndexesList.AddLast( iConvexContourVertexIndex );
			}
		}

		// Return the ear tip list
		return oEarTipVertexIndexesList;
	}
        /// <summary>
        /// Performs algorithm and returns skeleton
        /// </summary>
        public List<Point2D> Skeleton()
        {
            List<Point2D> ret = new List<Point2D>();

            int i = 0;
            while (Q.Count != 0)
            {
                Event currentEvent = Q.Dequeue();
                CircularLinkedList<Vertex> currentLAV = SLAV[currentEvent.getLAVID()];

                Console.WriteLine("------ Iteration " + i + " LAV ID " + currentEvent.getLAVID() + " ------");
                if (currentLAV.Count > 0)
                {
                    foreach (Vertex vertex in currentLAV)
                    {
                        if (vertex != null)
                        {
                            Console.WriteLine("Vertex with ID= " + vertex.getID() + (vertex.isActive() ? " is active " : " is not active"));
                        }
                    }
                  Console.WriteLine("---------------------------------");
                }

                i++;
                if (currentEvent.getType() == EventType.Edge)
                {
                    Console.WriteLine("Edge event between " + currentEvent.getFirstPoint().getID() + " and " + currentEvent.getSecondPoint().getID());
                    Node<Vertex> prevNode = currentLAV.Find(currentEvent.getFirstPoint());
                    Node<Vertex> nextNode = currentLAV.Find(currentEvent.getSecondPoint());

                    //check if event is outdated
                    if (prevNode == null || nextNode == null || (!prevNode.Value.isActive() && !nextNode.Value.isActive()))
                    {
                        Console.WriteLine("Skipped edge event");
                        continue;
                    }

                    Vertex prevV = prevNode.Value;
                    Vertex nextV = nextNode.Value;

                    //check if we remain to the last 3 points
                    if (prevNode.PrevActive().PrevActive().Value.Equals(nextV))
                    {
                        Point2D intersect = new Point2D(LineTools.LineIntersect(prevV.getPoint(), prevV.getRayStepPoint(), nextV.getPoint(), nextV.getRayStepPoint()));

                        ret.Add(prevV.getPoint());
                        ret.Add(intersect);
                        ret.Add(nextV.getPoint());
                        ret.Add(intersect);
                        ret.Add(prevNode.PrevActive().Value.getPoint());
                        ret.Add(intersect);

                        currentLAV.Find(prevV).Value.setActive(false);
                        currentLAV.Find(nextV).Value.setActive(false);
                        currentLAV.Find(prevV).PrevActive().Value.setActive(false);
                        continue;
                    }

                    //output two arcs
                    ret.Add(currentEvent.getFirstPoint().getPoint());
                    ret.Add(currentEvent.getIntersection());
                    ret.Add(currentEvent.getSecondPoint().getPoint());
                    ret.Add(currentEvent.getIntersection());

                    //modify list
                    currentLAV.Find(currentEvent.getFirstPoint()).Value.setActive(false);
                    currentLAV.Find(currentEvent.getSecondPoint()).Value.setActive(false);

                    Point2D intersection = currentEvent.getIntersection();
                    if (!intersection.Equals(Point2D.Zero))
                    {
                        Vertex newV = new Vertex(intersection, id++);
                        newV.prevEdge = prevV.prevEdge;
                        newV.nextEdge = nextV.nextEdge;
                        newV.update();

                        Node<Vertex> newNode = new Node<Vertex>(newV);

                        currentLAV.AddAfter(prevV, newV);
                        //currentLAV.Remove(prevV);
                        //currentLAV.Remove(nextV);

                        findClosestIntersectionAndStore(currentLAV, currentLAV.Find(newV).PrevActive().Value, currentLAV.Find(newV).Value, currentLAV.Find(newV).NextActive().Value);
                    }
                }
                else
                {
                    Console.WriteLine("Split event " + currentEvent.getFirstPoint().getID());
                    Node<Vertex> prevNode = currentLAV.Find(currentEvent.getFirstPoint());

                    //check if event is outdated
                    if (prevNode == null || !prevNode.Value.isActive())
                    {

                        Console.WriteLine("Skipped split event");
                        continue;
                    }
                    Vertex prevV = prevNode.Value;
                    prevV.setActive(false);

                    //check if we remain to the last 3 points
                    if (prevNode.PrevActive().PrevActive().Value.Equals(prevNode.NextActive().Value))
                    {
                        Point2D intersect = new Point2D(LineTools.LineIntersect(prevV.getPoint(), prevV.getRayStepPoint(), prevNode.Next.Value.getPoint(), prevNode.Next.Value.getRayStepPoint()));

                        ret.Add(prevNode.Value.getPoint());
                        ret.Add(intersect);
                        ret.Add(prevNode.NextActive().Value.getPoint());
                        ret.Add(intersect);
                        ret.Add(prevNode.PrevActive().Value.getPoint());
                        ret.Add(intersect);

                        continue;
                    }
                    //output only VI
                    ret.Add(prevV.getPoint());
                    ret.Add(currentEvent.getIntersection());

                    //split LAV reset que etc
                    Vertex newNodeV1 = new Vertex(currentEvent.getIntersection(), id++);
                    newNodeV1.prevEdge = currentEvent.getFirstPoint().prevEdge;
                    newNodeV1.nextEdge = currentEvent.getFirstEdgePoint().nextEdge;
                    newNodeV1.update();

                    Vertex newNodeV2 = new Vertex(currentEvent.getIntersection(), id++);
                    newNodeV2.prevEdge = currentEvent.getFirstPoint().nextEdge;
                    newNodeV2.nextEdge = currentEvent.getFirstEdgePoint().nextEdge;
                    newNodeV2.update();

                    CircularLinkedList<Vertex> newLAV = new CircularLinkedList<Vertex>();
                    newLAV.AddFirst(newNodeV2);
                    Node<Vertex> current = SLAV[currentEvent.getLAVID()].Find(currentEvent.getFirstPoint());

                    while(!current.Next.Value.Equals(currentEvent.getSecondEdgePoint()))
                    {
                        if (current.Next.Equals(current))
                        {
                            break;
                        }
                        current = current.Next;
                        newLAV.AddLast(current.Value);
                        //current.Value.setActive(false);
                        SLAV[currentEvent.getLAVID()].Remove(current.Value);
                    }
                    SLAV.Add(newLAV);
                    SLAV[currentEvent.getLAVID()].AddAfter(currentEvent.getFirstPoint(),newNodeV1);
                    //SLAV[currentEvent.getLAVID()].Find(currentEvent.getFirstPoint()).Value.setActive(false);
                    //SLAV[currentEvent.getLAVID()].Remove(currentEvent.getFirstPoint());

                    //test
                    for (int x = 0; x < newLAV.Count; x++)
                    {
                        Vertex prev = newLAV[x].PrevActive().Value;
                        Vertex curr = newLAV[x].Value;
                        Vertex next = newLAV[x].NextActive().Value;

                        findClosestIntersectionAndStore(newLAV, prev, curr, next);
                    }

                    //findClosestIntersectionAndStore(newLAV, newLAV.Find(newNodeV2).PrevActive().Value, newLAV.Find(newNodeV2).Value, newLAV.Find(newNodeV2).NextActive().Value);
                    findClosestIntersectionAndStore(SLAV[currentEvent.getLAVID()], SLAV[currentEvent.getLAVID()].Find(newNodeV1).PrevActive().Value, SLAV[currentEvent.getLAVID()].Find(newNodeV1).Value, SLAV[currentEvent.getLAVID()].Find(newNodeV1).NextActive().Value);

                }
            }
            return ret;
        }