Exemplo n.º 1
0
        void RenderMaximumFaceGroup(Face fOrig)
        {
            /* We want to find the largest triangle fan or strip of unmarked faces
             * which includes the given face fOrig.  There are 3 possible fans
             * passing through fOrig (one centered at each vertex), and 3 possible
             * strips (one for each CCW permutation of the vertices).  Our strategy
             * is to try all of these, and take the primitive which uses the most
             * triangles (a greedy approach).
             */
            HalfEdge  e   = fOrig.halfEdgeThisIsLeftFaceOf;
            FaceCount max = new FaceCount(1, e, new FaceCount.RenderDelegate(RenderTriangle));
            FaceCount newFace;

            max.size   = 1;
            max.eStart = e;
            if (!this.EdgeCallBackSet)
            {
                newFace = MaximumFan(e); if (newFace.size > max.size)
                {
                    max = newFace;
                }
                newFace = MaximumFan(e.nextEdgeCCWAroundLeftFace); if (newFace.size > max.size)
                {
                    max = newFace;
                }
                newFace = MaximumFan(e.Lprev); if (newFace.size > max.size)
                {
                    max = newFace;
                }

                newFace = MaximumStrip(e); if (newFace.size > max.size)
                {
                    max = newFace;
                }
                newFace = MaximumStrip(e.nextEdgeCCWAroundLeftFace); if (newFace.size > max.size)
                {
                    max = newFace;
                }
                newFace = MaximumStrip(e.Lprev); if (newFace.size > max.size)
                {
                    max = newFace;
                }
            }

            max.CallRender(this, max.eStart, max.size);
        }
Exemplo n.º 2
0
 public void Log(Coin.FACE face)
 {
     if (history.Count == 0)
     {
         history.Add(new FaceCount(1, face));
     }
     else
     {
         int       index = history.Count - 1;
         FaceCount last  = history[index];
         if (last.GetFace().Equals(face))
         {
             last.IncrementCount();
             history[index] = last;
         }
         else
         {
             history.Add(new FaceCount(1, face));
         }
     }
 }
Exemplo n.º 3
0
        private FaceCount MaximumStrip(HalfEdge eOrig)
        {
            /* Here we are looking for a maximal strip that contains the vertices
             * eOrig.Org, eOrig.Dst, eOrig.Lnext.Dst (in that order or the
             * reverse, such that all triangles are oriented CCW).
             *
             * Again we walk forward and backward as far as possible.  However for
             * strips there is a twist: to get CCW orientations, there must be
             * an *even* number of triangles in the strip on one side of eOrig.
             * We walk the strip starting on a side with an even number of triangles;
             * if both side have an odd number, we are forced to shorten one side.
             */
            FaceCount newFace = new FaceCount(0, null, RenderStrip);
            int       headSize = 0, tailSize = 0;
            Face      trail = null;
            HalfEdge  e, eTail, eHead;

            for (e = eOrig; !e.leftFace.Marked(); ++tailSize, e = e.nextEdgeCCWAroundOrigin)
            {
                Face.AddToTrail(ref e.leftFace, ref trail);
                ++tailSize;
                e = e.Dprev;
                if (e.leftFace.Marked())
                {
                    break;
                }
                Face.AddToTrail(ref e.leftFace, ref trail);
            }
            eTail = e;

            for (e = eOrig; !e.rightFace.Marked(); ++headSize, e = e.Dnext)
            {
                Face f = e.rightFace;
                Face.AddToTrail(ref f, ref trail);
                e.rightFace = f;
                ++headSize;
                e = e.Oprev;
                if (e.rightFace.Marked())
                {
                    break;
                }
                f = e.rightFace;
                Face.AddToTrail(ref f, ref trail);
                e.rightFace = f;
            }
            eHead = e;

            newFace.size = tailSize + headSize;
            if (IsEven(tailSize))
            {
                newFace.eStart = eTail.otherHalfOfThisEdge;
            }
            else if (IsEven(headSize))
            {
                newFace.eStart = eHead;
            }
            else
            {
                /* Both sides have odd length, we must shorten one of them.  In fact,
                 * we must start from eHead to guarantee inclusion of eOrig.Lface.
                 */
                --newFace.size;
                newFace.eStart = eHead.nextEdgeCCWAroundOrigin;
            }

            Face.FreeTrail(ref trail);
            return(newFace);
        }
Exemplo n.º 4
0
        internal static void RenderMaximumFaceGroup(GLUtessellatorImpl tess, Mogre.Utils.GluTesselator.GLUface fOrig)
        {
            /* We want to find the largest triangle fan or strip of unmarked faces
            * which includes the given face fOrig.  There are 3 possible fans
            * passing through fOrig (one centered at each vertex), and 3 possible
            * strips (one for each CCW permutation of the vertices).  Our strategy
            * is to try all of these, and take the primitive which uses the most
            * triangles (a greedy approach).
            */
            Mogre.Utils.GluTesselator.GLUhalfEdge e = fOrig.anEdge;
            FaceCount max = new FaceCount();
            FaceCount newFace = new FaceCount();

            max.size = 1;
            max.eStart = e;
            max.render = renderTriangle;

            if (!tess.flagBoundary)
            {
                newFace = MaximumFan(e);
                if (newFace.size > max.size)
                {
                    max = newFace;
                }
                newFace = MaximumFan(e.Lnext);
                if (newFace.size > max.size)
                {
                    max = newFace;
                }
                newFace = MaximumFan(e.Onext.Sym);
                if (newFace.size > max.size)
                {
                    max = newFace;
                }

                newFace = MaximumStrip(e);
                if (newFace.size > max.size)
                {
                    max = newFace;
                }
                newFace = MaximumStrip(e.Lnext);
                if (newFace.size > max.size)
                {
                    max = newFace;
                }
                newFace = MaximumStrip(e.Onext.Sym);
                if (newFace.size > max.size)
                {
                    max = newFace;
                }
            }
            max.render.render(tess, max.eStart, max.size);
        }
Exemplo n.º 5
0
        internal static FaceCount MaximumStrip(Mogre.Utils.GluTesselator.GLUhalfEdge eOrig)
        {
            /* Here we are looking for a maximal strip that contains the vertices
            * eOrig.Org, eOrig.Dst, eOrig.Lnext.Dst (in that order or the
            * reverse, such that all triangles are oriented CCW).
            *
            * Again we walk forward and backward as far as possible.  However for
            * strips there is a twist: to get CCW orientations, there must be
            * an *even* number of triangles in the strip on one side of eOrig.
            * We walk the strip starting on a side with an even number of triangles;
            * if both side have an odd number, we are forced to shorten one side.
            */
            FaceCount newFace = new FaceCount(0, null, renderStrip);
            long headSize = 0, tailSize = 0;
            Mogre.Utils.GluTesselator.GLUface trail = null;
            Mogre.Utils.GluTesselator.GLUhalfEdge e, eTail, eHead;

            for (e = eOrig; !Marked(e.Lface); ++tailSize, e = e.Onext)
            {
                trail = AddToTrail(e.Lface, trail);
                ++tailSize;
                e = e.Lnext.Sym;
                if (Marked(e.Lface))
                    break;
                trail = AddToTrail(e.Lface, trail);
            }
            eTail = e;

            for (e = eOrig; !Marked(e.Sym.Lface); ++headSize, e = e.Sym.Onext.Sym)
            {
                trail = AddToTrail(e.Sym.Lface, trail);
                ++headSize;
                e = e.Sym.Lnext;
                if (Marked(e.Sym.Lface))
                    break;
                trail = AddToTrail(e.Sym.Lface, trail);
            }
            eHead = e;

            newFace.size = tailSize + headSize;
            if (IsEven(tailSize))
            {
                newFace.eStart = eTail.Sym;
            }
            else if (IsEven(headSize))
            {
                newFace.eStart = eHead;
            }
            else
            {
                /* Both sides have odd length, we must shorten one of them.  In fact,
                * we must start from eHead to guarantee inclusion of eOrig.Lface.
                */
                --newFace.size;
                newFace.eStart = eHead.Onext;
            }
            /*LINTED*/
            FreeTrail(trail);
            return newFace;
        }
Exemplo n.º 6
0
        internal static FaceCount MaximumFan(Mogre.Utils.GluTesselator.GLUhalfEdge eOrig)
        {
            /* eOrig.Lface is the face we want to render.  We want to find the size
            * of a maximal fan around eOrig.Org.  To do this we just walk around
            * the origin vertex as far as possible in both directions.
            */
            FaceCount newFace = new FaceCount(0, null, renderFan);
            Mogre.Utils.GluTesselator.GLUface trail = null;
            Mogre.Utils.GluTesselator.GLUhalfEdge e;

            for (e = eOrig; !Marked(e.Lface); e = e.Onext)
            {
                trail = AddToTrail(e.Lface, trail);
                ++newFace.size;
            }
            for (e = eOrig; !Marked(e.Sym.Lface); e = e.Sym.Lnext)
            {
                trail = AddToTrail(e.Sym.Lface, trail);
                ++newFace.size;
            }
            newFace.eStart = e;
            /*LINTED*/
            FreeTrail(trail);
            return newFace;
        }
Exemplo n.º 7
0
        void RenderMaximumFaceGroup(Face fOrig)
        {
            /* We want to find the largest triangle fan or strip of unmarked faces
            * which includes the given face fOrig.  There are 3 possible fans
            * passing through fOrig (one centered at each vertex), and 3 possible
            * strips (one for each CCW permutation of the vertices).  Our strategy
            * is to try all of these, and take the primitive which uses the most
            * triangles (a greedy approach).
            */
            HalfEdge e = fOrig.halfEdgeThisIsLeftFaceOf;
            FaceCount max = new FaceCount(1, e, new FaceCount.RenderDelegate(RenderTriangle));
            FaceCount newFace;

            max.size = 1;
            max.eStart = e;

            if (!this.EdgeCallBackSet)
            {
                newFace = MaximumFan(e); if (newFace.size > max.size) { max = newFace; }
                newFace = MaximumFan(e.nextEdgeCCWAroundLeftFace); if (newFace.size > max.size) { max = newFace; }
                newFace = MaximumFan(e.Lprev); if (newFace.size > max.size) { max = newFace; }

                newFace = MaximumStrip(e); if (newFace.size > max.size) { max = newFace; }
                newFace = MaximumStrip(e.nextEdgeCCWAroundLeftFace); if (newFace.size > max.size) { max = newFace; }
                newFace = MaximumStrip(e.Lprev); if (newFace.size > max.size) { max = newFace; }
            }

            max.CallRender(this, max.eStart, max.size);
        }
Exemplo n.º 8
0
        FaceCount MaximumStrip(HalfEdge eOrig)
        {
            /* Here we are looking for a maximal strip that contains the vertices
            * eOrig.Org, eOrig.Dst, eOrig.Lnext.Dst (in that order or the
            * reverse, such that all triangles are oriented CCW).
            *
            * Again we walk forward and backward as far as possible.  However for
            * strips there is a twist: to get CCW orientations, there must be
            * an *even* number of triangles in the strip on one side of eOrig.
            * We walk the strip starting on a side with an even number of triangles;
            * if both side have an odd number, we are forced to shorten one side.
            */
            FaceCount newFace = new FaceCount(0, null, RenderStrip);
            int headSize = 0, tailSize = 0;
            Face trail = null;
            HalfEdge e, eTail, eHead;

            for (e = eOrig; !e.leftFace.Marked(); ++tailSize, e = e.nextEdgeCCWAroundOrigin)
            {
                Face.AddToTrail(ref e.leftFace, ref trail);
                ++tailSize;
                e = e.Dprev;
                if (e.leftFace.Marked()) break;
                Face.AddToTrail(ref e.leftFace, ref trail);
            }
            eTail = e;

            for (e = eOrig; !e.rightFace.Marked(); ++headSize, e = e.Dnext)
            {
                Face f = e.rightFace;
                Face.AddToTrail(ref f, ref trail);
                e.rightFace = f;
                ++headSize;
                e = e.Oprev;
                if (e.rightFace.Marked()) break;
                f = e.rightFace;
                Face.AddToTrail(ref f, ref trail);
                e.rightFace = f;
            }
            eHead = e;

            newFace.size = tailSize + headSize;
            if (IsEven(tailSize))
            {
                newFace.eStart = eTail.otherHalfOfThisEdge;
            }
            else if (IsEven(headSize))
            {
                newFace.eStart = eHead;
            }
            else
            {
                /* Both sides have odd length, we must shorten one of them.  In fact,
                * we must start from eHead to guarantee inclusion of eOrig.Lface.
                */
                --newFace.size;
                newFace.eStart = eHead.nextEdgeCCWAroundOrigin;
            }

            Face.FreeTrail(ref trail);
            return newFace;
        }
Exemplo n.º 9
0
        FaceCount MaximumFan(HalfEdge eOrig)
        {
            /* eOrig.Lface is the face we want to render.  We want to find the size
            * of a maximal fan around eOrig.Org.  To do this we just walk around
            * the origin vertex as far as possible in both directions.
            */
            FaceCount newFace = new FaceCount(0, null, new FaceCount.RenderDelegate(RenderFan));
            Face trail = null;
            HalfEdge e;

            for (e = eOrig; !e.leftFace.Marked(); e = e.nextEdgeCCWAroundOrigin)
            {
                Face.AddToTrail(ref e.leftFace, ref trail);
                ++newFace.size;
            }
            for (e = eOrig; !e.rightFace.Marked(); e = e.Oprev)
            {
                Face f = e.rightFace;
                Face.AddToTrail(ref f, ref trail);
                e.rightFace = f;
                ++newFace.size;
            }
            newFace.eStart = e;

            Face.FreeTrail(ref trail);
            return newFace;
        }
Exemplo n.º 10
0
        internal static FaceCount MaximumStrip(Mogre.Utils.GluTesselator.GLUhalfEdge eOrig)
        {
            /* Here we are looking for a maximal strip that contains the vertices
             * eOrig.Org, eOrig.Dst, eOrig.Lnext.Dst (in that order or the
             * reverse, such that all triangles are oriented CCW).
             *
             * Again we walk forward and backward as far as possible.  However for
             * strips there is a twist: to get CCW orientations, there must be
             * an *even* number of triangles in the strip on one side of eOrig.
             * We walk the strip starting on a side with an even number of triangles;
             * if both side have an odd number, we are forced to shorten one side.
             */
            FaceCount newFace = new FaceCount(0, null, renderStrip);
            long      headSize = 0, tailSize = 0;

            Mogre.Utils.GluTesselator.GLUface     trail = null;
            Mogre.Utils.GluTesselator.GLUhalfEdge e, eTail, eHead;

            for (e = eOrig; !Marked(e.Lface); ++tailSize, e = e.Onext)
            {
                trail = AddToTrail(e.Lface, trail);
                ++tailSize;
                e = e.Lnext.Sym;
                if (Marked(e.Lface))
                {
                    break;
                }
                trail = AddToTrail(e.Lface, trail);
            }
            eTail = e;

            for (e = eOrig; !Marked(e.Sym.Lface); ++headSize, e = e.Sym.Onext.Sym)
            {
                trail = AddToTrail(e.Sym.Lface, trail);
                ++headSize;
                e = e.Sym.Lnext;
                if (Marked(e.Sym.Lface))
                {
                    break;
                }
                trail = AddToTrail(e.Sym.Lface, trail);
            }
            eHead = e;

            newFace.size = tailSize + headSize;
            if (IsEven(tailSize))
            {
                newFace.eStart = eTail.Sym;
            }
            else if (IsEven(headSize))
            {
                newFace.eStart = eHead;
            }
            else
            {
                /* Both sides have odd length, we must shorten one of them.  In fact,
                 * we must start from eHead to guarantee inclusion of eOrig.Lface.
                 */
                --newFace.size;
                newFace.eStart = eHead.Onext;
            }
            /*LINTED*/
            FreeTrail(trail);
            return(newFace);
        }