0

i have an byte[] that contains coordinates XYZ and i need to copy into 3D[, , ,] with these coordinates then convert it into it's original double value

something like that , mind it's just suedo code

buff = binReader.ReadBytes(384);
                int length = BitConverter.ToInt32(buff, 0);
                obj.coordinates = new double[length, length, length];
                for (int i = 0; i < length; i++)
                {
                    for (int k = 0; k < length; k++)
                    {
                        for (int j = 0; j < length; j++)
                        {
                            obj.coordinates[i, k, j].ToDouble() = buff[i];
                        }
                    }
                }

any idea?

  • what is the problem with this approach? – Vivek Nuna Jun 04 '20 at 11:48
  • I guess you don't understand how to convert `i`, `j` and `k` into index? It's probably [flattened array](https://stackoverflow.com/q/7367770/1997232). – Sinatr Jun 04 '20 at 11:49
  • @viveknuna its not working for some reason cause of the size as i am getting this error System.OutOfMemoryException: 'Exception of type 'System.OutOfMemoryException' was thrown.' –  Jun 04 '20 at 11:50
  • @user22387 waht is value of length? – Vivek Nuna Jun 04 '20 at 11:54
  • @viveknuna buff = binReader.ReadBytes(384); int length = BitConverter.ToInt32(buff, 0); –  Jun 04 '20 at 11:55
  • Can you put the actual code? @user22387 – Vivek Nuna Jun 04 '20 at 11:58
  • @viveknuna that is the actual code so far the coordinates are stored in 384 bytes[] , i need to get the XYZ values and add it to double 3d array –  Jun 04 '20 at 12:00
  • So can you tell me, what value of length are you getting while debugging? – Vivek Nuna Jun 04 '20 at 12:05
  • So if you have single point with coordinates {1000000, 0, 0} you are starting with allocating 3-dimentional array capable to hold 10^18 points? – Sinatr Jun 04 '20 at 12:06
  • @viveknuna thats a huge number i didnt expect ( 538976288 ) any idea how to get the true length value? –  Jun 04 '20 at 12:09
  • You may use a [`LongLength`](https://learn.microsoft.com/en-us/dotnet/api/system.array.longlength?view=netcore-3.1) property – Pavel Anikhouski Jun 04 '20 at 12:27

0 Answers0