Beispiel #1
0
        public void BuildFromGrid2(ICartGridData pointStripList)
        {
            int minStripLen = GetMinStripLength(pointStripList);
            int id          = 0;

            IPlyVertex[,] vertexGrid = new PlyVertex[pointStripList.Count, minStripLen];
            for (int i = 0; i < pointStripList.Count; i++)
            {
                for (int j = 0; j < minStripLen; j++)
                {
                    vertexGrid[i, j] = new PlyVertex(pointStripList[i][j], id++);
                    Vertices.Add(vertexGrid[i, j]);
                }
            }
            for (int i = 0; i < pointStripList.Count - 1; i++)
            {
                for (int j = 0; j < minStripLen - 1; j++)
                {
                    var indices1 = new List <int>()
                    {
                        vertexGrid[i, j].ID, vertexGrid[i, j + 1].ID, vertexGrid[i + 1, j].ID
                    };
                    Faces.Add(new PlyFace(indices1));
                    var indices2 = new List <int>()
                    {
                        vertexGrid[i, j + 1].ID, vertexGrid[i + 1, j + 1].ID, vertexGrid[i + 1, j].ID
                    };
                    Faces.Add(new PlyFace(indices2));
                }
            }
        }
Beispiel #2
0
        private void ReadBody(List <string> section, IPlyElement element)
        {
            foreach (string line in section)
            {
                string[] tokens = line.Split(splitter, StringSplitOptions.RemoveEmptyEntries);
                if (element.Type == PlyElementType.vertex)
                {
                    float[]   floatTokens = new float[tokens.Length];
                    PlyVertex Vertex      = new PlyVertex();
                    for (int i = 0; i < tokens.Length; i++)
                    {
                        string          typeName = element.Properties[i].TypeName;
                        string          name     = element.Properties[i].Name;
                        PlyPropertyType propType = element.Properties[i].Type;
                        byte            r        = 0;
                        byte            g        = 0;
                        byte            b        = 0;
                        if (propType == PlyPropertyType.x)
                        {
                            Vertex.X = float.Parse(tokens[i]);
                        }
                        if (propType == PlyPropertyType.y)
                        {
                            Vertex.Y = float.Parse(tokens[i]);
                        }
                        if (propType == PlyPropertyType.z)
                        {
                            Vertex.Z = float.Parse(tokens[i]);
                        }
                        if (propType == PlyPropertyType.nx)
                        {
                            Vertex.Normal.X = double.Parse(tokens[i]);
                        }
                        if (propType == PlyPropertyType.ny)
                        {
                            Vertex.Normal.Y = double.Parse(tokens[i]);
                        }
                        if (propType == PlyPropertyType.nz)
                        {
                            Vertex.Normal.Z = double.Parse(tokens[i]);
                        }
                        if (propType == PlyPropertyType.red)
                        {
                            r = byte.Parse(tokens[i]);
                        }
                        if (propType == PlyPropertyType.green)
                        {
                            g = byte.Parse(tokens[i]);
                        }
                        if (propType == PlyPropertyType.blue)
                        {
                            b = byte.Parse(tokens[i]);
                        }
                        Vertex.Col = System.Drawing.Color.FromArgb(r, g, b);
                    }

                    Vertices.Add(Vertex);
                }
                if (element.Type == PlyElementType.face)
                {
                    var indexList = new List <int>();
                    for (int i = 1; i < tokens.Length; i++)
                    {
                        int temp = int.Parse(tokens[i]);
                        indexList.Add(temp);
                    }
                    Faces.Add(new PlyFace(indexList));
                }
                if (element.Type == PlyElementType.edge)
                {
                    IPlyEdge edge = new PlyEdge(element.ContainsColor);
                    for (int i = 0; i < tokens.Length; i++)
                    {
                        string          typeName = element.Properties[i].TypeName;
                        string          name     = element.Properties[i].Name;
                        PlyPropertyType propType = element.Properties[i].Type;
                        byte            r        = 0;
                        byte            b        = 0;
                        byte            g        = 0;

                        if (propType == PlyPropertyType.red)
                        {
                            r = byte.Parse(tokens[i]);
                        }
                        if (propType == PlyPropertyType.green)
                        {
                            g = byte.Parse(tokens[i]);
                        }
                        if (propType == PlyPropertyType.blue)
                        {
                            b = byte.Parse(tokens[i]);
                        }
                        if (propType == PlyPropertyType.vertex1)
                        {
                            edge.Vertex1 = int.Parse(tokens[i]);
                        }
                        if (propType == PlyPropertyType.vertex2)
                        {
                            edge.Vertex2 = int.Parse(tokens[i]);
                        }
                        edge.Color = System.Drawing.Color.FromArgb(r, g, b);
                    }
                    Edges.Add(edge);
                }
                if (element.Type == PlyElementType.material)
                {
                    for (int i = 0; i < tokens.Length; i++)
                    {
                    }
                }
                if (element.Type == PlyElementType.other)
                {
                    for (int i = 0; i < tokens.Length; i++)
                    {
                    }
                }
            }
        }