示例#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
        /// <summary>
        /// Initialize the small multiple
        /// </summary>
        /// <param name="parser">The VTK Parser</param>
        /// <param name="subDataset">The SubDataset bound to this VTK view</param>
        /// <param name="dimensions">The dimensions in use</param>
        /// <param name="dataProvider">The application data provider (a.k.a, Main)</param>
        /// <returns></returns>
        public unsafe bool Init(VTKParser parser, SubDataset subDataset, Vector3Int dimensions, IDataProvider dataProvider)
        {
            subDataset.AddListener(this);
            m_subDataset   = subDataset;
            m_dataProvider = dataProvider;

            //Copy the variables
            m_dimensions = dimensions;

            VTKStructuredPoints descPts = parser.GetStructuredPointsDescriptor();

            m_descPts = descPts;

            float maxAxis = (float)Math.Max(descPts.Spacing[0] * m_dimensions[0],
                                            Math.Max(descPts.Spacing[1] * m_dimensions[1],
                                                     descPts.Spacing[2] * m_dimensions[2]));

            m_spacing = new Vector3();
            for (int i = 0; i < 3; i++)
            {
                m_spacing[i] = (float)(descPts.Spacing[i] / maxAxis);
            }

            UpdateTF();

            return(true);
        }
示例#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);
        }
示例#4
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;
        }
    }
示例#5
0
        /// <summary>
        /// Represent a VTKDataset
        /// </summary>
        /// <param name="id">The ID of the Dataset</param>
        /// <param name="name">The Dataset's name</param>
        /// <param name="parser">The VTKParser containing all the dataset.</param>
        /// <param name="ptFieldValues">Array of point field values to take account of</param>
        /// <param name="cellFieldValues">Array of cell field values to take account of</param>
        public VTKDataset(int id, String name, VTKParser parser, VTKFieldValue[] ptFieldValues, VTKFieldValue[] cellFieldValues) : base(id, name)
        {
            m_timesteps.Add(new VTKDatasetTimeStep {
                Parser          = parser,
                PtFieldValues   = new List <VTKFieldValue>(ptFieldValues),
                CellFieldValues = new List <VTKFieldValue>(cellFieldValues)
            });

            m_nbTimesteps = 1;

            //Add all the field values to load
            for (int i = 0; i < PtFieldValues.Count; i++)
            {
                VTKFieldValue        metaData = PtFieldValues[i];
                PointFieldDescriptor desc     = new PointFieldDescriptor(metaData);
                desc.ID = (UInt32)i;
                m_ptFieldDescs.Add(desc);
            }
        }