コード例 #1
0
        private void TagBlindTriangles()
        {
            int num = 0;

            this.subsegMap = new Dictionary <int, Segment>();
            Otri otri  = new Otri();
            Otri otri1 = new Otri();
            Osub osub  = new Osub();
            Osub osub1 = new Osub();

            foreach (Triangle value in this.mesh.triangles.Values)
            {
                value.infected = false;
            }
            foreach (Segment segment in this.mesh.subsegs.Values)
            {
                Stack <Triangle> triangles = new Stack <Triangle>();
                osub.seg    = segment;
                osub.orient = 0;
                osub.TriPivot(ref otri);
                if (otri.triangle != Mesh.dummytri && !otri.triangle.infected)
                {
                    triangles.Push(otri.triangle);
                }
                osub.SymSelf();
                osub.TriPivot(ref otri);
                if (otri.triangle != Mesh.dummytri && !otri.triangle.infected)
                {
                    triangles.Push(otri.triangle);
                }
                while (triangles.Count > 0)
                {
                    otri.triangle = triangles.Pop();
                    otri.orient   = 0;
                    if (!this.TriangleIsBlinded(ref otri, ref osub))
                    {
                        continue;
                    }
                    otri.triangle.infected = true;
                    num++;
                    this.subsegMap.Add(otri.triangle.hash, osub.seg);
                    otri.orient = 0;
                    while (otri.orient < 3)
                    {
                        otri.Sym(ref otri1);
                        otri1.SegPivot(ref osub1);
                        if (otri1.triangle != Mesh.dummytri && !otri1.triangle.infected && osub1.seg == Mesh.dummysub)
                        {
                            triangles.Push(otri1.triangle);
                        }
                        otri.orient = otri.orient + 1;
                    }
                }
            }
            num = 0;
        }
コード例 #2
0
ファイル: BoundedVoronoi.cs プロジェクト: oldmannus/PitGit
        /// <summary>
        /// Tag all blind triangles.
        /// </summary>
        /// <remarks>
        /// A triangle is said to be blind if the triangle and its circumcenter
        /// lie on two different sides of a constrained edge.
        /// </remarks>
        private void TagBlindTriangles()
        {
            int blinded = 0;

            Stack <Triangle> triangles;

            subsegMap = new Dictionary <int, Segment>();

            Otri f    = default(Otri);
            Otri f0   = default(Otri);
            Osub e    = default(Osub);
            Osub sub1 = default(Osub);

            // Tag all triangles non-blind
            foreach (var t in mesh.triangles.Values)
            {
                // Use the infected flag for 'blinded' attribute.
                t.infected = false;
            }

            // for each constrained edge e of cdt do
            foreach (var ss in mesh.subsegs.Values)
            {
                // Create a stack: triangles
                triangles = new Stack <Triangle>();

                // for both adjacent triangles fe to e tagged non-blind do
                // Push fe into triangles
                e.seg    = ss;
                e.orient = 0;
                e.TriPivot(ref f);

                if (f.triangle != Mesh.dummytri && !f.triangle.infected)
                {
                    triangles.Push(f.triangle);
                }

                e.SymSelf();
                e.TriPivot(ref f);

                if (f.triangle != Mesh.dummytri && !f.triangle.infected)
                {
                    triangles.Push(f.triangle);
                }

                // while triangles is non-empty
                while (triangles.Count > 0)
                {
                    // Pop f from stack triangles
                    f.triangle = triangles.Pop();
                    f.orient   = 0;

                    // if f is blinded by e (use P) then
                    if (TriangleIsBlinded(ref f, ref e))
                    {
                        // Tag f as blinded by e
                        f.triangle.infected = true;
                        blinded++;

                        // Store association triangle -> subseg
                        subsegMap.Add(f.triangle.hash, e.seg);

                        // for each adjacent triangle f0 to f do
                        for (f.orient = 0; f.orient < 3; f.orient++)
                        {
                            f.Sym(ref f0);

                            f0.SegPivot(ref sub1);

                            // if f0 is finite and tagged non-blind & the common edge
                            // between f and f0 is unconstrained then
                            if (f0.triangle != Mesh.dummytri && !f0.triangle.infected && sub1.seg == Mesh.dummysub)
                            {
                                // Push f0 into triangles.
                                triangles.Push(f0.triangle);
                            }
                        }
                    }
                }
            }

            blinded = 0;
        }