TessPolygon() public method

public TessPolygon ( float vertex2dCoords ) : List
vertex2dCoords float
return List
Example #1
0
        /// <summary>
        /// tess and read result as triangle list index array (for GLES draw element)
        /// </summary>
        /// <param name="tessTool"></param>
        /// <param name="vertex2dCoords"></param>
        /// <param name="contourEndPoints"></param>
        /// <param name="outputCoords"></param>
        /// <param name="vertexCount"></param>
        /// <returns></returns>
        internal static void TessAndAddToMultiPartResult(this TessTool tessTool,
                                                         float[] vertex2dCoords,
                                                         int[] contourEndPoints,
                                                         MultiPartTessResult multipartTessResult,
                                                         out int vertexCount)
        {
            if (!tessTool.TessPolygon(vertex2dCoords, contourEndPoints))
            {
                vertexCount = 0;
                return;
            }
            //-----------------------------
            //results
            //1.
            List <ushort> indexList = tessTool.TessIndexList;
            //2.
            List <TessTempVertex> tempVertexList = tessTool.TempVertexList;

            //3.
            vertexCount = indexList.Count;
            //-----------------------------
            multipartTessResult.BeginPart();
            multipartTessResult.AddTessCoords(vertex2dCoords);
            //append with newly create vertex(from tempVertList)
            int tempVertListCount = tempVertexList.Count;

            for (int i = 0; i < tempVertListCount; ++i)
            {
                TessTempVertex v = tempVertexList[i];
                multipartTessResult.AddTessCoord((float)v.m_X, (float)v.m_Y);
            }
            multipartTessResult.AddVertexIndexList(indexList);
            multipartTessResult.EndPart();
        }
Example #2
0
 public float[] GetAreaTess(ref TessTool tess)
 {
     if (areaTess == null)
     {
         List <Vertex> vertextList = tess.TessPolygon(coordXYs);
         if (vertextList == null)
         {
             tessAreaTriangleCount = 0;
             return(null);
         }
         //-----------------------------
         //switch how to fill polygon
         int     j   = vertextList.Count;
         float[] vtx = new float[j * 2];
         int     n   = 0;
         for (int p = 0; p < j; ++p)
         {
             var v = vertextList[p];
             vtx[n]     = (float)v.m_X;
             vtx[n + 1] = (float)v.m_Y;
             n         += 2;
         }
         //triangle list
         tessAreaTriangleCount = j;
         //-------------------------------------
         return(this.areaTess = vtx);
     }
     return(areaTess);
 }
Example #3
0
        /// <summary>
        /// tess and read result as triangle list index array (for GLES draw element)
        /// </summary>
        /// <param name="tessTool"></param>
        /// <param name="vertex2dCoords"></param>
        /// <param name="contourEndPoints"></param>
        /// <param name="outputCoords"></param>
        /// <param name="vertexCount"></param>
        /// <returns></returns>
        public static ushort[] TessAsTriIndexArray(this TessTool tessTool,
                                                   float[] vertex2dCoords,
                                                   int[] contourEndPoints,
                                                   out float[] outputCoords,
                                                   out int vertexCount)
        {
            if (!tessTool.TessPolygon(vertex2dCoords, contourEndPoints))
            {
                vertexCount  = 0;
                outputCoords = null;
                return(null); //* early exit
            }
            //results
            //1.
            List <ushort> indexList = tessTool.TessIndexList;
            //2.
            List <TessTempVertex> tempVertexList = tessTool.TempVertexList;

            //3.
            vertexCount = indexList.Count;
            //-----------------------------

            //create a new array and append with original and new tempVertex list
            int tempVertListCount = tempVertexList.Count;

            outputCoords = new float[vertex2dCoords.Length + tempVertListCount * 2];
            //1. copy original array
            Array.Copy(vertex2dCoords, outputCoords, vertex2dCoords.Length);
            //2. append with newly create vertex (from tempVertList)
            int endAt = vertex2dCoords.Length + tempVertListCount;
            int p     = 0;
            int q     = vertex2dCoords.Length; //start adding at

            for (int i = vertex2dCoords.Length; i < endAt; ++i)
            {
                TessTempVertex v = tempVertexList[p];
                outputCoords[q]     = (float)v.m_X;
                outputCoords[q + 1] = (float)v.m_Y;
                p++;
                q += 2;
            }

            return(indexList.ToArray());
        }
Example #4
0
        /// <summary>
        /// tess and read result as triangle list vertex array (for GLES draw-array)
        /// </summary>
        /// <param name="tessTool"></param>
        /// <param name="vertex2dCoords"></param>
        /// <param name="contourEndPoints"></param>
        /// <param name="vertexCount"></param>
        /// <returns></returns>
        public static float[] TessAsTriVertexArray(this TessTool tessTool, float[] vertex2dCoords, int[] contourEndPoints, out int vertexCount)
        {
            if (!tessTool.TessPolygon(vertex2dCoords, contourEndPoints))
            {
                vertexCount = 0;
                return(null);
            }
            //results
            //1.
            List <ushort> indexList = tessTool.TessIndexList;
            //2.
            List <TessTempVertex> tempVertexList = tessTool.TempVertexList;

            //3.
            vertexCount = indexList.Count;
            //-----------------------------
            int orgVertexCount = vertex2dCoords.Length / 2;

            float[] vtx = new float[vertexCount * 2];//***
            int     n   = 0;

            for (int p = 0; p < vertexCount; ++p)
            {
                ushort index = indexList[p];
                if (index >= orgVertexCount)
                {
                    //extra coord (newly created)
                    TessTempVertex extraVertex = tempVertexList[index - orgVertexCount];
                    vtx[n]     = (float)extraVertex.m_X;
                    vtx[n + 1] = (float)extraVertex.m_Y;
                }
                else
                {
                    //original corrd
                    vtx[n]     = (float)vertex2dCoords[index * 2];
                    vtx[n + 1] = (float)vertex2dCoords[(index * 2) + 1];
                }
                n += 2;
            }
            //triangle list
            return(vtx);
        }
 public float[] GetAreaTess(ref TessTool tess)
 {
     if (areaTess == null)
     {
         List<Vertex> vertextList = tess.TessPolygon(coordXYs);
         //-----------------------------   
         //switch how to fill polygon
         int j = vertextList.Count;
         float[] vtx = new float[j * 2];
         int n = 0;
         for (int p = 0; p < j; ++p)
         {
             var v = vertextList[p];
             vtx[n] = (float)v.m_X;
             vtx[n + 1] = (float)v.m_Y;
             n += 2;
         }
         //triangle list
         tessAreaTriangleCount = j;
         //-------------------------------------                              
         return this.areaTess = vtx;
     }
     return areaTess;
 }