public string FirstEdge(Mesh mesh, out List <int> firstLoop1)
        {
            Rhino.Geometry.Collections.MeshTopologyEdgeList   el = mesh.TopologyEdges;
            Rhino.Geometry.Collections.MeshTopologyVertexList vs = mesh.TopologyVertices;
            firstLoop1 = new List <int>();
            int firstPoint = -1;

            for (int i = 0; i < vs.Count; i++)
            {
                if (vs.ConnectedTopologyVertices(i).Length == 2)
                {
                    firstPoint = i; break;
                }
            }
            if (firstPoint == -1)
            {
                return("can not find a 2 degree Vertex,Please check the mesh boundary");
            }
            int SecondPoint = vs.ConnectedTopologyVertices(firstPoint)[0];
            int ThirdPoint  = vs.ConnectedTopologyVertices(firstPoint)[1];
            int firstPoint1 = firstPoint;

            firstLoop1.Add(firstPoint);



            if (vs.ConnectedTopologyVertices(ThirdPoint).Length == 2)
            {
                firstLoop1.Add(ThirdPoint);
            }
            else if (vs.ConnectedTopologyVertices(SecondPoint).Length == 2)
            {
                firstLoop1.Add(SecondPoint);
            }
            else
            {
                firstLoop1.Add(SecondPoint);
                for (int i = 0; i < vs.Count; i++)
                {
                    bool  stop  = false;
                    int[] index = vs.ConnectedTopologyVertices(SecondPoint);
                    for (int j = 0; j < index.Length; j++)
                    {
                        if (index[j] != firstPoint1)
                        {
                            if (vs.ConnectedTopologyVertices(index[j]).Length == 3)
                            {
                                firstPoint1 = SecondPoint;
                                SecondPoint = index[j];
                                firstLoop1.Add(SecondPoint);
                                break;
                            }//if
                            if (vs.ConnectedTopologyVertices(index[j]).Length == 2)
                            {
                                firstPoint1 = SecondPoint;
                                SecondPoint = index[j];
                                firstLoop1.Add(SecondPoint);
                                stop = true;
                                break;
                            }//if
                        }
                    }
                    if (stop)
                    {
                        break;
                    }
                }
            }
            return("Done");
        }
        public string Mesh2Mesh(Mesh mesh, out Mesh s, double uscale, double vscale)
        {
            Rhino.Geometry.Collections.MeshTopologyEdgeList   el = mesh.TopologyEdges;
            Rhino.Geometry.Collections.MeshTopologyVertexList vs = mesh.TopologyVertices;
            string     str = "";
            List <int> firstLoop1;

            str += FirstEdge(mesh, out firstLoop1);
            double column = (double)vs.Count / (double)firstLoop1.Count;
            int    Column = (int)column;

            if (column - Column != 0)
            {
                str += "Points Count error,Please confirm the topo to be quad style";
            }
            int[]      energy  = new int[vs.Count];
            List <int> indexPt = new List <int>();

            indexPt.AddRange(firstLoop1);
            for (int i = 0; i < firstLoop1.Count; i++)
            {
                energy[firstLoop1[i]] = 1;
            }
            for (int i = 0; i < Column - 1; i++)
            {
                bool sign = true;
                for (int j = 0; j < firstLoop1.Count; j++)
                {
                    int[] index = vs.ConnectedTopologyVertices(firstLoop1[j]);
                    for (int k = 0; k < index.Length; k++)
                    {
                        //Print("j:" + j.ToString() + " k:" + k.ToString() + " energy: " + energy[index[k]].ToString());////////
                        energy[index[k]]++;
                    }
                }
                //Print("///");
                for (int j = 0; j < firstLoop1.Count; j++)
                {
                    int[] index = vs.ConnectedTopologyVertices(firstLoop1[j]);
                    for (int k = 0; k < index.Length; k++)
                    {
                        // Print("j:" + j.ToString() + " k:" + k.ToString() + " energy: " + energy[index[k]].ToString());////////
                        if (energy[index[k]] == 1)
                        {
                            firstLoop1[j] = index[k]; sign = false; break;
                        }
                    }
                }
                if (sign)
                {
                    str += " Loop false,Not quad topo Or To the end";
                }
                else
                {
                    indexPt.AddRange(firstLoop1);
                }
            }
            List <Point3d> output1 = new List <Point3d>();

            for (int i = 0; i < indexPt.Count; i++)
            {
                output1.Add(vs[indexPt[i]]);
            }

            //   s = NurbsSurface.CreateFromPoints(output1, Column, firstLoop1.Count, 3, 3);

            s = mc.MeshFromPoints(output1, firstLoop1.Count, Column, uscale, vscale);
            return(str);
        }
        public string Mesh2Topo(ref Mesh mesh, out Mesh mesh2, double length, double width, double mX, double mY, double maxX, double maxY)
        {
            //
            //construct a single bitmap but the edge is not fit well.The Vt has not been tested yet.
            //
            Rhino.Geometry.Collections.MeshTopologyEdgeList   el = mesh.TopologyEdges;
            Rhino.Geometry.Collections.MeshTopologyVertexList vs = mesh.TopologyVertices;
            string     str = "";
            List <int> firstLoop1;

            str += FirstEdge(mesh, out firstLoop1);
            double column = (double)vs.Count / (double)firstLoop1.Count;
            int    Column = (int)column;

            if (column - Column != 0)
            {
                str += "Points Count error,Please confirm the topo to be quad style";
            }
            int[]      energy  = new int[vs.Count];
            List <int> indexPt = new List <int>();

            indexPt.AddRange(firstLoop1);
            for (int i = 0; i < firstLoop1.Count; i++)
            {
                energy[firstLoop1[i]] = 1;
            }
            for (int i = 0; i < Column - 1; i++)
            {
                bool sign = true;
                for (int j = 0; j < firstLoop1.Count; j++)
                {
                    int[] index = vs.ConnectedTopologyVertices(firstLoop1[j]);
                    for (int k = 0; k < index.Length; k++)
                    {
                        energy[index[k]]++;
                    }
                }
                for (int j = 0; j < firstLoop1.Count; j++)
                {
                    int[] index = vs.ConnectedTopologyVertices(firstLoop1[j]);
                    for (int k = 0; k < index.Length; k++)
                    {
                        if (energy[index[k]] == 1)
                        {
                            firstLoop1[j] = index[k]; sign = false; break;
                        }
                    }
                }
                if (sign)
                {
                    str += " Loop false,Not quad topo Or To the end";
                }
                else
                {
                    indexPt.AddRange(firstLoop1);
                }
            }
            ///*******
            double         MX      = (double)Column - 1;
            double         MY      = (double)firstLoop1.Count - 1;
            List <Point3d> output1 = new List <Point3d>();
            List <Point3d> output2 = new List <Point3d>();
            int            iCount  = 0;

            Color[] cl = new Color[mesh.Vertices.Count];

            for (int i = 0; i < Column; i++)
            {
                for (int j = 0; j < firstLoop1.Count; j++)
                {
                    output1.Add(vs[indexPt[iCount]]);
                    int indexV = vs.MeshVertexIndices(indexPt[iCount])[0];
                    cl[iCount] = mesh.VertexColors[indexV];
                    iCount++;
                    Point3d pt = new Point3d(length / MX * i, width / MY * (double)j, 0);
                    output2.Add(pt);
                }
            }
            mesh2 = mc.MeshFromPoints(output2, firstLoop1.Count, Column);
            mesh  = mc.MeshFromPoints(output1, firstLoop1.Count, Column);
            mesh2.Transform(Transform.Translation(mX, mY, 0));
            mesh.VertexColors.Clear();
            mesh.VertexColors.AppendColors(cl);
            mesh2.VertexColors.Clear();
            mesh2.VertexColors.AppendColors(cl);
            iCount = 0;
            //Print(mesh.TextureCoordinates.Count.ToString());//unit=100
            for (double i = 0; i < Column; i++)
            {
                for (double j = 0; j < firstLoop1.Count; j++)
                {
                    //not tested
                    mesh.TextureCoordinates.Add(new Point2f((Single)((i * length / MX + mX) / maxX),
                                                            (Single)(j * width / MY + mY) / maxY));
                    mesh2.TextureCoordinates.Add(new Point2f((Single)((i * length / MX + mX) / maxX),
                                                             (Single)(j * width / MY + mY) / maxY));
                    iCount++;
                }
            }
            return(str);
        }
        /// 2Nurbs
        ///
        public string Mesh2Topo(ref Mesh mesh, out Mesh mesh2, int edge, out IndexPair data)
        {
            Rhino.Geometry.Collections.MeshTopologyEdgeList   el = mesh.TopologyEdges;
            Rhino.Geometry.Collections.MeshTopologyVertexList vs = mesh.TopologyVertices;
            string     str = "";
            List <int> firstLoop1;

            str += FirstEdge(mesh, out firstLoop1);
            double column = (double)vs.Count / (double)firstLoop1.Count;
            int    Column = (int)column;

            if (column - Column != 0)
            {
                str += "Points Count error,Please confirm the topo to be quad style";
            }
            int[]      energy  = new int[vs.Count];
            List <int> indexPt = new List <int>();

            indexPt.AddRange(firstLoop1);
            for (int i = 0; i < firstLoop1.Count; i++)
            {
                energy[firstLoop1[i]] = 1;
            }
            for (int i = 0; i < Column - 1; i++)
            {
                bool sign = true;
                for (int j = 0; j < firstLoop1.Count; j++)
                {
                    int[] index = vs.ConnectedTopologyVertices(firstLoop1[j]);
                    for (int k = 0; k < index.Length; k++)
                    {
                        energy[index[k]]++;
                    }
                }
                for (int j = 0; j < firstLoop1.Count; j++)
                {
                    int[] index = vs.ConnectedTopologyVertices(firstLoop1[j]);
                    for (int k = 0; k < index.Length; k++)
                    {
                        if (energy[index[k]] == 1)
                        {
                            firstLoop1[j] = index[k]; sign = false; break;
                        }
                    }
                }
                if (sign)
                {
                    str += " Loop false,Not quad topo Or To the end";
                }
                else
                {
                    indexPt.AddRange(firstLoop1);
                }
            }
            ///
            ///*******
            double         MX      = (double)Column - 1;
            double         MY      = (double)firstLoop1.Count - 1;
            List <Point3d> output1 = new List <Point3d>();
            List <Point3d> output2 = new List <Point3d>();
            int            iCount  = 0;

            Color[] cl = new Color[mesh.Vertices.Count];
            //edge
            List <int> pl1 = new List <int>();
            List <int> pl2 = new List <int>();
            List <int> pl3 = new List <int>();
            List <int> pl4 = new List <int>();
            int        edge1 = 0, edge2 = 0, edge3 = 0, edge4 = 0;

            //////////
            for (int i = 0; i < Column; i++)
            {
                for (int j = 0; j < firstLoop1.Count; j++)
                {
                    if (i == 0)
                    {
                        pl1.Add(iCount);
                    }
                    if (i == column - 1)
                    {
                        pl3.Add(iCount);
                    }
                    if (j == 0)
                    {
                        pl2.Add(iCount);
                    }
                    if (j == firstLoop1.Count - 1)
                    {
                        pl4.Add(iCount);
                    }
                    if (i == 0 && j == 0)
                    {
                        edge1 = iCount;
                    }
                    if (i == 0 && j == firstLoop1.Count - 1)
                    {
                        edge2 = iCount;
                    }
                    if (i == column - 1 && j == firstLoop1.Count - 1)
                    {
                        edge3 = iCount;
                    }
                    if (i == column - 1 && j == 0)
                    {
                        edge4 = iCount;
                    }
                    output1.Add(vs[indexPt[iCount]]);
                    int indexV = vs.MeshVertexIndices(indexPt[iCount])[0];
                    cl[iCount] = mesh.VertexColors[indexV];
                    iCount++;
                    Point3d pt = new Point3d(edge * i, edge * j, 0);
                    output2.Add(pt);
                }
            }
            mesh2 = mc.MeshFromPoints(output2, firstLoop1.Count, Column);
            mesh  = mc.MeshFromPoints(output1, firstLoop1.Count, Column);
            mesh.VertexColors.Clear();
            mesh.VertexColors.AppendColors(cl);
            mesh2.VertexColors.Clear();
            mesh2.VertexColors.AppendColors(cl);
            ///edge
            List <Point3d> pts;


            /////////////////////////////////////////////////////////
            Color[] cl1 = new Color[pl1.Count * 2]; pts = new List <Point3d>();
            for (int i = 0; i < pl1.Count; i++)
            {
                pts.Add(new Point3d(mesh2.Vertices[pl1[i]]));
                pts.Add((Point3d)mesh2.Vertices[pl1[i]] + new Vector3d(-edge, 0, 0));
                cl1[i * 2] = mesh2.VertexColors[pl1[i]]; cl1[i * 2 + 1] = mesh2.VertexColors[pl1[i]];
            }
            Mesh mesh3 = mc.MeshFromPoints(pts, 2, pl1.Count);

            mesh3.VertexColors.AppendColors(cl1);
            mesh2.Append(mesh3);
            /////////////////////////////////////////////////////////
            Color[] cl2 = new Color[pl2.Count * 2]; pts = new List <Point3d>();
            for (int i = 0; i < pl2.Count; i++)
            {
                pts.Add(new Point3d(mesh2.Vertices[pl2[i]]));
                pts.Add((Point3d)mesh2.Vertices[pl2[i]] + new Vector3d(0, -edge, 0));
                cl2[i * 2] = mesh2.VertexColors[pl2[i]]; cl2[i * 2 + 1] = mesh2.VertexColors[pl2[i]];
            }
            mesh3 = mc.MeshFromPoints(pts, 2, pl2.Count);
            mesh3.VertexColors.AppendColors(cl2);
            mesh2.Append(mesh3);
            /////////////////////////////////////////////////////////
            Color[] cl3 = new Color[pl3.Count * 2]; pts = new List <Point3d>();
            for (int i = 0; i < pl3.Count; i++)
            {
                pts.Add(new Point3d(mesh2.Vertices[pl3[i]]));
                pts.Add((Point3d)mesh2.Vertices[pl3[i]] + new Vector3d(edge, 0, 0));
                cl3[i * 2] = mesh2.VertexColors[pl3[i]]; cl3[i * 2 + 1] = mesh2.VertexColors[pl3[i]];
            }
            mesh3 = mc.MeshFromPoints(pts, 2, pl3.Count);
            mesh3.VertexColors.AppendColors(cl3);
            mesh2.Append(mesh3);
            /////////////////////////////////////////////////////////
            Color[] cl4 = new Color[pl4.Count * 2]; pts = new List <Point3d>();
            for (int i = 0; i < pl4.Count; i++)
            {
                pts.Add(new Point3d(mesh2.Vertices[pl4[i]]));
                pts.Add((Point3d)mesh2.Vertices[pl4[i]] + new Vector3d(0, edge, 0));
                cl4[i * 2] = mesh2.VertexColors[pl4[i]]; cl4[i * 2 + 1] = mesh2.VertexColors[pl4[i]];
            }
            mesh3 = mc.MeshFromPoints(pts, 2, pl4.Count);
            mesh3.VertexColors.AppendColors(cl4);
            mesh2.Append(mesh3);
            /////////////////////////////////////////////////////////

            Point3d ept = (Point3d)mesh2.Vertices[edge1];

            mesh3 = mc.MeshFromPoints(ept, ept + new Vector3d(-edge, 0, 0), ept + new Vector3d(-edge, -edge, 0), ept + new Vector3d(0, -edge, 0));
            mesh3.VertexColors.Add(mesh2.VertexColors[edge1]);
            mesh3.VertexColors.Add(mesh2.VertexColors[edge1]);
            mesh3.VertexColors.Add(mesh2.VertexColors[edge1]);
            mesh3.VertexColors.Add(mesh2.VertexColors[edge1]);
            mesh2.Append(mesh3);
            ept   = (Point3d)mesh2.Vertices[edge2];
            mesh3 = mc.MeshFromPoints(ept, ept + new Vector3d(-edge, 0, 0), ept + new Vector3d(-edge, edge, 0), ept + new Vector3d(0, edge, 0));
            mesh3.VertexColors.Add(mesh2.VertexColors[edge2]);
            mesh3.VertexColors.Add(mesh2.VertexColors[edge2]);
            mesh3.VertexColors.Add(mesh2.VertexColors[edge2]);
            mesh3.VertexColors.Add(mesh2.VertexColors[edge2]);
            mesh2.Append(mesh3);
            ept   = (Point3d)mesh2.Vertices[edge3];
            mesh3 = mc.MeshFromPoints(ept, ept + new Vector3d(edge, 0, 0), ept + new Vector3d(edge, edge, 0), ept + new Vector3d(0, edge, 0));
            mesh3.VertexColors.Add(mesh2.VertexColors[edge3]);
            mesh3.VertexColors.Add(mesh2.VertexColors[edge3]);
            mesh3.VertexColors.Add(mesh2.VertexColors[edge3]);
            mesh3.VertexColors.Add(mesh2.VertexColors[edge3]);
            mesh2.Append(mesh3);
            ept   = (Point3d)mesh2.Vertices[edge4];
            mesh3 = mc.MeshFromPoints(ept, ept + new Vector3d(edge, 0, 0), ept + new Vector3d(edge, -edge, 0), ept + new Vector3d(0, -edge, 0));
            mesh3.VertexColors.Add(mesh2.VertexColors[edge4]);
            mesh3.VertexColors.Add(mesh2.VertexColors[edge4]);
            mesh3.VertexColors.Add(mesh2.VertexColors[edge4]);
            mesh3.VertexColors.Add(mesh2.VertexColors[edge4]);
            mesh2.Append(mesh3);


            //////////////////////////////////////////////////////
            for (double i = 1; i <= Column; i++)
            {
                for (double j = 1; j <= firstLoop1.Count; j++)
                {
                    mesh.TextureCoordinates.Add(i / (Column + 1), j / (firstLoop1.Count + 1));
                }
            }
            data = new IndexPair((Column + 1) * edge, (firstLoop1.Count + 1) * edge);
            return(str);
        }
Beispiel #5
0
        public Mesh Catmull_Clark(Mesh x)
        {
            Mesh           mesh = new Mesh();
            List <Point3d> pv   = new List <Point3d>();
            List <Point3d> pe   = new List <Point3d>();
            List <Point3d> pf   = new List <Point3d>();

            Rhino.Geometry.Collections.MeshTopologyVertexList vs = x.TopologyVertices;
            Rhino.Geometry.Collections.MeshTopologyEdgeList   el = x.TopologyEdges;
            for (int i = 0; i < x.Faces.Count; i++)
            {
                int[]   index = vs.IndicesFromFace(i);
                Point3d pf1   = new Point3d();
                for (int j = 0; j < index.Length; j++)
                {
                    pf1 += vs[index[j]];
                }
                pf1 /= index.Length;
                pf.Add(pf1);
            }
            for (int i = 0; i < el.Count; i++)
            {
                IndexPair pair  = el.GetTopologyVertices(i);
                Point3d   pe1   = vs[pair.I] + vs[pair.J];
                int[]     index = el.GetConnectedFaces(i);
                if (index.Length == 2)
                {
                    pe1 += pf[index[0]] + pf[index[1]];
                    pe1 /= 4.0;
                }
                else
                {
                    pe1 = pe1 / 2.0;
                }
                pe.Add(pe1);
            }
            for (int i = 0; i < vs.Count; i++)
            {
                int[]   index  = vs.ConnectedEdges(i);
                int[]   index2 = vs.ConnectedFaces(i);
                Point3d V      = vs[i];
                if (index.Length == index2.Length)
                {
                    Point3d R = new Point3d(), Q = new Point3d();
                    for (int j = 0; j < index.Length; j++)
                    {
                        IndexPair pair = el.GetTopologyVertices(index[j]);
                        Point3d   pe1  = (vs[pair.I] + vs[pair.J]) * 0.5f;
                        R += pe1;
                    }
                    R /= index.Length;
                    for (int j = 0; j < index2.Length; j++)
                    {
                        Q += pf[index2[j]];
                    }
                    Q /= index2.Length;

                    int n = vs.ConnectedTopologyVertices(i).Length;
                    V  = Q + (R * 2) + V * (n - 3);
                    V /= n;
                }
                else
                {
                    Point3d R = new Point3d();
                    for (int j = 0; j < index.Length; j++)
                    {
                        if (el.GetConnectedFaces(index[j]).Length == 1)
                        {
                            IndexPair pair = el.GetTopologyVertices(index[j]);
                            R += vs[pair.I] + vs[pair.J];
                        }
                    }
                    V = R * 0.125f + V * 0.5;
                }
                pv.Add(V);
            }
            mesh.Vertices.AddVertices(pv);
            mesh.Vertices.AddVertices(pe);
            mesh.Vertices.AddVertices(pf);
            for (int i = 0; i < x.Faces.Count; i++)
            {
                int[] index = vs.IndicesFromFace(i);
                if (x.Faces[i].IsQuad)
                {
                    int pc = pv.Count + pe.Count + i;
                    int p1 = index[0]; int p2 = index[1]; int p3 = index[2]; int p4 = index[3];
                    int p12 = el.GetEdgeIndex(p1, p2) + pv.Count;
                    int p23 = el.GetEdgeIndex(p2, p3) + pv.Count;
                    int p34 = el.GetEdgeIndex(p3, p4) + pv.Count;
                    int p41 = el.GetEdgeIndex(p4, p1) + pv.Count;
                    mesh.Faces.AddFace(p1, p12, pc, p41);
                    mesh.Faces.AddFace(p12, p2, p23, pc);
                    mesh.Faces.AddFace(pc, p23, p3, p34);
                    mesh.Faces.AddFace(p41, pc, p34, p4);
                }
                else if (x.Faces[i].IsTriangle)
                {
                    int pc = pv.Count + pe.Count + i;
                    int p1 = index[0]; int p2 = index[1]; int p3 = index[2];
                    int p12 = el.GetEdgeIndex(p1, p2) + pv.Count;
                    int p23 = el.GetEdgeIndex(p2, p3) + pv.Count;
                    int p31 = el.GetEdgeIndex(p3, p1) + pv.Count;
                    mesh.Faces.AddFace(p1, p12, pc, p31);
                    mesh.Faces.AddFace(p12, p2, p23, pc);
                    mesh.Faces.AddFace(pc, p23, p3, p31);
                }
            }
            mesh.UnifyNormals();
            return(mesh);
        }
Beispiel #6
0
        private List <MeshSimplify_Point> preDivide(Mesh mesh)
        {
            Rhino.Geometry.Collections.MeshTopologyEdgeList   el = mesh.TopologyEdges;
            Rhino.Geometry.Collections.MeshTopologyVertexList vs = mesh.TopologyVertices;
            List <MeshSimplify_Point> PointList = new List <MeshSimplify_Point>();

            for (int i = 0; i < vs.Count; i++)
            {
                MeshSimplify_Point pt = new MeshSimplify_Point(vs[i]);
                if (vs.MeshVertexIndices(i).Length > 0)
                {
                    pt.N = mesh.Normals[vs.MeshVertexIndices(i)[0]];
                }
                else
                {
                    pt.computeNormal(mesh);
                }
                PointList.Add(pt);
            }
            for (int i = 0; i < vs.Count; i++)
            {
                int[] index = vs.ConnectedTopologyVertices(i);
                for (int j = 0; j < index.Length; j++)
                {
                    PointList[i].refpoints.Add(PointList[index[j]]);
                }
                PointList[i].Sort();
            }

            /////////////////////////////////////////////////////
            for (int i = 0; i < vs.Count; i++)
            {
                PointList[i].order = 0;
            }
            for (int i = 0; i < el.Count; i++)
            {
                if (el.GetConnectedFaces(i).Length == 1)
                {
                    PointList[el.GetTopologyVertices(i).I].order = 5;
                    PointList[el.GetTopologyVertices(i).J].order = 5;
                }
            }
            for (int i = 0; i < vs.Count; i++)
            {
                if (PointList[i].order == 5)
                {
                    if (PointList[i].refpoints.Count != 3)
                    {
                        PointList[i].order = 4;
                    }
                }
                else
                {
                    if (PointList[i].refpoints.Count != 4)
                    {
                        PointList[i].order = 4;
                    }
                }
            }
            //////////////////////////////////////////////////////////
            for (int k = 0; k < PointList.Count; k++)
            {
                bool sign = true;
                for (int i = 0; i < PointList.Count; i++)
                {
                    if (PointList[i].order == 4)
                    {
                        sign = false;
                        PointList[i].order++;
                        if (PointList[i].refpoints.Count == 4)
                        {
                            if (PointList[i].refpoints[0].order == 5 && PointList[i].refpoints[2].order != 5)
                            {
                                PointList[i].refpoints[2].order = 1;
                            }
                            if (PointList[i].refpoints[1].order == 5 && PointList[i].refpoints[3].order != 5)
                            {
                                PointList[i].refpoints[3].order = 1;
                            }
                            if (PointList[i].refpoints[2].order == 5 && PointList[i].refpoints[0].order != 5)
                            {
                                PointList[i].refpoints[0].order = 1;
                            }
                            if (PointList[i].refpoints[3].order == 5 && PointList[i].refpoints[1].order != 5)
                            {
                                PointList[i].refpoints[1].order = 1;
                            }
                        }
                        else
                        {
                            for (int j = 0; j < PointList[i].refpoints.Count; j++)
                            {
                                PointList[i].refpoints[j].order++;
                            }
                        }
                    }
                }
                for (int i = 0; i < PointList.Count; i++)
                {
                    if (PointList[i].order > 0 && PointList[i].order < 4)
                    {
                        PointList[i].order = 4;
                    }
                }
                if (sign)
                {
                    break;
                }
            }
            return(PointList);
        }