Esempio n. 1
0
        static Atom[,] ReadCompressedChannelFromStream(Stream stream, int width)
        {
            List <Atom> atoms          = new List <Atom>();
            bool        readSuccessful = false;

            do
            {
                readSuccessful = Atom.Deserialize(stream, out Atom atom);
                atoms.Add(atom);
            } while (readSuccessful);

            Atom[,] channel = new Atom[atoms.Count / width, width];
            for (int y = 0; y < atoms.Count / width; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    channel[y, x] = atoms[y * width + x];
                }
            }
            return(channel);
        }
Esempio n. 2
0
    public static AtomDetails[,,] ToDetails(string f)
    {
        string[] pieces = f.Split(';');
        AtomDetails[,,] details = new AtomDetails[AgentSize, AgentSize, AgentSize];
        int total = 0;

        for (int i = 0; i < AgentSize; i++)
        {
            for (int k = 0; k < AgentSize; k++)
            {
                for (int j = 0; j < AgentSize; j++)
                {
                    if (pieces[total] != "")
                    {
                        details[i, j, k] = Atom.Deserialize(pieces[total]);
                    }
                    total++;
                }
            }
        }
        return(details);
    }