示例#1
0
        public unsafe VTKUnityStructuredGrid(VTKDataset vtkDataset, UInt32 desiredDensity, IDataProvider dataProvider)
        {
            m_dataset        = vtkDataset;
            m_desiredDensity = desiredDensity;
            m_dataProvider   = dataProvider;

            VTKParser parser = m_dataset.Parser;

            if (parser.GetDatasetType() != VTKDatasetType.VTK_STRUCTURED_POINTS)
            {
                Debug.Log("Error: The dataset should be a structured points dataset");
                return;
            }

            //Get the points and modify the points / normals buffer
            m_ptsDesc = parser.GetStructuredPointsDescriptor();

            //Determine the new dimension and spacing
            m_dimensions = GetDisplayableSize();
            float maxAxis = (float)Math.Max(m_ptsDesc.Spacing[0] * m_ptsDesc.Size[0],
                                            Math.Max(m_ptsDesc.Spacing[1] * m_ptsDesc.Size[1],
                                                     m_ptsDesc.Spacing[2] * m_ptsDesc.Size[2]));

            for (int i = 0; i < 3; i++)
            {
                m_spacing[i] = (float)(m_ptsDesc.Size[i] * m_ptsDesc.Spacing[i] / m_dimensions[i] / maxAxis);
            }

            //Small multiples array
            m_smallMultiples = new List <VTKUnitySmallMultiple>();
        }
示例#2
0
    static void Main(String[] argv)
    {
        if (argv.Length < 1)
        {
            Console.WriteLine("Needs the path to the dataset");
            return;
        }

        VTKParser parser = new VTKParser(argv[0]);

        if (!parser.Parse())
        {
            Console.WriteLine($"Fail to parse the file {argv[0]}");
            return;
        }

        if (parser.GetDatasetType() == VTKDatasetType.VTK_UNSTRUCTURED_GRID)
        {
            Console.WriteLine("Unstructured grid");
            return;
        }
        else if (parser.GetDatasetType() == VTKDatasetType.VTK_STRUCTURED_POINTS)
        {
            Console.WriteLine("Structured points");
            VTKStructuredPoints pts = parser.GetStructuredPointsDescriptor();
            Console.WriteLine($"Structured points : dimensions {pts.Size[0]}, {pts.Size[1]}, {pts.Size[2]}");
            Console.WriteLine($"Structured points : spacing    {pts.Spacing[0]:F4}, {pts.Spacing[1]:F4}, {pts.Spacing[2]:F4}");
            Console.WriteLine($"Structured points : origin     {pts.Origin[0]:F4},  {pts.Origin[1]:F4},  {pts.Origin[2]:F4}");

            List <VTKFieldValue> fieldDesc = parser.GetPointFieldValueDescriptors();
            if (fieldDesc.Count > 0)
            {
                foreach (var f in fieldDesc)
                {
                    Console.WriteLine($"Found {f.Name} with {f.NbTuples} values");
                }
            }
            else
            {
                Console.WriteLine("No value found...");
            }

            return;
        }
    }
示例#3
0
        /// <summary>
        /// Add a new timestep to this VTKDataset
        /// </summary>
        /// <param name="parser">The parser data for this new timestep. As VTK format does not handle timestep inherently, we are using multiple VTKParser</param>
        /// <returns></returns>
        public bool AddTimestep(VTKParser parser)
        {
            //Check the type of the new timestep
            if (Parser.GetDatasetType() != parser.GetDatasetType())
            {
                return(false);
            }
            if (Parser.GetDatasetType() == VTKDatasetType.VTK_STRUCTURED_POINTS)
            {
                if (Parser.GetStructuredPointsDescriptor() != parser.GetStructuredPointsDescriptor())
                {
                    return(false);
                }
            }

            List <VTKFieldValue> ptFieldValues   = new List <VTKFieldValue>();
            List <VTKFieldValue> cellFieldValues = new List <VTKFieldValue>();

            foreach (VTKFieldValue f in PtFieldValues)
            {
                VTKFieldValue tf = parser.GetPointFieldValueDescriptors().Find((t) => (f as FieldValueMetaData) == (t as FieldValueMetaData));
                if (tf is null)
                {
                    return(false);
                }
                ptFieldValues.Add(tf);
            }

            foreach (VTKFieldValue f in CellFieldValues)
            {
                VTKFieldValue tf = parser.GetCellFieldValueDescriptors().Find((t) => (f as FieldValueMetaData) == (t as FieldValueMetaData));
                if (tf is null)
                {
                    return(false);
                }
                ptFieldValues.Add(tf);
            }

            m_timesteps.Add(new VTKDatasetTimeStep {
                Parser          = parser,
                PtFieldValues   = ptFieldValues,
                CellFieldValues = cellFieldValues
            });

            m_nbTimesteps++;
            return(true);
        }