Exemple #1
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);
        }
Exemple #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;
        }
    }