Esempio n. 1
0
        public static T[] GetOneDimArray <T>(ucar.ma2.Array theArray)
        {
            if (typeof(string) != typeof(T))
            {
                return((T[])theArray.get1DJavaArray(typeof(T)));
            }
            else
            {
                var shape = theArray.getShape();
                var size  = shape[1];


                char[]        temp     = theArray.get1DJavaArray(typeof(char)) as char[];
                List <char>   charList = new List <char>();
                List <string> strList  = new List <string>();
                for (int i = 0; i < temp.Length; i++)
                {
                    if (temp[i] == '\0')
                    {
                        if (charList.Count > 0)
                        {
                            strList.Add(new string(charList.ToArray()));
                            charList.Clear();
                        }
                    }
                    else
                    {
                        charList.Add(temp[i]);
                        if (charList.Count == size)
                        {
                            strList.Add(new string(charList.ToArray()));
                            charList.Clear();
                        }
                    }
                }
                return(strList.ToArray() as T[]);
            }
        }