示例#1
0
            protected void LoadPolydata(VtkPolyData polydata)
            {
                while (!EndOfFile)
                {
                    _curToken = GetVtkToken();
                    switch (_curToken)
                    {
                    case VtkToken.Points:
                        LoadPoints(polydata);
                        break;

                    case VtkToken.Vertices:
                    case VtkToken.Lines:
                    case VtkToken.Polygons:
                    case VtkToken.TriangleStrips:
                        LoadPolydataItems(polydata);
                        break;

                    case VtkToken.UnknowMetadata:
                        SkipMetadata();
                        break;

                    case VtkToken.None:
                        break;

                    default:
                        return;
                    }
                }
            }
示例#2
0
            protected void LoadPolydataItems(VtkPolyData polyData)
            {
                var n    = GetCount();
                var size = GetCount();

                Debug.WriteLine(string.Format("{0} n: {1}, size: {2}", _curToken, n, size));
                if (polyData.Items == null)
                {
                    polyData.Items = new Dictionary <string, PolyDataItem>();
                }

                var item = new PolyDataItem();

                item.Name    = _curToken.ToString();
                item.Indices = new List <int[]>();
                polyData.Items[item.Name] = item;
                for (int ic = 0, s = 0; ic < n && s < size; ic++)
                {
                    var iCountPerArr = GetIntData();
                    s++;
                    var arr = new int[iCountPerArr];
                    for (int i = 0; i < iCountPerArr; i++)
                    {
                        arr[i] = GetIntData();
                        s++;
                    }
                    item.Indices.Add(arr);
                }
            }
示例#3
0
            protected void LoadDataset(VtkModel model)
            {
                _curToken = GetVtkToken();
                switch (_curToken)
                {
                //                case VtkToken.StructuredPoint:break;
                //                case VtkToken.StructuredGrid:break;
                case VtkToken.UnstructuredGrid:
                    var usGrid = new VtkUnstructuredGrid();
                    LoadUnstructuredGrid(usGrid);
                    model.DataSet = usGrid;
                    break;

                case VtkToken.Polydata:
                    var polydata = new VtkPolyData();
                    LoadPolydata(polydata);
                    model.DataSet = polydata;
                    break;

                //                case VtkToken.RectilinearGrid:break;
                //                case VtkToken.Field:break;
                case VtkToken.UnknowMetadata:
                    SkipMetadata();
                    break;

                default:
                    throw new NotImplementedException(String.Format("unsupported vtk token: {0}.", _curToken));
                    break;
                }
            }