NonRegular() public static method

Return a positive value if the point pd is incompatible with the circle or plane passing through pa, pb, and pc (meaning that pd is inside the circle or below the plane); a negative value if it is compatible; and zero if the four points are cocircular/coplanar. The points pa, pb, and pc must be in counterclockwise order, or the sign of the result will be reversed.
public static NonRegular ( System.Point pa, System.Point pb, System.Point pc, System.Point pd ) : double
pa System.Point Point a.
pb System.Point Point b.
pc System.Point Point c.
pd System.Point Point d.
return double
Ejemplo n.º 1
0
        public bool CheckDelaunay()
        {
            Otri otri    = new Otri();
            Otri otri1   = new Otri();
            Osub osub    = new Osub();
            bool noExact = Behavior.NoExact;

            Behavior.NoExact = false;
            int num = 0;

            foreach (Triangle value in this.mesh.triangles.Values)
            {
                otri.triangle = value;
                otri.orient   = 0;
                while (otri.orient < 3)
                {
                    Vertex vertex  = otri.Org();
                    Vertex vertex1 = otri.Dest();
                    Vertex vertex2 = otri.Apex();
                    otri.Sym(ref otri1);
                    Vertex vertex3 = otri1.Apex();
                    bool   flag    = (otri1.triangle == Mesh.dummytri || Otri.IsDead(otri1.triangle) || otri.triangle.id >= otri1.triangle.id || !(vertex != this.mesh.infvertex1) || !(vertex != this.mesh.infvertex2) || !(vertex != this.mesh.infvertex3) || !(vertex1 != this.mesh.infvertex1) || !(vertex1 != this.mesh.infvertex2) || !(vertex1 != this.mesh.infvertex3) || !(vertex2 != this.mesh.infvertex1) || !(vertex2 != this.mesh.infvertex2) || !(vertex2 != this.mesh.infvertex3) || !(vertex3 != this.mesh.infvertex1) || !(vertex3 != this.mesh.infvertex2) ? false : vertex3 != this.mesh.infvertex3);
                    if (this.mesh.checksegments & flag)
                    {
                        otri.SegPivot(ref osub);
                        if (osub.seg != Mesh.dummysub)
                        {
                            flag = false;
                        }
                    }
                    if (flag && Primitives.NonRegular(vertex, vertex1, vertex2, vertex3) > 0)
                    {
                        this.logger.Warning(string.Format("Non-regular pair of triangles found (IDs {0}/{1}).", otri.triangle.id, otri1.triangle.id), "Quality.CheckDelaunay()");
                        num++;
                    }
                    otri.orient = otri.orient + 1;
                }
            }
            if (num == 0)
            {
                this.logger.Info("Mesh is Delaunay.");
            }
            Behavior.NoExact = noExact;
            return(num == 0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Ensure that the mesh is (constrained) Delaunay.
        /// </summary>
        public bool CheckDelaunay()
        {
            Otri   loop = default(Otri);
            Otri   oppotri = default(Otri);
            Osub   opposubseg = default(Osub);
            Vertex triorg, tridest, triapex;
            Vertex oppoapex;
            bool   shouldbedelaunay;
            int    horrors;
            bool   saveexact;

            // Temporarily turn on exact arithmetic if it's off.
            saveexact        = Behavior.NoExact;
            Behavior.NoExact = false;
            horrors          = 0;

            // Run through the list of triangles, checking each one.
            foreach (var tri in mesh.triangles.Values)
            {
                loop.triangle = tri;

                // Check all three edges of the triangle.
                for (loop.orient = 0; loop.orient < 3;
                     loop.orient++)
                {
                    triorg  = loop.Org();
                    tridest = loop.Dest();
                    triapex = loop.Apex();
                    loop.Sym(ref oppotri);
                    oppoapex = oppotri.Apex();
                    // Only test that the edge is locally Delaunay if there is an
                    // adjoining triangle whose pointer is larger (to ensure that
                    // each pair isn't tested twice).
                    shouldbedelaunay = (oppotri.triangle != Mesh.dummytri) &&
                                       !Otri.IsDead(oppotri.triangle) && loop.triangle.id < oppotri.triangle.id &&
                                       (triorg != mesh.infvertex1) && (triorg != mesh.infvertex2) &&
                                       (triorg != mesh.infvertex3) &&
                                       (tridest != mesh.infvertex1) && (tridest != mesh.infvertex2) &&
                                       (tridest != mesh.infvertex3) &&
                                       (triapex != mesh.infvertex1) && (triapex != mesh.infvertex2) &&
                                       (triapex != mesh.infvertex3) &&
                                       (oppoapex != mesh.infvertex1) && (oppoapex != mesh.infvertex2) &&
                                       (oppoapex != mesh.infvertex3);
                    if (mesh.checksegments && shouldbedelaunay)
                    {
                        // If a subsegment separates the triangles, then the edge is
                        // constrained, so no local Delaunay test should be done.
                        loop.SegPivot(ref opposubseg);
                        if (opposubseg.seg != Mesh.dummysub)
                        {
                            shouldbedelaunay = false;
                        }
                    }
                    if (shouldbedelaunay)
                    {
                        if (Primitives.NonRegular(triorg, tridest, triapex, oppoapex) > 0.0)
                        {
                            logger.Warning(String.Format("Non-regular pair of triangles found (IDs {0}/{1}).",
                                                         loop.triangle.id, oppotri.triangle.id), "Quality.CheckDelaunay()");
                            horrors++;
                        }
                    }
                }
            }

            if (horrors == 0) // && Behavior.Verbose
            {
                logger.Info("Mesh is Delaunay.");
            }

            // Restore the status of exact arithmetic.
            Behavior.NoExact = saveexact;

            return(horrors == 0);
        }